home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / grfx_snd / picfrmt / picfmts.doc
Text File  |  1990-06-06  |  29KB  |  703 lines

  1.                            ST Picture Formats
  2.                            ------------------
  3.                                Edited by:
  4.  
  5.                               David Baggett
  6.                          5640 Vantage Point Road
  7.                          Columbia, MD  21044 USA
  8.                              (301)  596-4779    
  9.                           (usenet: dmb@TIS.COM)
  10.  
  11.                    (Please report errors or additions)
  12.  
  13.            Copyright (C) 1988, 1989, 1990 by David M. Baggett
  14.  
  15.  
  16.     Non-profit redistribution of this document is permitted, provided
  17.     the document is not modified in any way.
  18.  
  19.     Reproduction of this document in whole or in part for  commercial
  20.     purposes is expressly forbidden without the prior written consent
  21.     of David M. Baggett.
  22.  
  23.     The  information  presented here is not guaranteed to be correct.
  24.     The editor and contributors will in no event be liable for direct,
  25.     indirect, incidental, or consequential damages resulting from the 
  26.     use of the information in this document.
  27.  
  28.     This document is the product of many hours of volunteer work by a
  29.     large number of people. Please respect this -- do not violate the
  30.     distribution policy.
  31.  
  32.  
  33.                               CONTRIBUTORS
  34.   
  35.         Phil Blanchfield  Jason Blochowiak John Brochu**
  36.       David Brooks  Neil Forsyth  Stefan Hoehn Ken MacLeod   
  37.      Jim McCabe  Darek Mihocka    David Mumper  George Seto  
  38.       Joe Smith  Greg Wageman  Roland Waldi* Gerry Wheeler
  39.  
  40.  
  41.                                 Contents 
  42.                                 --------
  43.  
  44.         NEOchrome                               *.NEO
  45.         NEOchrome Animation                     *.ANI
  46.         DEGAS                                   *.PI?   ? = 1, 2, 3
  47.         DEGAS Elite                             *.PI?   ? = 1, 2, 3
  48.         DEGAS Elite (Compressed)                *.PC?   ? = 1, 2, 3
  49.         Tiny                                    *.TN?   ? = 1, 2, 3, Y
  50.         Spectrum 512                            *.SPU
  51.         Spectrum 512 (Compressed)               *.SPC
  52.         Art Director                            *.ART
  53.         C.O.L.R. Object Editor Mural            *.MUR
  54.         Doodle                                  *.DOO
  55.         Animatic Film                           *.FLM
  56.         GEM Bit Image                           *.IMG
  57.         STAD                                    *.PAC
  58.         Imagic Film/Picture                     *.IC?   ? = 1, 2, 3
  59.         IFF                                     *.IFF
  60.         MacPaint                                *.MAC
  61.     PackBits Compression Algorithm
  62.  
  63.  
  64.                         Introductory Information
  65.                         ------------------------
  66. word    = 2 bytes
  67. long    = 4 bytes
  68. palette = Hardware color palette, stored as 16 words.  First word is
  69.           color register zero (background), last word is color register
  70.           15.  Each word has the form:
  71.  
  72.           Bit:  (MSB) 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 (LSB)
  73.                       -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  74.                        0  0  0  0  0 R2 R1 R0  0 G2 G1 G0  0 B2 B1 B0
  75.  
  76.           R2 = MSB of red intensity
  77.           R0 = LSB of red intensity
  78.  
  79.           G2 = MSB of green intensity
  80.           G0 = LSB of green intensity
  81.  
  82.           B2 = MSB of blue intensity
  83.           B0 = LSB of blue intensity
  84.  
  85.           Intensity ranges from 0 (color not present) to 7 (highest
  86.           intensity).
  87.  
  88.           Example: { red = 7, green = 3, blue = 5 } -> 0735 (hex)
  89.  
  90.           Caveat:  It is wise to mask off the upper four bits of each
  91.                    palette entry, since a few programs store special
  92.                    information there (most notably Art Studio).
  93.  
  94.  
  95.                              The Formats
  96.                              -----------
  97.  
  98. <NEOchrome>     *.NEO
  99.  
  100. 1 word          flag byte [always 0]
  101. 1 word          resolution [0 = low res, 1 = medium res, 2 = high res]
  102. 16 words        palette
  103. 12 bytes        filename [usually "        .   "]
  104. 1 word          color animation limits.  High bit (bit 15) set if color
  105.                 animation data is valid.  Low byte contains color animation
  106.                 limits (4 most significant bits are left/lower limit,
  107.                 4 least significant bits are right/upper limit).
  108. 1 word          color animation speed and direction.  High bit (bit 15) set
  109.                 if animation is on.  Low order byte is # vblanks per step.
  110.                 If negative, scroll is left (decreasing).  Number of vblanks
  111.                 between cycles is |x| - 1
  112. 1 word          # of color steps (as defined in previous word) to display
  113.                 picture before going to the next.  (For use in slide shows)
  114. 1 word          image X offset [unused, always 0]
  115. 1 word          image Y offset [unused, always 0]
  116. 1 word          image width [unused, always 320]
  117. 1 word          image height [unused, always 200]
  118. 33 words        reserved for future expansion
  119. 16000 words     picture data (screen memory)
  120. -----------
  121. 32128 bytes     total
  122.  
  123.  
  124. <NEOchrome Animation>        *.ANI
  125.  
  126. NOTE:      To get this feature on versions 0.9 and later select the Grabber
  127.         icon and click both mouse buttons in the eye of the second R in the
  128.         word GRABBER.
  129.            Interestingly enough, some versions of NEO only require you
  130.         to press the right button, not both.  Hmmm...
  131.  
  132. 1 long          magic number BABEEBEA (hex) (seems to be ignored)
  133. 1 word          width of image in bytes (always divisible by 8)
  134. 1 word          height of image in scan lines
  135. 1 word          size of image in bytes + 10 (!)
  136. 1 word          x coordinate of image (must be divisible by 16) - 1
  137. 1 word          y coordinate of image - 1
  138. 1 word          number of frames
  139. 1 word          animation speed (# vblanks to delay between frames)
  140. 1 long          reserved; should be zero
  141. --------
  142. 22 bytes        total for header
  143.  
  144. ? words         image data (words of screen memory) for each frame, in 
  145.                 order
  146.  
  147.  
  148. <DEGAS>         *.PI1 (low resolution)
  149.                 *.PI2 (medium resolution)
  150.                 *.PI3 (high resolution)
  151.  
  152. 1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
  153.                 Other bits may be used in the future; use a simple bit
  154.                 test rather than checking for specific word values.
  155. 16 words        palette
  156. 16000 words     picture data (screen memory)
  157. -----------
  158. 32034 bytes     total
  159.  
  160.  
  161. <DEGAS Elite>   *.PI1 (low resolution)
  162.                 *.PI2 (medium resolution)
  163.                 *.PI3 (high resolution)
  164.  
  165. 1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
  166.                 Other bits may be used in the future; use a simple bit
  167.                 test rather than checking for specific word values.
  168. 16 words        palette
  169. 16000 words     picture data (screen memory)
  170. 4 words         left color animtion limit table (starting color numbers)
  171. 4 words         right color animation limit table (ending color numbers)
  172. 4 words         animation channel direction flag (0 = left, 1 = off, 2 = right)
  173. 4 words         128 - animation channel delay in 1/60's of a second. [0 - 128]
  174.                 (I.e., subtract word from 128 to get 1/60th's of a second.)
  175. -----------
  176. 32066 bytes     total
  177.  
  178.  
  179. <DEGAS Elite (Compressed)>      *.PC1 (low resolution)
  180.                                 *.PC2 (medium resolution)
  181.                                 *.PC3 (high resolution)
  182.  
  183. 1 word          resolution (same as Degas, but high order bit is set;
  184.                 i.e., hex 8000 = low res, hex 8001 = medium res,
  185.                 hex 8002 = high res).  Other bits may be used in the
  186.                 future; use a simple bit test rather than checking
  187.                 for specific word values.
  188. 16 words        palette
  189. < 32000 bytes   control/data bytes
  190. 4 words         left color animation limit table (starting color numbers)
  191. 4 words         right color animation limit table (ending color numbers)
  192. 4 words         animation channel direction flag [0 = left, 1 = off, 2 = right]
  193. 4 words         128 - animation channel delay in 1/60's of a second. [0 - 128]
  194.                 (I.e., subtract word from 128 to get 1/60th's of a second.)
  195. -----------
  196. < 32066 bytes   total
  197.  
  198. Compression Scheme:
  199.  
  200.    PackBits compression is used (see below).  Each scan line is compressed
  201. separately; i.e., all data for a given scan line appears before any data
  202. for the next scan line.  The scan lines are specified from top to bottom
  203. (i.e., 0 is first).  For each scan line, all the data for a given bit plane
  204. appears before any data for the next higher order bit plane.  Note this is
  205. identical to the IFF 'BODY' image data.
  206.    To clarify:  The first data in the file will be the data for the lowest
  207. order bit plane of scan line zero, followed by the data for the next higher
  208. order bit plane of scan line zero, etc., until all bit planes have been
  209. specified for scan line zero.  The next data in the file will be the data
  210. for the lowest order bit plane of scan line one, followed by the data for
  211. the next higher order bit plane of scan line one, etc., until all bit planes
  212. have been specified for all scan lines.
  213.  
  214. Caveats:
  215.  
  216.    DEGAS Elite's picture loading routine places some restrictions on
  217. compressed DEGAS files:
  218.  
  219.         o Elite uses a 40-byte buffer to store data being decompressed.
  220.  
  221.         o Whenever a control command is encountered, bytes are stuffed
  222.         in this buffer.
  223.  
  224.         o The buffer is only emptied when there are EXACTLY 40
  225.         characters in it.
  226.  
  227. The important conclusion here is that
  228.  
  229.         No control command may cause the buffer to have more than 40
  230.         bytes in it.  In other words, all control commands must end on
  231.         or before the 40-byte boundary.
  232.  
  233. Any picture violating the last condition will cause Elite to get a bus
  234. error when the picture is loaded.
  235.  
  236.  
  237. <Tiny>  *.TNY (any resolution)
  238.         *.TN1 (low resolution)
  239.         *.TN2 (medium resolution)
  240.         *.TN3 (high resolution)
  241.  
  242.    Several people have reported sightings of mutated Tiny pictures that
  243. do not follow the standard format, so let's be careful out there.  What
  244. is described here is the format that David Mumper's original
  245. TNYSTUFF.PRG produces.
  246.  
  247. 1 byte          resolution (same as NEO, but +3 indicates rotation
  248.                 information also follows)
  249.  
  250. If resolution > 2 {
  251. 1 byte          left and right color animation limits.  High 4 bits
  252.                 hold left (start) limit; low 4 bits hold right (end)
  253.                 limit
  254. 1 byte          direction and speed of color animation (negative value
  255.                 indicates left, positive indicates right, absolute value
  256.                 is delay in 1/60's of a second.
  257. 1 word          color rotation duration (number of iterations)
  258. }
  259.  
  260. 16 words        palette
  261. 1 word          number of control bytes
  262. 1 word          number of data words
  263. 3-10667 bytes   control bytes
  264. 1-16000 words   data words
  265. -------------
  266. 42-32044 bytes  total
  267.  
  268. Control byte meanings:
  269.  
  270.         For a given control byte, x:
  271.  
  272.         x < 0   Absolute value specifies the number of unique words to
  273.                 take from the data section (from 1 to 127)
  274.         x = 0   1 word is taken from the control section which specifies
  275.                 the number of times to repeat the next data word (from
  276.                 128 to 32767)
  277.         x = 1   1 word is taken from the control section which specifies
  278.                 the number of unique words to be taken from the data
  279.                 section (from 128 - 32767)
  280.         x > 1   Specifies the number of times to repeat the next word
  281.                 taken from the data section (from 2 to 127)
  282.  
  283. Format of expanded data:
  284.  
  285.    The expanded data is not simply screen memory bitmap data; instead, the 
  286. data is divided into four sets of vertical columns.  (This results in
  287. better compression.)  A column consists of one specific word taken
  288. from each scan line, going from top to bottom.  For example, column 1 
  289. consists of word 1 on scanline 1 followed by word 1 on scanline 2, etc., 
  290. followed by word 1 on scanline 200.
  291.    The columns appear in the following order:
  292.  
  293.    1st set contains columns 1, 5,  9, 13, ..., 69, 73, 77 in order
  294.    2nd set contains columns 2, 6, 10, 14, ..., 70, 74, 78 in order
  295.    3rd set contains columns 3, 7, 11, 15, ..., 71, 75, 79 in order
  296.    4th set contains columns 4, 8, 12, 16, ..., 72, 76, 80 in order
  297.  
  298. Note that Tiny partitions the screen this way regardless of resolution; i.e., 
  299. these aren't bitplanes.  For example, medium resoltion only has two bitplanes, 
  300. but Tiny still divides medium resolution pictures into four parts.
  301.  
  302.  
  303. <Spectrum 512>  *.SPU
  304.  
  305. 80 words        first scan line of picture (unused) -- should be zeroes
  306. 15920 words     picture data (screen memory) for scan lines 1 through 199
  307. 9552 words      3 palettes for each scan line (the top scan line is
  308.                 not included because Spectrum 512 can't display it)
  309. -----------
  310. 51104 bytes     total
  311.  
  312.  
  313. <Spectrum 512 (Compressed)>        *.SPC
  314.  
  315. 1 word          flag word [$5350 or "SP"]
  316. 1 word          reserved for future use [always 0]
  317. 1 long          length of data bit map
  318. 1 long          length of color bit map
  319. <= 32092 bytes  compressed data bit map
  320. <= 17910 bytes  compressed color bit map
  321. --------------
  322. <= 50014 bytes   total
  323.  
  324. Data compression:
  325.  
  326.    Compression is via a modified run length encoding (RLE) scheme,
  327. similar to DEGAS compressed and Tiny.  The data map is stored as a
  328. sequence of records.  Each record consists of a header byte followed by
  329. one or more data bytes.  The meaning of the header byte is as follows:
  330.  
  331.         For a given header byte, x:
  332.  
  333.            0 <= x <= 127   Use the next x + 1 bytes literally (no repetition)
  334.         -128 <= x <=  -1   Use the next byte -x + 2 times
  335.  
  336. The data appears in the following order:
  337.  
  338.         1. Picture data, bit plane 0, scan lines 1 - 199
  339.         2. Picture data, bit plane 1, scan lines 1 - 199
  340.         3. Picture data, bit plane 2, scan lines 1 - 199
  341.         4. Picture data, bit plane 3, scan lines 1 - 199
  342.  
  343. Decompression of data ends when 31840 data bytes have been used.
  344.  
  345. Color map compression:
  346.  
  347.    Each 16-word palette is compressed separately.  There are three
  348. palettes for each scan line (597 total).  The color map is stored as a
  349. sequence of records.  Each record starts with a 1-word bit vector which
  350. specifies which of the 16 palette entries are included in the data
  351. following the bit vector (1 = included, 0 = not included).  If a palette
  352. entry is not included, it is assumed to be zero (black).  The least
  353. significant bit of the bit vector refers to palette entry zero, while the
  354. most significant bit refers to palette entry 15.  Bit 15 must be zero,
  355. since Spectrum 512 does not use palette entry 15.  Bit 0 should also be
  356. zero, since Spectrum 512 always makes the background color black.
  357.    The words specifying the values for the palette entries indicated in
  358. the bit vector follow the bit vector itself, in order (0 - 15).
  359.  
  360.  
  361. <Art Director>  *.ART (low resolution only)
  362.  
  363. 16000 words     picture data (screen memory)
  364. 16 words        palette
  365. 15 * 16 words   15 more palettes for animation
  366. -------------
  367. 32512 bytes     total
  368.  
  369.  
  370. <C.O.L.R. Object Editor Mural>        *.MUR (low resolution only)
  371.  
  372. 16000 words     picture data (screen memory)
  373.                 (palettes are stored in separate files)
  374. -----------
  375. 32000 bytes     total
  376.  
  377.  
  378. <Doodle>        *.DOO (high resolution only)
  379.  
  380. 16000 words     picture data (screen memory)
  381. -----------
  382. 32000 bytes     total
  383.  
  384.  
  385. <Animatic Film> *.FLM (low resolution only)
  386.  
  387. 1 word          number of frames
  388. 16 words        palette
  389. 1 word          speed (0 - 99; value is 99 - # vblanks to delay between frames)
  390. 1 word          direction (0 = forwards, 1 = backwards)
  391. 1 word          end action (what to do after the last frame)
  392.                 0 = pause, then repeat from beginning
  393.                 1 = immediately repeat from beginning
  394.                 2 = reverse (change direction)
  395. 1 word          width of film in pixels
  396. 1 word          height of film in pixels
  397. 1 word          Animatic version number (major)
  398. 1 word          Animatic version number (minor)
  399. 1 long          magic number 27182818 (hex)
  400. 3 longs         reserved for expansion (should be all zeros)
  401. --------
  402. 32 words        total for header
  403.  
  404. ? words         image data (words of screen memory) for each frame, in order
  405.  
  406.  
  407. <GEM Bit Image> *.IMG
  408.  
  409. 1 word          version number of image file [1]
  410. 1 word          length of header in words [usually 8]
  411. 1 word          number of color planes [1 for monochrome]
  412. 1 word          pattern length in bytes [1-8, usually 2 for screen images]
  413. 1 word          pixel width in microns (1/1000 mm, 25400 microns per inch)
  414. 1 word          pixel height in microns
  415. 1 word          line width in pixels
  416. 1 word          number of lines
  417. -------
  418. ? words         header length defined in 2nd word of header
  419.  
  420. ? bytes         data
  421.  
  422. NOTES:  If the image is a color image (planes > 1), the planes are stored
  423. separately starting with plane 0.  There is, however, no standard way of
  424. storing the color palette.  Some programs may save the palette in separate
  425. files, some may extend the header.  For this reason, you should never
  426. assume the header is 8 words long, always get the header length from the
  427. 2nd word of the header.  Also, the line width in the 7th word is the number
  428. of pixels in a line.  Since the data is encoded in byte-wide packets, the
  429. actual unpacked line width is always a multiple of 8, and may be 1-7 pixels
  430. longer than the length specified in the header.
  431.  
  432. For each byte x in the data section,
  433.  
  434.         x = 0           Pattern/scanline run.
  435.                         Read the next byte, n (unsigned).
  436.  
  437.                         If n > 0 then:
  438.                                 Read a number of bytes equal to the "pattern
  439.                                 length" word in the header.  Repeat this
  440.                                 pattern n times.
  441.  
  442.                         If n = 0 then:
  443.                                 Scanline run.  Data for the next scanline
  444.                                 is to be used multiple times.  Read the
  445.                                 following record:
  446.  
  447.                                 1 byte          flag byte [$FF]
  448.                                 1 byte          number of times to use
  449.                                                 next scanline data
  450.  
  451.                                 The data for the next scanline follows,
  452.                                 compressed normally.
  453.  
  454.         x = 80 (hex)    Uncompressed bit string.  The next byte
  455.                         determines the number of bytes to use
  456.                         literally.  The literal data bytes follow.
  457.  
  458.         otherwise       Solid run.  The value of x determines
  459.                         what to draw.  The high bit specifies whether
  460.                         the pixels are set or cleared.  A 1 indicates
  461.                         a byte-run using $FF, a 0 indicates a byte-run
  462.                         using $00.  The low 7 bits, taken as an unsigned
  463.                         quantity, specify the length of the run in bytes.
  464.  
  465.  
  466. <STAD>          *.PAC (high resolution only)
  467.  
  468. 4 bytes         "pM86" (vertically packed) or "pM85" (horizontally packed)
  469. 1 byte          id byte
  470. 1 byte          pack byte (most frequently occuring byte in bitmap)
  471. 1 byte          "special" byte
  472. -------
  473. 7 bytes         total for header
  474.  
  475. ? bytes         data
  476.  
  477. The data is encoded as follows.  For each byte x in the data section:
  478.  
  479.         x = id byte             Read one more byte, n.  Use pack byte 
  480.                                 n + 1 times.
  481.         x = "special" byte      Read two more bytes, d, and n (in order).
  482.                                 Use byte d n times.
  483.         otherwise               Use byte x literally.
  484.  
  485.  
  486. <Imagic Film/Picture>           *.IC1 (low resolution)
  487.                                 *.IC2 (medium resolution)
  488.                                 *.IC3 (high resolution)
  489.  
  490. 4 bytes         "IMDC"
  491. 1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
  492. 16 words        palette
  493. 1 word          date (GEMDOS format)
  494. 1 word          time (GEMDOS format)
  495. 8 bytes         name of base picture file (for delta compression), or zeroes
  496. 1 word          length of data (?)
  497. 1 long          registration number
  498. 8 bytes         reserved
  499. 1 byte          compressed? (0 = no, 1 = yes)
  500.  
  501. If compressed {
  502. 1 byte          delta-compressed? (-1 = no, > -1 = yes)
  503. 1 byte          ?
  504. 1 byte          escape byte
  505. }
  506. -------
  507. 65 bytes        total for header (68 bytes if compressed)
  508.  
  509. ? bytes         data
  510.  
  511.    Compressed data may be either stand-alone or delta-compressed (relative
  512. to the base picture named in the header).  Delta compression involves
  513. storing only how the picture differs from the base picture (i.e., only
  514. portions of the screen that have changed are stored).  This is used to
  515. to encode animated sequences efficiently.
  516.  
  517. Compressed data, stand-alone:
  518.  
  519. For each byte x in the data section:
  520.  
  521.         x = escape byte         Read one more byte, n.  (n is unsigned).
  522.  
  523.                                 If n >= 2, use the next byte n times.
  524.                                 If n = 1, keep reading bytes until a
  525.                                 byte k not equal to 1 is encountered.
  526.                                 Then read the next byte d.
  527.                                 If the number of 1 bytes encountered is o,
  528.                                 use d (256 * o + k) times.  I.e.,
  529.  
  530.                                 if (n == 1) {
  531.                                         o = 0;
  532.                                         while (n == 1) {
  533.                                                 o++;
  534.                                                 n = next byte;
  535.                                         }
  536.  
  537.                                         k = n;
  538.                                         d = next byte;
  539.  
  540.                                         Use d (256 * o + k) times.
  541.                                 }
  542.                                 else {
  543.                                         d = next byte;
  544.                                         Use d (n) times.
  545.                                 }
  546.  
  547.         x != escape byte        Use x literally.
  548.  
  549. Compressed data, delta compressed:
  550.  
  551. For each byte x in the data section:
  552.  
  553.         x = escape byte         Read one more byte, n.  (n is unsigned).
  554.  
  555.                                 If n >= 3, use the next byte n times.
  556.                                 If n = 1, do the same as for n = 1 in
  557.                                 stand-alone compression (above).
  558.                                 If n = 2, then set n = next byte.
  559.                                         If n = 0, end of picture.
  560.                                         If n >= 2, take n bytes from base
  561.                                         picture.
  562.                                         If n = 1, do the same as for n = 1
  563.                                         in stand-alone compression (above),
  564.                                         but take (256 * o + k) bytes from 
  565.                                         base picture.
  566.  
  567.         x != escape byte        Use x literally.
  568.  
  569.  
  570. <IFF Format>    *.IFF
  571.  
  572. 4 bytes         "FORM" (FORM chunk ID)
  573. 1 long          length of file that follows
  574. 4 bytes         "ILBM" (InterLeaved BitMap file ID)
  575.  
  576. 4 bytes         "BMHD" (BitMap HeaDer chunk ID)
  577. 1 long          length of chunk [20]
  578. 20 bytes        1 word = image width in pixels
  579.                 1 word = image height in lines
  580.                 1 word = image x-offset [usually 0]
  581.                 1 word = image y-offset [usually 0]
  582.                 1 byte = # bitplanes
  583.                 1 byte = mask (0=no, 1=impl., 2=transparent, 3=lasso)
  584.                 1 byte = compressed [1] or uncompressed [0]
  585.                 1 byte = unused [0]
  586.                 1 word = transparent color (for mask=2)
  587.                 1 byte = x-aspect [5=640x200, 10=320x200/640x400, 20=320x400]
  588.                 1 byte = y-aspect [11]
  589.                 1 word = page width (usually the same as image width)
  590.                 1 word = page height (usually the same as image height)
  591.  
  592. 4 bytes         "CMAP" (ColorMAP chunk ID)
  593. 1 long          length of chunk [3*n where n is the # colors]
  594. 3n bytes        3 bytes per RGB color.  Each color value is a byte
  595.                 and the actual color value is left-justified in the
  596.                 byte such that the most significant bit of the value
  597.                 is the MSB of the byte.  (ie. a color value of 15 ($0F)
  598.                 is stored as $F0)  The bytes are stored in R,G,B order.
  599.  
  600. 4 bytes         "CRNG" (Color RaNGe chunk ID)
  601. 1 long          length of chunk [8]
  602. 8 bytes         1 word = reserved [0]
  603.                 1 word = animation speed (16384 = 60 steps per second)
  604.                 1 word = active [1] or inactive [0]
  605.                 1 byte = left/lower color animation limit
  606.                 1 byte = right/upper color animation limit
  607.  
  608. 4 bytes         "CAMG" (Commodore AMiGa viewport mode chunk ID)
  609. 1 long          length of chunk [4]
  610. 1 long          viewport mode bits (bit 11 = HAM, bit 3 = interlaced)
  611.  
  612. 4 bytes         "BODY" (BODY chunk ID)
  613. 1 long          length of chunk [# bytes of image data that follow]
  614. ? bytes         actual image data
  615.  
  616. NOTES: Some of these chunks may not be present in every IFF file, and may
  617. not be in this order.  You should always look for the ID bytes to find a
  618. certain chunk.  All chunk IDs are followed by a long value that tells the
  619. size of the chunk.  This is the number of bytes that FOLLOW the 4 ID bytes
  620. and size longword.  The exception to this is the FORM chunk.  The size
  621. longword that follows the FORM ID is the size of the remainder of the file.
  622. The FORM chunk must always be the first chunk in an IFF file.
  623.  
  624. The R,G,B ranges of AMIGA and ST are different (AMIGA 0...15, ST 0...7),
  625. as is the maximum number of bitplanes (AMIGA: 5, ST: 4).
  626.  
  627. Format of body data
  628.  
  629. An expanded picture is simply a bitmap.  The packing method is PackBits
  630. (see below), and is identical to MacPaint and DEGAS Elite compressed.
  631.  
  632. The (decompressed) body data appears in the following order:
  633.  
  634.         line 1 plane 0 ... line 1 plane 1 ... ... line 1 plane m
  635.         [line 1 mask (if appropriate)]
  636.         line 2 plane 0 ... line 2 plane 1 ... ... line 2 plane m
  637.         [line 2 mask (if appropriate)]
  638.         ...
  639.         line x plane 0 ... line x plane 1 ... ... line x plane m
  640.         [line x mask (if appropriate)]
  641.  
  642. The FORM chunk identifies the type of data:
  643.  
  644.         "ILBM" = interleaved bit map
  645.         "8SVX" = 8-bit sample voice
  646.         "SMUS" = simple music score
  647.         "FTXT" = formatted text (Amiga)
  648.  
  649.  
  650. <MacPaint>      *.MAC
  651.  
  652. 1 long          version number [0=ignore header, 2=header valid]
  653. 38 * 8 bytes    8x8 brush/fill patterns.  Each byte is a pattern row,
  654.                 and the bytes map the pattern rows top to bottom.  The
  655.                 patterns are stored in the order they appear at the bottom
  656.                 of the MacPaint screen top to bottom, left to right.
  657. 204 bytes       unused
  658. -------------
  659. 512 bytes       total for header
  660. < 51200 bytes   compressed bitmap data
  661. -------------
  662. < 51712 bytes   total
  663.  
  664. NOTE:  The version number is actually a flag to MacPaint to indicate if
  665. the brush/fill patterns are present in the file.  If the version is 0,
  666. the default patterns are used.  Therefore you can simply save a MacPaint
  667. file by writing a blank header (512 $00 bytes), followed by the packed
  668. image data.
  669.  
  670. Bitmap compression:
  671.  
  672.    The bitmap data is for a 576 pixel by 720 pixel monochrome image.
  673. The packing method is PackBits (see below).  There are 72 bytes per
  674. scan line.  Each bit represents one pixel; 0 = white, 1 = black.
  675.  
  676.  
  677. <PackBits Compression Algorithm>
  678.  
  679. The following packing algorithm originated on the Mac, was adopted by
  680. Electronic Arts/Commodore for use in the IFF standard, and then by Tom
  681. Hudson for use in DEGAS Elite.  The algorithm is currently used in
  682. MacPaint, IFF, and DEGAS Elite compressed file formats.  Each scan line
  683. is packed separately, and packing never extends beyond a scan line.
  684.  
  685. For a given control byte 'n':
  686.     0 <= n <= 127   : use the next n + 1 bytes literally (no repetition).
  687.  -127 <= n <= -1    : use the next byte -n + 1 times.
  688.          n = -128   : no operation, not used.
  689.  
  690. -------------------------------------------------------------------------
  691.  
  692. * Roland Waldi contributed extensive information on the following formats:
  693.  
  694.         GEM, IMG, Doodle, STAD, Imagic Film/Picture, Art Director, IFF
  695.  
  696. ** John Brochu, ST picture formats guru, provided sage advice and many
  697.    corrections to the following formats:
  698.  
  699.     NeoChrome, DEGAS Elite Compressed, Spectrum 512 Compressed,
  700.     GEM Bit Image, IFF, MacPaint
  701.  
  702. Version of Mon Apr  9 00:24:07 EDT 1990
  703.