RIX.TXT


Remove Frame

Appendix E
RIX image File Format


The RIX philosophy for a file format is to provide a simple
structure that can be easily processed. This structure also results
in a format that can be loaded quickly.

The internal compression algorithm used by RIX is not published
because it is extremely complicated. RIX provides the RIXLATE
utility software as part of the ColoRIX VGA Paint package to expand
and compress files. Although some compression schemes are more
efficient for some pictures, the RIX compression scheme performs
extremely well with a broad range of picture types.


Header Format

RIX image files begin with a 10-byte Intel (low byte first) format
header that identifies the image as described below:


Byte Position     Description
    0 - 3         "RIX"
    4 - 5         Image width in pixels
    6 - 7         Image height in lines
      8           Palette Type
      9           Storage Type


Palette Type

The Palette Type byte indicates the presence of a palette and
its format and length in the form:

M P RGB PIX

where:

     M = 80 if palette table (map) is present,
     P = 40 if packed map entry (e.g., TARGA 16) 5 bits x 3 into
       2 bytes.
     RGB = rgb bits minus 1 (EGA is 2 minus 1, VGA is 6 minus 1).
     PIX = bits per pixel minus 1 (i.e., log number of map
       entries). VGA is 7.

The Palette Type is thus calculated as:

     *   EGA (16/64) = 80 + 40 + 08 + 3 = CB
     *   Extended EGA (16/256K) = 80 + + 28 + 3 = AB
     *   VGA (256/256MK) = 80 + + 28 + 7 = AF
     *   TARGA 16 (256/32K) = 80 + 40 + 20 + 7 = E7
     *   PGA (256/4K) = 80 + + 18 + 7 = 9F

If not a mapped file (i.e., no 80) then remainder is bits per
pixel. For example:

     *   TARGA 16 is 10
     *   TARGA 24 is 18
     *   TARGA 32 is 20


Storage Type

The Storage Type byte indicates how the pixel data are stored. This
value is calculated as follows:

     *   80 = Compressed
     *   40 = Extension block
     *   20 = Encrypted
     *   0 = Linear, one byte per pixel (a la VGA, TGA, PGA)
     *   1 = Planar 0, 2, 1, 3 (a la EGA)
     *   2 = Planar 0, 1, 2, 3 (a la EGA)
     *   3 = Text (char, attr)
     *   4 = Planar lines 0, 1, 2, 3
     *   40 = Extension. Next word is total number of bytes in the
         extension block as described below.

Extension blocks are provided to allow additional information to
be added to the image. This information is optional, so that the
file reader may choose to skip the extension block.


Data Format

The palette is either 48 or 768 bytes long, containing one RGB
triple for each color (16 or 256). The image data is either one
byte per pixel (256 colors) or four fines of one bit per pixel
data.


Extension Format

The extension block comprises one or more extensions. Each
extension is prefaced with a byte of type and a byte of length. The
length is three bytes if first byte is zero. Types 0 through 127
are reserved for RIX applications. A few typical extension formats
are shown below.


     *  00 xx ASCII text for identification field (e.g., creator's
        signature).

     *  01 04 xxx yyy defines original image origin.

     *  02 04 xxx yyy defines original image screen resolution.

     *  03 02 ID (defines encryptor's ID).

     *  04 xx bit map of used palettes where xx is 2 or 32 bytes.

When processing a screen file, the reader should ignore all
unfamiliar extension types. Other applications are free to create
their own extensions, but should use types starting with 128.
Developers may request from RIX an ID less than 12 to avoid
conflict with other developers. RIX welcomes suggestions for now
extensions.