| 1 |
# https://en.wikipedia.org/wiki/Truevision_TGA, create binary header with: |
| 2 |
# perl -nE 's/#.*$//g; s/([0-9A-F]+)/print(chr(hex("$1")))/ge' tga_head.txt > tga_head.bin |
| 3 |
# details with: identify -ping -verbose -unique a.tga |
| 4 |
# |
| 5 |
#Field no. Length Field name Description Our choice |
| 6 |
|
| 7 |
4 #1 1 byte ID length Length of the image ID field - 2 byte ID 0x4D, 0x4E |
| 8 |
1 #2 1 byte Color map type Whether a color map is included - 1 if color-map present |
| 9 |
1 #3 1 byte Image type Compression and color types - 1 uncompressed color-mapped image |
| 10 |
|
| 11 |
#4 5 bytes Color map specification Describes the color map |
| 12 |
0 0 # First entry index (2 bytes): index of first color map entry that is included in the file |
| 13 |
0 1 # Color map length (2 bytes): number of entries of the color map that are included in the file - 0x100 = 256 entries |
| 14 |
18 # Color map entry size (1 byte): number of bits per pixel - 24 bpp (3 bytes each entry) |
| 15 |
|
| 16 |
#5 10 bytes Image specification Image dimensions and format |
| 17 |
0 0 # X-origin (2 bytes): absolute coordinate of lower-left corner for displays where origin is at the lower left |
| 18 |
0 0 # Y-origin (2 bytes): as for X-origin |
| 19 |
40 1 # Image width (2 bytes): width in pixels - 320 |
| 20 |
C8 0 # Image height (2 bytes): height in pixels - 200 |
| 21 |
8 # Pixel depth (1 byte): bits per pixel - 8 bpp |
| 22 |
20 # Image descriptor (1 byte): bits 3-0 give the alpha channel depth, bits 5-4 give direction - 00100000 for top-left origin |
| 23 |
|
| 24 |
4D 4E 31 0 #6 From image ID length field Image ID Optional field containing identifying information - empty, or some ID |
| 25 |
#7 From color map specification field Color map data Look-up table containing color map data - .pal |
| 26 |
#8 From image specification field Image data Stored according to the image descriptor - .scr |