Thanks Peter,
This format has an antique feel about it. Do you think it has a future?
Anyway I'm studying it.
Charles
/*
TGA FILE FORMAT
===============
FIELD DESCRIPT
1 1 byte ID length Length of the image ID field
2 1 byte Color map type Whether a color map is included
3 1 byte Image type Compression and color types
4 5 bytes Color map specification Describes the color map
5 10 bytes Image specification Image dimensions and format
VALUES IN THESE FIELDS
Image ID length (field 1)
'------------------------
0 - 255 The number of bytes that the image ID field consists of. The image
ID field can contain any information, but it is common for it to
contain the date and time the image was created or a serial number.
As of version 2.0 of the TGA spec, the date and time the image was created
is catered for in the extension area.
Color map type (field 2)
'-----------------------
has the value:
0 if image file contains no color map
1 if present
2-127 reserved by Truevision
128-255 available for developer use
Image type (field 3)
'-------------------
is enumerated in the lower three bits, with the fourth bit as a flag for RLE.
Some possible values are:
0 no image data is present,
1 uncompressed, color-mapped image,
2 uncompressed, true-color image,
3 uncompressed, black-and-white image,
9 run-length encoded, color-mapped Image,
10 run-length encoded, true-color image and,
11 run-length encoded, black-and-white Image
Color map specification (field 4)
'--------------------------------
has three subfields:
First entry index (2 bytes): offset into the color map table
Color map length (2 bytes): number of entries
Color map entry size (1 byte): number of bits per pixel
Image specification (field 5)
'----------------------------
has six subfields:
X-origin (2 bytes): absolute coordinate of lower-left corner for displays where origin is at the lower left
Y-origin (2 bytes): as for X-origin
Image width (2 bytes): width in pixels
Image height (2 bytes): height in pixels
Pixel depth (1 byte): bits per pixel
Image Descriptor (1 byte): bits 3-0 give the alpha channel depth, bits 5-4 give direction
Image and color map data
'-----------------------
Field no. Length Field Description
6 From image ID length field Image ID Optional field containing identifying information
7 From color map specification field Color map data Look-up table containing color map data
8 From image specification field Image data Stored according to the image descriptor
EXTENSION AREA:
Field no. Length Field Description
10 2 bytes Extension size Size in bytes of the extension area, always 495
11 41 bytes Author name Name of the author. If not used, bytes should be set to NULL (\0) or spaces
12 324 bytes Author comment A comment, organized as four lines, each consisting of 80 characters plus a NULL
13 12 bytes Date/time stamp Date and time at which the image was created
14 41 bytes Job ID
15 6 bytes Job time Hours, minutes and seconds spent creating the file (for billing, etc.)
16 41 bytes Software ID The application that created the file.
17 3 bytes Software version
18 4 bytes Key color
19 4 bytes Pixel aspect ratio
20 4 bytes Gamma value
21 4 bytes Color correction offset Number of bytes from the beginning of the file to the color correction table if present
22 4 bytes Postage stamp offset Number of bytes from the beginning of the file to the postage stamp image if present
23 4 bytes Scan line offset Number of bytes from the beginning of the file to the scan lines table if present
24 1 byte Attributes type Specifies the alpha channel
FOOTER
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.
Field no. Length Field Description
28 4 bytes Extension offset Offset in bytes from the beginning of the file
29 4 bytes Developer area offset Offset in bytes from the beginning of the file
30 16 bytes Signature Contains "TRUEVISION-XFILE"
31 1 byte Contains "."
32 1 byte Contains NULL