TGA

This format was developed by the Truevision company in 1987. The format is variable, enabling several types of compression. All the Targa formats are identified using Data type table. Individual formats are as follows:

DATA TYPE:

0 - does not contain any image data 
1 - non-compressed color image 
2 - non-compressed RGB image
3 - non-compressed black & white image
9 - RLE coded color image
10 - PLE coded RGB image
11 - compressed black & white image
32 - compressed color data using Huffman, Delta, and RLE coding
33 - compressed color data using Huffman, Delta, and RLE coding,   4-transitional square transfer

Example: Non-compressed color image

DATA TYPE 1: non-compressed color image 

 

Offset Length Meaning
0 1 Size of the identification array. If it is 0, then the image has no identification array. 
1 1 Color Map Type. 
 For a non-compressed color image the value is 1.
2 1 Image Type Code. The value is always 1 . 
3 2 Color Map Origin, index to the first color map
5 2 Length Color Map, the number of color maps
7 1 vSize Color Map, the number of bits per every color map. 16 for Targa 16, 24 for Targa 24, 32 for Targa 32
8 2 X-size of the image
10 2 Y-size of the image
12 2 Width of picture in pixels
14 2 Height in pixels
16 1 Number of pixels in the image
17 1 Image Descriptor Byte. 

Bits 3-0 - number of bits for each pixel. 

Bit 4 reserved. Must be 0. 

Bit 5 screen origin bit. 
0 = Origin in lower left-hand corner. 
1 = Origin in lower right-hand corner. Must be 0.

Bits 7-6 Data storage interleaving flag. 
00 = non-interleaved. 
01 = two-way (even/odd) interleaving. 
10 = four way interleaving . 
11 = reserved. This entire byte should be set to 0.

18 ? Image Identification Field. Contains a free-form identification field of the length specified in byte 1 of the image record. It is usually omitted (length in byte 1 = 0), but can be up to 255 characters. If more identification information is required, it can be stored after the image data.
? ? Color map data. 

The offset is determined by the size of the Image Identification Field. The length is determined by the Color Map Specification, which describes the size of each entry and the number of entries. Each color map entry is 2, 3, or 4 bytes. Unused bits are assumed to specify attribute bits. 

The 4 byte entry contains 1 byte for blue, 1 byte for green, 1 byte for red, and 1 byte of attribute information, in that order.

The 3 byte entry contains 1 byte each of blue, green, and red. |

The 2 byte entry is broken down as follows: ARRRRRGG GGGBBBBB, where each letter represents a bit. But, because of the lo-hi storage order, the first byte coming from the file will actually be GGGBBBBB, and the second will be ARRRRRGG. "A" represents an attribute bit. 
? ? Image Data Field. 

This field specifies (width) x (height) color map indices. Each index is stored as an integral number of bytes (typically 1 or 2). All fields are unsigned. The low-order byte of a two-byte field is stored first. 
Copyright (c) 1999-2017 Juraj Štugel. www.netgraphics.sk