Posts

Simple targa image file TGA loader C++

What is a tga file? TGA Targa is a specific file specification that is use to store and load image data. Image data that is store in binary. Chances are if you are here, viewing this blog you know what a TGA image is. But just in case you don't know, you can educate your self more about this at the following link wikipedia.
To begin writing your tag image loader, you will need to first create a tga header structure. You will do so with the following code.

struct TGA_Header { unsignedchar  ID_Length; unsignedchar  ColorMapType; unsignedchar  ImageType; unsignedchar  ColorMapSpecification[5]; unsignedshort xOrigin; unsignedshort yOrigin; unsignedshort ImageWidth; unsignedshort ImageHeight; unsignedchar  PixelDepth; };
The relevant data we require from the header is the ImageHeight, ImageWidth, and the PixelDepth which is the bpp bits-per-pixel. The rest of information in the header we won't need. The next step is to create a couple of variables to so your image info. You can do so with th…
Recent posts