-
Tga
I'm tired of using other people's image libraries. So I decided to write my own. I started with Bitmap files (.BMP, .ICO, & .CUR) first. It took me about an hour to finish those because it is easy to use the built in BitBlt() function. Now I'm on TGA files. I went to wotsit.org and found the documentation but I'm unsure exactly how to display the file. Should I convert it to a bitmap somehow? Or do i have to do a for() loop and display the bits 1 by 1? Or is there some other way? Once I figure this out the rest is easy...
-
Once you have the decoded bits there are two options you can use to copy them to a windows HBITMAP. The first is to create an HBITMAP using CreateCompatibleBitmap and then copy the bits to it using SetDIBits. The other option is to create a dib section HBITMAP using CreateDIBSection. This will give you a pointer to the memory that contains the bits. You can read or decode your tga image into this memory. There is a sample of this approach here.
-
-
How do you display the other files?
Basically, whenever you load a bitmap, you load it into an in-memory buffer which will contain raw image data in the screen-specific pixel format (RGB-24, BGR-32, Palettized-8, whatever...). Loading a TGA is not any different from the other formats: you undo any compression that may be on the image (runlength, Huffman, LZ*, JPEG-like Quantization, ...) to get the raw data in the image-specific format (that would be some palettized format for icons and cursors, GIFs, some PNGs and BMPs and others, or RGB-24 bottom-up line order for true-color BMPs, or perhaps YUV for some Adobe JPEG files, or the standard JFIF YCbCr or YCCK format). Then you transcode this format to whatever you need in the final image, which depends on your display settings, as mentioned earlier.