[comp.sys.atari.st] It's Back! A Substantially Revised Picture Formats List

dmb@TIS.COM (David M. Baggett) (10/25/89)

Since there have been some inquiries about picture files, here's the
latest version of "The List".  If you have an old version of this,
I strongly suggest you take this new one.  Major corrections have been
made to:

	NEOchrome (color animation info in header was _completely_ wrong)
	DEGAS compressed (bitplane ordering was wrong)
	Tiny (complete rewrite of compression scheme description)

I have fully tested NEO, DEGAS (all variants), and Tiny, so I'm fairly
sure these are correct now.

Those of you who have been kind enough to upload this list to archives,
please replace the old crusty versions with this one (oh, and THANKS).

	David Baggett
arpa:	dmb@TIS.COM

---------------------------------- >8 -----------------------------------------
                           ST Picture Formats
                           ------------------
                              Compiled by:
                              Dave Baggett
                         (arpanet: dmb@TIS.COM)

                   (Please report errors or additions)

                              CONTRIBUTORS

    Phil Blanchfield   Jason Blochowiak   David Brooks   Neil Forsyth   
         Ken MacLeod   Jim McCabe   Darek Mihocka   David Mumper   
          George Seto   Joe Smith   Greg Wageman  Gerry Wheeler


                                Contents 
                                --------

NEOchrome                       NEOchrome Animation             DEGAS   
DEGAS Elite (Uncompressed)      DEGAS Elite (Compressed)        Tiny
Spectrum 512 (Uncompressed)     C.O.L.R. Object Editor Mural    MacPaint
Spectrum 512 (Compressed)       Animatic Film


                        Introductory Information
                        ------------------------
word    = 2 bytes
long    = 4 bytes
palette = Hardware color palette, stored as 16 words.  First word is
          color register zero (background), last word is color register
          15.  Each word has the form:

          Bit:  (MSB) 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 (LSB)
                      -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
                       0  0  0  0  0 R2 R1 R0  0 G2 G1 G0  0 B2 B1 B0

          R2 = MSB of red intensity
          R0 = LSB of red intensity

          G2 = MSB of green intensity
          G0 = LSB of green intensity

          B2 = MSB of blue intensity
          B0 = LSB of blue intensity

          Intensity ranges from 0 (color not present) to 7 (highest
          intensity).

          Example: { red = 7, green = 3, blue = 5 } -> 0735 (hex)

          Caveat:  It is wise to mask off the upper four bits of each
                   palette entry, since a few programs store special
                   information there (most notably Art Studio).


                             The Formats
                             -----------

<NEOchrome>

1 long          resolution (0 = loew res, 1 = medium res, 2 = high res)
16 words        palette
12 bytes        filename (usually "        .   ")
1 byte          unused (usually either 80 hex or 0)
1 byte          color animation limits (4 most significant bits are 
                left/lower limit; 4 least significant bits are 
                right/upper limit).
1 byte          color animation enabled?  High bit set if yes.
1 byte          color animation speed and direction
                x = 0 means animation stopped
                x < 0 means colors cycle to the left (decreasing)
                x > 0 means colors cycle to the right (ascending)
                Number of vblanks between cycles is |x| - 1
19 longs        reserved for expansion
16000 words     picture data (screen memory)
-----------
32128 bytes     total


<NEOchrome Animation>

NOTE:      To get this feature on versions 0.9 and later select the Grabber
        icon and click the both mouse buttons in the eye of the second R in
        the word GRABBER.
           Interestingly enough, some versions of NEO only require you
        to press the right button, not both.  Hmmm...

