123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605 |
- TGA specs, from the 2D graphics format web collection.
- This was annotated with a remark that there are a few
- inaccuracies in this ASCII version. - b.
- -----------------------------------------------------------------------
- This file has been created to satisfy numerous requests for information
- on Targa image file formats. The information has been taken from
- Appendix C of the Truevision Technical Guide. Requests for further
- information could be directed to:
- AT&T
- Electronic Photography and Imaging Center
- 2002 Wellesley Ave.
- Indianapolis, IN 42619
- This document does not pretend to be complete, but it does pretend to
- be accurate. If you discover any finger checks or erroneous information
- please let me know, ( David McDuffee, 75530,2626), and I will upload the
- corrections. Thanks.
- The lack of completeness is due to the fact that the Targa recognizes
- over half a dozen image file formats, some of which are more widely
- used than others. I have chosen to re-key the details on only those
- formats which I actually use. Again, if you want to know more about
- formats not covered here, you could contact your Truevision representative.
- All Targa formats are identified by a Data Type field, which is a one
- byte binary integer located in byte three of the file. The various
- file types specified by this field are as follows:
- 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.
- This document will describe only four formats: 1, 2, 9, and 10.
- --------------------------------------------------------------------------------
- DATA TYPE 1: Color-mapped images. |
- _______________________________________________________________________________|
- | Offset | Length | Description |
- |--------|--------|------------------------------------------------------------|
- |--------|--------|------------------------------------------------------------|
- | 0 | 1 | Number of Characters in Identification Field. |
- | | | |
- | | | This field is a one-byte unsigned integer, specifying |
- | | | the length of the Image Identification Field. Its range |
- | | | is 0 to 255. A value of 0 means that no Image |
- | | | Identification Field is included. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 1 | 1 | Color Map Type. |
- | | | |
- | | | This field contains a binary 1 for Data Type 1 images. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 2 | 1 | Image Type Code. |
- | | | |
- | | | This field will always contain a binary 1. |
- | | | ( That's what makes it Data Type 1 ). |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 3 | 5 | Color Map Specification. |
- | | | |
- | 3 | 2 | Color Map Origin. |
- | | | Integer ( lo-hi ) index of first color map entry. |
- | | | |
- | 5 | 2 | Color Map Length. |
- | | | Integer ( lo-hi ) count of color map entries. |
- | | | |
- | 7 | 1 | Color Map Entry Size. |
- | | | Number of bits in each color map entry. 16 for |
- | | | the Targa 16, 24 for the Targa 24, 32 for the Targa 32. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 8 | 10 | Image Specification. |
- | | | |
- | 8 | 2 | X Origin of Image. |
- | | | Integer ( lo-hi ) X coordinate of the lower left corner |
- | | | of the image. |
- | | | |
- | 10 | 2 | Y Origin of Image. |
- | | | Integer ( lo-hi ) Y coordinate of the lower left corner |
- | | | of the image. |
- | | | |
- | 12 | 2 | Width of Image. |
- | | | Integer ( lo-hi ) width of the image in pixels. |
- | | | |
- | 14 | 2 | Height of Image. |
- | | | Integer ( lo-hi ) height of the image in pixels. |
- | | | |
- | 16 | 1 | Image Pixel Size. |
- | | | Number of bits in a stored pixel index. |
- | | | |
- | 17 | 1 | Image Descriptor Byte. |
- | | | Bits 3-0 - number of attribute bits associated with each |
- | | | pixel. |
- | | | Bit 4 - reserved. Must be set to 0. |
- | | | Bit 5 - screen origin bit. |
- | | | 0 = Origin in lower left-hand corner. |
- | | | 1 = Origin in upper left-hand corner. |
- | | | Must be 0 for Truevision images. |
- | | | 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. Don't ask me. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 18 | varies | Image Identification Field. |
- | | | Contains a free-form identification field of the length |
- | | | specified in byte 1 of the image record. It's 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. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | varies | varies | 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. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | varies | varies | 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. |
- | | | |
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- DATA TYPE 2: Unmapped RGB images. |
- _______________________________________________________________________________|
- | Offset | Length | Description |
- |--------|--------|------------------------------------------------------------|
- |--------|--------|------------------------------------------------------------|
- | 0 | 1 | Number of Characters in Identification Field. |
- | | | |
- | | | This field is a one-byte unsigned integer, specifying |
- | | | the length of the Image Identification Field. Its value |
- | | | is 0 to 255. A value of 0 means that no Image |
- | | | Identification Field is included. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 1 | 1 | Color Map Type. |
- | | | |
- | | | This field contains either 0 or 1. 0 means no color map |
- | | | is included. 1 means a color map is included, but since |
- | | | this is an unmapped image it is usually ignored. TIPS |
- | | | ( a Targa paint system ) will set the border color |
- | | | the first map color if it is present. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 2 | 1 | Image Type Code. |
- | | | |
- | | | This field will always contain a binary 2. |
- | | | ( That's what makes it Data Type 2 ). |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 3 | 5 | Color Map Specification. |
- | | | |
- | | | Ignored if Color Map Type is 0; otherwise, interpreted |
- | | | as follows: |
- | | | |
- | 3 | 2 | Color Map Origin. |
- | | | Integer ( lo-hi ) index of first color map entry. |
- | | | |
- | 5 | 2 | Color Map Length. |
- | | | Integer ( lo-hi ) count of color map entries. |
- | | | |
- | 7 | 1 | Color Map Entry Size. |
- | | | Number of bits in color map entry. 16 for the Targa 16, |
- | | | 24 for the Targa 24, 32 for the Targa 32. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 8 | 10 | Image Specification. |
- | | | |
- | 8 | 2 | X Origin of Image. |
- | | | Integer ( lo-hi ) X coordinate of the lower left corner |
- | | | of the image. |
- | | | |
- | 10 | 2 | Y Origin of Image. |
- | | | Integer ( lo-hi ) Y coordinate of the lower left corner |
- | | | of the image. |
- | | | |
- | 12 | 2 | Width of Image. |
- | | | Integer ( lo-hi ) width of the image in pixels. |
- | | | |
- | 14 | 2 | Height of Image. |
- | | | Integer ( lo-hi ) height of the image in pixels. |
- | | | |
- | 16 | 1 | Image Pixel Size. |
- | | | Number of bits in a pixel. This is 16 for Targa 16, |
- | | | 24 for Targa 24, and .... well, you get the idea. |
- | | | |
- | 17 | 1 | Image Descriptor Byte. |
- | | | Bits 3-0 - number of attribute bits associated with each |
- | | | pixel. For the Targa 16, this would be 0 or |
- | | | 1. For the Targa 24, it should be 0. For |
- | | | Targa 32, it should be 8. |
- | | | Bit 4 - reserved. Must be set to 0. |
- | | | Bit 5 - screen origin bit. |
- | | | 0 = Origin in lower left-hand corner. |
- | | | 1 = Origin in upper left-hand corner. |
- | | | Must be 0 for Truevision images. |
- | | | Bits 7-6 - Data storage interleaving flag. |
- | | | 00 = non-interleaved. |
- | | | 01 = two-way (even/odd) interleaving. |
- | | | 10 = four way interleaving. |
- | | | 11 = reserved. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 18 | varies | Image Identification Field. |
- | | | Contains a free-form identification field of the length |
- | | | specified in byte 1 of the image record. It's 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. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | varies | varies | Color map data. |
- | | | |
- | | | If the Color Map Type is 0, this field doesn't exist. |
- | | | Otherwise, just read past it to get to the image. |
- | | | The Color Map Specification describes the size of each |
- | | | entry, and the number of entries you'll have to skip. |
- | | | Each color map entry is 2, 3, or 4 bytes. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | varies | varies | Image Data Field. |
- | | | |
- | | | This field specifies (width) x (height) pixels. Each |
- | | | pixel specifies an RGB color value, which is stored as |
- | | | an integral number of bytes. |
- | | | |
- | | | 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. |
- | | | |
- | | | The 3 byte entry contains 1 byte each of blue, green, |
- | | | and red. |
- | | | |
- | | | The 4 byte entry contains 1 byte each of blue, green, |
- | | | red, and attribute. For faster speed (because of the |
- | | | hardware of the Targa board itself), Targa 24 images are |
- | | | sometimes stored as Targa 32 images. |
- | | | |
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- DATA TYPE 9: Run Length Encoded, color-mapped images. |
- _______________________________________________________________________________|
- | Offset | Length | Description |
- |--------|--------|------------------------------------------------------------|
- |--------|--------|------------------------------------------------------------|
- | 0 | 1 | Number of Characters in Identification Field. |
- | | | |
- | | | This field is a one-byte unsigned integer, specifying |
- | | | the length of the Image Identification Field. Its value |
- | | | is 0 to 255. A value of 0 means that no Image |
- | | | Identification Field is included. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 1 | 1 | Color Map Type. |
- | | | |
- | | | This field is always 1 for color-mapped images. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 2 | 1 | Image Type Code. |
- | | | |
- | | | A binary 9 for this data type. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 3 | 5 | Color Map Specification. |
- | | | |
- | 3 | 2 | Color Map Origin. |
- | | | Integer ( lo-hi ) index of first color map entry. |
- | | | |
- | 5 | 2 | Color Map Length. |
- | | | Integer ( lo-hi ) count of color map entries. |
- | | | |
- | 7 | 1 | Color Map Entry Size. |
- | | | Number of bits in each color map entry. 16 for the |
- | | | Targa 16, 24 for the Targa 24, 32 for the Targa 32. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 8 | 10 | Image Specification. |
- | | | |
- | 8 | 2 | X Origin of Image. |
- | | | Integer ( lo-hi ) X coordinate of the lower left corner |
- | | | of the image. |
- | | | |
- | 10 | 2 | Y Origin of Image. |
- | | | Integer ( lo-hi ) Y coordinate of the lower left corner |
- | | | of the image. |
- | | | |
- | 12 | 2 | Width of Image. |
- | | | Integer ( lo-hi ) width of the image in pixels. |
- | | | |
- | 14 | 2 | Height of Image. |
- | | | Integer ( lo-hi ) height of the image in pixels. |
- | | | |
- | 16 | 1 | Image Pixel Size. |
- | | | Number of bits in a pixel. This is 16 for Targa 16, |
- | | | 24 for Targa 24, and .... well, you get the idea. |
- | | | |
- | 17 | 1 | Image Descriptor Byte. |
- | | | Bits 3-0 - number of attribute bits associated with each |
- | | | pixel. For the Targa 16, this would be 0 or |
- | | | 1. For the Targa 24, it should be 0. For the |
- | | | Targa 32, it should be 8. |
- | | | Bit 4 - reserved. Must be set to 0. |
- | | | Bit 5 - screen origin bit. |
- | | | 0 = Origin in lower left-hand corner. |
- | | | 1 = Origin in upper left-hand corner. |
- | | | Must be 0 for Truevision images. |
- | | | Bits 7-6 - Data storage interleaving flag. |
- | | | 00 = non-interleaved. |
- | | | 01 = two-way (even/odd) interleaving. |
- | | | 10 = four way interleaving. |
- | | | 11 = reserved. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 18 | varies | Image Identification Field. |
- | | | Contains a free-form identification field of the length |
- | | | specified in byte 1 of the image record. It's 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. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | varies | varies | 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. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | varies | varies | Image Data Field. |
- | | | |
- | | | This field specifies (width) x (height) color map |
- | | | indices. The indices are stored in packets. There |
- | | | two types of packets: Run-length packets, and Raw |
- | | | packets. Both types of packets consist of a 1-byte |
- | | | header, identifying the type of packet and specifying a |
- | | | count, followed by a variable-length body. |
- | | | The high-order bit of the header is "1" for the |
- | | | run length packet, and "0" for the raw packet. |
- | | | |
- | | | For the run-length packet, the header consists of: |
- | | | __________________________________________________ |
- | | | | 1 bit | 7 bit repetition count minus 1. | |
- | | | | ID | Since the maximum value of this | |
- | | | | | field is 127, the largest possible | |
- | | | | | run size would be 128. | |
- | | | |-------|----------------------------------------| |
- | | | | 1 | C C C C C C C | |
- | | | -------------------------------------------------- |
- | | | |
- | | | For the raw packet, the header consists of: |
- | | | __________________________________________________ |
- | | | | 1 bit | 7 bit number of pixels minus 1. | |
- | | | | ID | Since the maximum value of this | |
- | | | | | field is 127, there can never be | |
- | | | | | more than 128 pixels per packet. | |
- | | | |-------|----------------------------------------| |
- | | | | 0 | N N N N N N N | |
- | | | -------------------------------------------------- |
- | | | |
- | | | For the run length packet, the header is followed by |
- | | | a single color index, which is assumed to be repeated |
- | | | the number of times specified in the header. The RLE |
- | | | packet may cross scan lines ( begin on one line and end |
- | | | on the next ). |
- | | | |
- | | | For the raw packet, the header is followed by the number |
- | | | of color indices specified in the header. The raw |
- | | | packet may cross scan lines ( begin on one line and end |
- | | | on the next ). |
- | | | |
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- DATA TYPE 10: Run Length Encoded, RGB images. |
- _______________________________________________________________________________|
- | Offset | Length | Description |
- |--------|--------|------------------------------------------------------------|
- |--------|--------|------------------------------------------------------------|
- | 0 | 1 | Number of Characters in Identification Field. |
- | | | |
- | | | This field is a one-byte unsigned integer, specifying |
- | | | the length of the Image Identification Field. Its range |
- | | | is 0 to 255. A value of 0 means that no Image |
- | | | Identification Field is included. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 1 | 1 | Color Map Type. |
- | | | |
- | | | This field contains either 0 or 1. 0 means no color map |
- | | | is included. 1 means a color map is included, but since |
- | | | this is an unmapped image it is usually ignored. TIPS |
- | | | ( a Targa paint system ) will set the border color |
- | | | the first map color if it is present. Wowie zowie. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 2 | 1 | Image Type Code. |
- | | | |
- | | | Binary 10 for this type of image. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 3 | 5 | Color Map Specification. |
- | | | |
- | | | Ignored if Color Map Type is 0; otherwise, interpreted |
- | | | as follows: |
- | | | |
- | 3 | 2 | Color Map Origin. |
- | | | Integer ( lo-hi ) index of first color map entry. |
- | | | |
- | 5 | 2 | Color Map Length. |
- | | | Integer ( lo-hi ) count of color map entries. |
- | | | |
- | 7 | 1 | Color Map Entry Size. |
- | | | Number of bits in color map entry. This value is 16 for |
- | | | the Targa 16, 24 for the Targa 24, 32 for the Targa 32. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 8 | 10 | Image Specification. |
- | | | |
- | 8 | 2 | X Origin of Image. |
- | | | Integer ( lo-hi ) X coordinate of the lower left corner |
- | | | of the image. |
- | | | |
- | 10 | 2 | Y Origin of Image. |
- | | | Integer ( lo-hi ) Y coordinate of the lower left corner |
- | | | of the image. |
- | | | |
- | 12 | 2 | Width of Image. |
- | | | Integer ( lo-hi ) width of the image in pixels. |
- | | | |
- | 14 | 2 | Height of Image. |
- | | | Integer ( lo-hi ) height of the image in pixels. |
- | | | |
- | 16 | 1 | Image Pixel Size. |
- | | | Number of bits in a pixel. This is 16 for Targa 16, |
- | | | 24 for Targa 24, and .... well, you get the idea. |
- | | | |
- | 17 | 1 | Image Descriptor Byte. |
- | | | Bits 3-0 - number of attribute bits associated with each |
- | | | pixel. For the Targa 16, this would be 0 or |
- | | | 1. For the Targa 24, it should be 0. For the |
- | | | Targa 32, it should be 8. |
- | | | Bit 4 - reserved. Must be set to 0. |
- | | | Bit 5 - screen origin bit. |
- | | | 0 = Origin in lower left-hand corner. |
- | | | 1 = Origin in upper left-hand corner. |
- | | | Must be 0 for Truevision images. |
- | | | Bits 7-6 - Data storage interleaving flag. |
- | | | 00 = non-interleaved. |
- | | | 01 = two-way (even/odd) interleaving. |
- | | | 10 = four way interleaving. |
- | | | 11 = reserved. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | 18 | varies | Image Identification Field. |
- | | | Contains a free-form identification field of the length |
- | | | specified in byte 1 of the image record. It's 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. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | varies | varies | Color map data. |
- | | | |
- | | | If the Color Map Type is 0, this field doesn't exist. |
- | | | Otherwise, just read past it to get to the image. |
- | | | The Color Map Specification, describes the size of each |
- | | | entry, and the number of entries you'll have to skip. |
- | | | Each color map entry is 2, 3, or 4 bytes. |
- | | | |
- |--------|--------|------------------------------------------------------------|
- | varies | varies | Image Data Field. |
- | | | |
- | | | This field specifies (width) x (height) pixels. The |
- | | | RGB color information for the pixels is stored in |
- | | | packets. There are two types of packets: Run-length |
- | | | encoded packets, and raw packets. Both have a 1-byte |
- | | | header, identifying the type of packet and specifying a |
- | | | count, followed by a variable-length body. |
- | | | The high-order bit of the header is "1" for the |
- | | | run length packet, and "0" for the raw packet. |
- | | | |
- | | | For the run-length packet, the header consists of: |
- | | | __________________________________________________ |
- | | | | 1 bit | 7 bit repetition count minus 1. | |
- | | | | ID | Since the maximum value of this | |
- | | | | | field is 127, the largest possible | |
- | | | | | run size would be 128. | |
- | | | |-------|----------------------------------------| |
- | | | | 1 | C C C C C C C | |
- | | | -------------------------------------------------- |
- | | | |
- | | | For the raw packet, the header consists of: |
- | | | __________________________________________________ |
- | | | | 1 bit | 7 bit number of pixels minus 1. | |
- | | | | ID | Since the maximum value of this | |
- | | | | | field is 127, there can never be | |
- | | | | | more than 128 pixels per packet. | |
- | | | |-------|----------------------------------------| |
- | | | | 0 | N N N N N N N | |
- | | | -------------------------------------------------- |
- | | | |
- | | | |
- | | | For the run length packet, the header is followed by |
- | | | a single color value, which is assumed to be repeated |
- | | | the number of times specified in the header. The |
- | | | packet may cross scan lines ( begin on one line and end |
- | | | on the next ). |
- | | | |
- | | | For the raw packet, the header is followed by |
- | | | the number of color values specified in the header. |
- | | | |
- | | | The color entries themselves are two bytes, three bytes, |
- | | | or four bytes ( for Targa 16, 24, and 32 ), and are |
- | | | broken down as follows: |
- | | | |
- | | | The 2 byte entry - |
- | | | 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. |
- | | | |
- | | | The 3 byte entry contains 1 byte each of blue, green, |
- | | | and red. |
- | | | |
- | | | The 4 byte entry contains 1 byte each of blue, green, |
- | | | red, and attribute. For faster speed (because of the |
- | | | hardware of the Targa board itself), Targa 24 image are |
- | | | sometimes stored as Targa 32 images. |
- | | | |
- --------------------------------------------------------------------------------
|