Thread: C# resources and question about C++, and what data is possible to save into a file

  1. #1
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717

    C# resources and question about C++, and what data is possible to save into a file

    hello.

    I've been working a bit with C# to make a GUI for an editor of mine, now I need a rectangle tool that's transparent and fully controllable by the user, much like the crop tool in Photoshop and The Gimp, can anyone link me to a resource, since I don't wanna learn C# :S

    Also, I did make a stupid approach, I didn't check how compatible C# is with C++. I wanna make a console app that takes certain parameters, if not direct data (depending on how well C# and C++ work together) and then this console app creates my file with the specified data... Is this possible?

    Then last but not least, I wanna make a file format which holds a texture, (meaning .png, .dds, .tga (all these support transparency)), and then I need it to hold some other data too, like some vectors (x and y coordinates) and maybe something else, I ain't sure, but those in the first place... Is this possible?

    Hope I'm clear and thanks in advance!
    Currently research OpenGL

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Akkernight View Post
    Also, I did make a stupid approach, I didn't check how compatible C# is with C++. I wanna make a console app that takes certain parameters, if not direct data (depending on how well C# and C++ work together) and then this console app creates my file with the specified data... Is this possible?
    Yes, they can work with each other.
    But how well? That is always the question when working with different languages, so saying the answer to that is a difficult task.

    Then last but not least, I wanna make a file format which holds a texture, (meaning .png, .dds, .tga (all these support transparency)), and then I need it to hold some other data too, like some vectors (x and y coordinates) and maybe something else, I ain't sure, but those in the first place... Is this possible?
    Of course it's possible.
    It's dead easy in C++, but I don't know what options C# offers for reading files, so saying how also becomes a difficult task.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    The C# to C++ thing can be a little tricky. I made a converter that converted a bmp file to my own format (adding an alpha-channel and some stuff like that) and what i found out is that you have to be very careful to make sure you choose the correct data-types in C# for them to match in C++ (a char in C# is a 16-bit Unicode character for instance).

    Read up on the different inbuilt data-types in C# and find which ones map to an inbuilt data-type in C++ and you should be good.
    Last edited by Shakti; 04-15-2009 at 04:08 AM.

  4. #4
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    ... I'll have my man Mossa do it, since he's interested in C# and I'm definetly not xP
    Also, to make a file format, I will have to make a writer and reader 'SDK', right?
    Is it possible to get the code itself from a .dds, .png and .tga file, or will I have to use a link to the image location?
    Currently research OpenGL

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    A file format is exactly what you want it to be.
    For example, in some code you might write like:
    Code:
    struct mystruct { /* ... */ };
    mystruct foo;
    fwrite(&foo, sizeof(foo), 1, f);
    Now you have a file format.
    Getting it to work with C# is the only real problem.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    PNG allows arbitrary data blocks, so using libpng for reading and writing PNG data might be a good approach.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    you can also use DevIL to read in different image-formats easily. It supports reading png, tga and dds files and is quite easy to use once you get the hang of how it works.

  8. #8
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    Ok, DevIL sounds like the thing... Still, working with C# is more than horrible >.<
    I think Imma make the console version in C++, then get the GUI working based on that...
    Currently research OpenGL

Popular pages Recent additions subscribe to a feed