Terrain Development Guide
Chapter 4: Additional Resources
Understanding TGA Files
This section is not required reading; it is here for anyone that wants to learn more about TGA files and how they are structured. You do not need to know this level of information to build a Targetware terrain.
The first thing is to understand that a graphics image is just a bunch of numbers contained in a file, just like any other file on your computer. The structure of the file consists of three data blocks. First is a header, which contains information on the size of the file and other properties associated with the contents to the file. The header is a kind of "Table of Contents" for the file. Next is the color map, which consists of 256 sets of red-green-blue values defining the color palette used by the file. The color map is then followed by a block of index values (the actual image data) which contains, for every position (pixel) in the image, a reference to one of the positions in the palette. For example, in gray-scale, the palette typically runs from black (palette index #0) to white (palette index #255) in 256 increments. If there were to be a black pixel at a particular point, there would be an index value of 255 at that location in the raster. The figure below illustrates the Targa format.

More detailed information on the Targa specification can be found here.
|