TGA



 Truevision TGA, often referred to as TARGA, is a raster graphics file format. TGA is an initialism for Truevision Graphics Adapter.

Header
All Targa formats are identified by a Data Type field, which is a one byte binary integer located in byte three of the file. These data types are:

0 -  No image data included. 1 -  Uncompressed, color-mapped images. 2 -  Uncompressed, RGB images. 3 -  Uncompressed, black and white images. 9 -  Runlength encoded color-mapped images. 10 -  Runlength encoded RGB images. 11 -  Compressed, black and white images. 32 -  Compressed color-mapped data, using Huffman, Delta, and runlength encoding. 33 -  Compressed color-mapped data, using Huffman, Delta, and runlength encoding. 4-pass quadtree-type process.

The bitsperpixel specifies the size of each colour value. When 24 or 32 the normal conventions apply. For 16 bits each colour component is stored as 5 bits and the remaining bit is a binary alpha value. The colour components are converted into single byte components by simply shifting each component up by 3 bits (multiply by 8).

File footer (optional)
If a TGA image contains a footer, the chances are that it is a TGA version 2 file. The footer is the final 26 bytes of the file, of which the last 18 are constant.

Reference

 * http://www.paulbourke.net/dataformats/tga/
 * http://en.wikipedia.org/wiki/Truevision_TGA