1 long          magic number BABEEBEA (hex) (seems to be ignored)
1 word          width of image in bytes (always divisible by 8)
1 word          height of image in scan lines
1 word          size of image in bytes + 10 (!)
1 word          x coordinate of image (must be divisible by 16) - 1
1 word          y coordinate of image - 1
1 word          number of frames
1 word          animation speed (# vblanks to delay between frames)
1 long          reserved; should be zero
--------
22 bytes        total for header

? words         image data (words of screen memory) for each frame, in 
                order


<DEGAS>

1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
                Other bits may be used in the future; use a simple bit
                test rather than checking for specific word values.
16 words        palette
16000 words     picture data (screen memory)
-----------
32034 bytes     total


<DEGAS Elite (Uncompressed)>

1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
                Other bits may be used in the future; use a simple bit
                test rather than checking for specific word values.
16 words        palette
16000 words     picture data (screen memory)
4 words         left color animtion limit table (starting color numbers)
4 words         right color animation limit table (ending color numbers)
4 words         animation channel direction flag (0 = left, 1 = off, 2 = right)
4 words         animation channel delay in 1/60's of a second. [0 - 128]
-----------
32066 bytes     total


<DEGAS Elite (Compressed)>

1 word          resolution (same as Degas, but high order bit is set;
                i.e., hex 8000 = low res, hex 8001 = medium res,
                hex 8002 = high res).  Other bits may be used in the
                future; use a simple bit test rather than checking
                for specific word values.
16 words        palette
< 32000 bytes   control bytes
4 words         left color animtion limit table (starting color numbers)
4 words         right color animation limit table (ending color numbers)
4 words         animation channel direction flag (0 = left, 1 = off, 2 = right)
4 words         animation channel delay in 1/60's of a second. [0 - 128]
-----------
< 32066 bytes   total

Control byte meanings:

        For a given control byte, x:

        0 <= x <= 127   Use the next x + 1 bytes literally (no repetition)
        -127 <= x <= -1 Use the next byte -x + 1 times
        -128            No operation (ignore)

Compression Scheme:

   Each scan line is compressed separately; i.e., all data for a given
scan line appears before any data for the next scan line.  The scan lines
are specified from top to bottom (i.e., 0 is first).  For each scan line,
all the data for a given bit plane appears before any data for the next
higher order bit plane.
   To clarify:  The first data in the file will be the data for the highest
order bit plane of scan line zero, followed by the data for the next lower
order bit plane of scan line zero, etc., until all bit planes have been
specified for scan line zero.  The next data in the file will be the data
for the highest order bit plane of scan line one, followed by the data for
the next lower order bit plane of scan line one, etc., until all bit planes
have been specified for all scan lines.


<C.O.L.R. Object Editor Mural>

16000 words     picture data (screen memory)
                (palettes are stored in separate files)
-----------
32000 bytes     total


<Tiny>

   Several people have reported sightings of mutated Tiny pictures
that do not follow the standard format, so let's be careful out there. 
What is described here is the format David Mumper's original TNYSTUFF.PRG 
produces.

1 byte          resolution (same as NEO, but +3 indicates rotation
                information also follows)

If resolution > 2 {
1 byte          left and right color animation limits.  High 4 bits
                hold left (start) limit; low 4 bits hold right (end)
                limit
1 byte          direction and speed of color animation (negative value
                indicates left, positive indicates right, absolute value
                is delay in 1/60's of a second.
1 word          color rotation duration (number of iterations)
}

16 words        palette
1 word          number of control bytes
1 word          number of data words
3-10667 bytes   control bytes
1-16000 words   data words
-------------
42-32044 bytes  total

Control byte meanings:

        For a given control byte, x:

        x < 0   Absolute value specifies the number of unique words to
                take from the data section (from 1 to 127)
        x = 0   1 word is taken from the control section which specifies
                the number of times to repeat the next data word (from
                128 to 32767)
        x = 1   1 word is taken from the control section which specifies
                the number of unique words to be taken from the data
                section (from 128 - 32767)
        x > 1   Specifies the number of times to repeat the next word
                taken from the data section (from 2 to 127)

Format of expanded data:

   The expanded data is not simply screen memory bitmap data; instead, the 
data is divided into four sets of vertical columns.  (This results in
better compression.)  A column consists of one specific word taken
from each scan line, going from top to bottom.  For example, column 1 
consists of word 1 on scanline 1 followed by word 1 on scanline 2, etc., 
followed by word 1 on scanline 200.
   The columns appear in the following order:

   1st set contains columns 1, 5,  9, 13, ..., 69, 73, 77 in order
   2nd set contains columns 2, 6, 10, 14, ..., 70, 74, 78 in order
   3rd set contains columns 3, 7, 11, 15, ..., 71, 75, 79 in order
   4th set contains columns 4, 8, 12, 16, ..., 72, 76, 80 in order

Note that Tiny partitions the screen this way regardless of resolution; i.e., 
these aren't bitplanes.  For example, medium resoltion only has two bitplanes, 
but Tiny still divides the medium resolution pictures into four parts.


<Spectrum 512 (Uncompressed)>

80 words        first scan line of picture (unused) -- should be zeroes
15920 words     picture data (screen memory) for scan lines 1 through 199
9552 words      3 palettes for each scan line (the top scan line is
                not included because Spectrum 512 can't display it)
-----------
51104 bytes     total


<Spectrum 512 (Compressed)>

1 word          5350 (hex) ("SP")
1 word          0 (reserved for future use)
1 long          length of data bit map
1 long          length of color bit map
<= 32092 bytes  compressed data bit map
<= 17910 bytes  compressed color bit map
--------------
< 50014 bytes   total

Data compression:

   Compression is via a modified run length encoding (RLE) scheme,
similar to DEGAS compressed and Tiny.  The data map is stored as a
sequence of records.  Each record consists of a header byte followed by
one or more data bytes.  The meaning of the header byte is as follows:

        For a given header byte, x:

        0 <= x < 127    Use the next x + 1 bytes literally (no repetition)
        -128 <= x < 0   Use the next byte -x + 2 times

The data appears in the following order:

        1. Picture data, bit plane 0, scan lines 1 - 199
        2. Picture data, bit plane 1, scan lines 1 - 199
        3. Picture data, bit plane 2, scan lines 1 - 199
        4. Picture data, bit plane 3, scan lines 1 - 199

Decompression of data ends when 31840 data bytes have been used.

Color map compression:

   Each 16-word palette is compressed separately.  There are three
palettes for each scan line (597 total).  The color map is stored as a
sequence of records.  Each record starts with a 1-word bit vector which
specifies which of the 16 palette entries are included in the data
following the bit vector (1 = included, 0 = not included; i.e., stays
the same).  The least significant bit of the bit vector refers to
palette entry zero, while the most significant bit refers to palette
entry 15.  Bit 15 must be zero, since Spectrum 512 does not use palette
entry 15.  Bit 0 should also be zero, since Spectrum 512 always makes the
background color black.
   The words specifying the values for the palette entries indicated in
the bit vector follow the bit vector itself, in order (0 - 15).
   Yes, it is hideously complex.


<Animatic Film>

1 word          number of frames
16 words        palette
1 word          speed (0 - 99; value is 99 - # vblanks to delay between frames)
1 word          direction (0 = forwards, 1 = backwards)
1 word          end action (what to do after the last frame)
                0 = pause, then repeat from beginning
                1 = immediately repeat from beginning
                2 = reverse
1 word          width of film in pixels
1 word          height of film in pixels
1 word          Animatic version number (major)
1 word          Animatic version number (minor)
1 long          magic number 27182818 (hex)
3 longs         reserved for expansion (should be all zeros)
--------
32 words        total for header

? words         image data (words of screen memory) for each frame, in order


<MacPaint>

   Word has it that this is wrong.  Someone please send me a correction!

header {
1 long          version number (if zero, entire header is ignored)
38 * 2 longs    pattern data (anyone know how to use this?)
83 longs        reserved
}                            (total 160 longwords for header)
< 51200 bytes   compressed bitmap data
-------------
< 51716 bytes   total

Bitmap compression:

   The bitmap data is for a 576 pixel by 720 pixel monochrome image.
The data is stored as a sequence of records.  Each record consists of a
control byte followed by one or more data bytes.  The meaning of the
control byte is as follows:

        For a given control byte, x:

        0 < x < 127     Use the next x + 1 bytes literally (no repetition)
        -128 <= x <= 0  Use the next byte -x + 1 times

There are 72 bytes per scan line.  Each bit represents one pixel; 0 = white,
1 = black.


Version of Wed Oct 25 00:56:54 EDT 1989