home *** CD-ROM | disk | FTP | other *** search
-
- Tetra Color Palette Format, Version 1.0
- Released to the Public Domain
- Robert M. Crawford
-
- Tetra color palette files contain color dithering data used by DGIF. Two
- types of dither are currently defined; error dispersion and uniform ordered
- dither. The file structure begins with a 16 byte header, followed by the
- dither color table and lastly dither dependent data.
-
- If the dither type is error dispersion, the data is a RGB to dither color
- lookup table.
-
- If the dither type is uniform ordered, tetrahedron partition data follows
- the color table.
-
- The general format is:
-
- Length (bytes) Field
-
- 16 Header
- 3*Number_Colors Color table
- Variable Compressed lookup table or ITETRA data
-
-
- The Header field is described below:
-
- Header
-
- Byte # Length Field
- 0 5 Tetra ID, must be the upper case characters "TETRA".
- 5 1 Major version number, 01h.
- 6 1 Minor version number, 00h.
- 7 1 Largest color index used (Number colors - 1).
- 8 1 Compression. No compression = 0, Delta Row + RLE = 1.
- 9 1 Dither Type, dispresion = 0, uniform = 1.
- 10 2 If dither type 1, NTetra = number of tetrahedrons.
- 12 4 Reserved.
-
-
-
- The Color Table field is described below:
-
- Color Table
-
- Colors are stored with 24 bit precision (one byte pre RGB component). Color
- values are stored in red green blue order, color index zero first. Color
- components are stored as INTENSITY levels NOT DAC voltages (Gamma correct
- before setting graphics hardware).
- Minimum intensity = 00h, Maximum intensity = 0ffh.
-
-
- Example: 0ffh,00h,00h = RED
-
- If the dither type is error dispersion, the following data follows the color
- table:
-
-
- RGB to Dither Color Table
-
- Uncompressed map tables are limited to 64k bytes so RGB values have to be
- quantized. Two formats are used. One for files with 16 or less dither
- colors. The other format is for files with more than 16 dither colors.
-
- Color Bit Position
- 7 6 5 4 3 2 1 0
- RED R7 R6 R5 R4 R3 R2 R1 R0
- GREEN G7 G6 G5 G4 G3 G2 G1 G0
- BLUE B7 B6 B5 B4 B3 B2 B1 B0
-
-
-
- 16-Color Format
-
- Red and green values are quantized to 6 bits. Blue is quantized to 5 bits.
- The three RGB values are combined to form a 16 bit index into a table of
- bytes.
-
-
-
- Table Index Bit Assignments
-
- MSB LSB
- 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
-
- B7 B6 B5 B4 B3 G7 G6 G5 G4 G3 G2 R7 R6 R5 R4 R3
-
- Even values of Red (R2 = 0) are stored in the lower 4 bits of each byte.
- Odd values of Red (R2 = 1) are stored in the upper 4 bits. Delta row and
- RLE data compression is used to reduce table size (uncompressed table size
- is 64k bytes). Each row is 32 bytes.
-
-
-
- 255-Color Format
-
- Red and blue values are quantized to 5 bits. Green is quantized to 6 bits.
- The three RGB values are combined to form a 16 bit index into a table of
- bytes.
-
-
- Table Index Bit Assignments
-
- MSB LSB
- 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
-
- B7 B6 B5 B4 B3 G7 G6 G5 G4 G3 G2 R7 R6 R5 R4 R3
-
-
- Delta row and RLE data compression is used to reduce table size (uncompressed
- table size is 64k bytes). Each row is 32 bytes.
-
-
- If the dither type is uniform ordered, the following data follows the color
- table:
-
- Tetrahedron Partition Data
-
- The tetrahedron data is made up of NTetra (number tetrahedron parameter in
- header) ITETRA data blocks. The ITETRA structure is defined below:
-
- typedef struct
- {
- unsigned int flags;
- unsigned char DIndex[4];
- int V1[3]; /* scaled 6 bits */
- int V2[3];
- int V3[3];
- int V4[3];
- int SinA; /* 1.0 = 0x7fff */
- int CosA;
- int SinB;
- int CosB;
- unsigned int p[4]; /* 1.0 = 0xffff */
- unsigned int next[4];
-
- } ITETRA;
-
- The first data block is tetrahedron #1. The first 12 data blocks define the
- "root" tetrahedrons if there are 16 or less dither colors. If there are more
- than 16 colors, the first 27*12 data blocks define the "root" tetrahedrons.
-
- Each field is described below:
-
- Field Description
-
- flags Number of daughter tetraheadrons.
-
- DIndex[4] Four dither color table index values that
- define the tetrahedron.
-
- V1[3] RGB value of DIndex[0] X 64.
-
- V2[3] RGB value of Dindex[1] - V1 rotated by A and B so
- that V2 is aligned along the red axis and multiplied
- by 64.
-
- V3[3] RGB value of Dindex[2] - V1 and rotated by A and B and
- then multiplied by 64.
-
- V4[3] RGB value of Dindex[3] - V1 and rotated by A and B and
- then multiplied by 64.
-
- SinA A = - ArcTan(V2'[2],V2'[1]), SinA = 0x7fff*sin(A).
- CosA A = - ArcTan(V2'[2],V2'[1]), CosA = 0x7fff*cos(A).
- SinB B = - ArcTan(V2'[1],V2'[0]), SinB = 0x7fff*sin(B).
- CosB B = - ArcTan(V2'[1],V2'[0]), CosB = 0x7fff*Cos(B).
-
- p[4] If flags > 0, the split point defining the daughter
- tetrahedrons. The point is specified as:
-
- split pt = p[0]*V1 + p[1]*V2 + p[2]*V3 + p[3]*V4
- (1.0 = 0xFFFF).
-
- next[4] Pointer to daughter tetrahedrons. The convention
- used is as follows:
-
- next[k] points to a daughter tetrahedron if DIndex[k]
- is not a vertex of the daughter tetrahedron.
-
-
-