home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / DOCS / PICRES.ZIP / PICRES.TXT
Encoding:
Text File  |  1997-04-16  |  30.3 KB  |  725 lines

  1.  
  2.  
  3.    John Brochu, author of the famed "PicSwitch", sent me a letter
  4.  
  5. and a disk containing modified picture format descriptions for NeoChrome, 
  6.  
  7. DEGAS Elite Compressed, Spectrum 512 Compressed, GEM Bit Image, IFF, 
  8.  
  9. and MacPaint formats.  John also sent a description of the PackBits
  10.  
  11. compression method used in DEGAS Elite, IFF, and MacPaint formats.
  12.  
  13.  
  14.  
  15.    Here's the new version with his corrections.  Many thanks go to
  16.  
  17. John for his contributions, and also to Gerfried Klein who sent
  18.  
  19. the MacPaint description as described by by *pple, corp.
  20.  
  21.  
  22.  
  23. Dave Baggett
  24.  
  25. dmb@wam.umd.edu | dmb@TIS.COM
  26.  
  27.  
  28.  
  29. PS> The "GEM Bit Image" description in previous versions describes an
  30.  
  31.     outdated version of this format which has been replaced by what
  32.  
  33.     is described below.  John believes that the old format was never
  34.  
  35.     actually implemented, so I took the description out.
  36.  
  37.  
  38.  
  39. ----------------------------------- >8 ----------------------------------------
  40.  
  41.  
  42.  
  43.                            ST Picture Formats
  44.  
  45.                            ------------------
  46.  
  47.                                Edited by:
  48.  
  49.  
  50.  
  51.                               David Baggett
  52.  
  53.                          5640 Vantage Point Road
  54.  
  55.                          Columbia, MD  21044 USA
  56.  
  57.                              (301)  596-4779    
  58.  
  59.                           (usenet: dmb@TIS.COM)
  60.  
  61.  
  62.  
  63.                    (Please report errors or additions)
  64.  
  65.  
  66.  
  67.            Copyright (C) 1988, 1989, 1990 by David M. Baggett
  68.  
  69.  
  70.  
  71.  
  72.     Non-profit redistribution of this document is permitted, provided
  73.  
  74.     the document is not modified in any way.
  75.  
  76.  
  77.  
  78.     Reproduction of this document in whole or in part for  commercial
  79.  
  80.     purposes is expressly forbidden without the prior written consent
  81.  
  82.     of David M. Baggett.
  83.  
  84.  
  85.  
  86.     The  information  presented here is not guaranteed to be correct.
  87.  
  88.     The editor and contributors will in no event be liable for direct,
  89.  
  90.     indirect, incidental, or consequential damages resulting from the 
  91.  
  92.     use of the information in this document.
  93.  
  94.  
  95.  
  96.     This document is the product of many hours of volunteer work by a
  97.  
  98.     large number of people. Please respect this -- do not violate the
  99.  
  100.     distribution policy.
  101.  
  102.  
  103.  
  104.  
  105.  
  106.                               CONTRIBUTORS
  107.  
  108.   
  109.  
  110.             Phil Blanchfield  Jason Blochowiak John Brochu**
  111.  
  112.         David Brooks  Neil Forsyth  Stefan Hoehn  Gerfried Klein
  113.  
  114.           Ken MacLeod  Jim McCabe  Darek Mihocka  David Mumper
  115.  
  116.     George Seto Joe Smith  Greg Wageman  Roland Waldi* Gerry Wheeler
  117.  
  118.  
  119.  
  120.  
  121.  
  122.                                 Contents 
  123.  
  124.                                 --------
  125.  
  126.  
  127.  
  128.         NEOchrome                               *.NEO
  129.  
  130.         NEOchrome Animation                     *.ANI
  131.  
  132.         DEGAS                                   *.PI?   ? = 1, 2, 3
  133.  
  134.         DEGAS Elite                             *.PI?   ? = 1, 2, 3
  135.  
  136.         DEGAS Elite (Compressed)                *.PC?   ? = 1, 2, 3
  137.  
  138.         Tiny                                    *.TN?   ? = 1, 2, 3, Y
  139.  
  140.         Spectrum 512                            *.SPU
  141.  
  142.         Spectrum 512 (Compressed)               *.SPC
  143.  
  144.         Art Director                            *.ART
  145.  
  146.         C.O.L.R. Object Editor Mural            *.MUR
  147.  
  148.         Doodle                                  *.DOO
  149.  
  150.         Animatic Film                           *.FLM
  151.  
  152.         GEM Bit Image                           *.IMG
  153.  
  154.         STAD                                    *.PAC
  155.  
  156.         Imagic Film/Picture                     *.IC?   ? = 1, 2, 3
  157.  
  158.         IFF                                     *.IFF
  159.  
  160.         MacPaint                                *.MAC
  161.  
  162.         PackBits Compression Algorithm
  163.  
  164.  
  165.  
  166.  
  167.  
  168.                         Introductory Information
  169.  
  170.                         ------------------------
  171.  
  172. word    = 2 bytes
  173.  
  174. long    = 4 bytes
  175.  
  176. palette = Hardware color palette, stored as 16 words.  First word is
  177.  
  178.           color register zero (background), last word is color register
  179.  
  180.           15.  Each word has the form:
  181.  
  182.  
  183.  
  184.           Bit:  (MSB) 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 (LSB)
  185.  
  186.                       -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  187.  
  188.                        0  0  0  0  0 R2 R1 R0  0 G2 G1 G0  0 B2 B1 B0
  189.  
  190.  
  191.  
  192.           R2 = MSB of red intensity
  193.  
  194.           R0 = LSB of red intensity
  195.  
  196.  
  197.  
  198.           G2 = MSB of green intensity
  199.  
  200.           G0 = LSB of green intensity
  201.  
  202.  
  203.  
  204.           B2 = MSB of blue intensity
  205.  
  206.           B0 = LSB of blue intensity
  207.  
  208.  
  209.           Intensity ranges from 0 (color not present) to 7 (highest
  210.  
  211.           intensity).
  212.  
  213.  
  214.  
  215.           Example: { red = 7, green = 3, blue = 5 } -> 0735 (hex)
  216.  
  217.  
  218.  
  219.           Caveat:  It is wise to mask off the upper four bits of each
  220.  
  221.                    palette entry, since a few programs store special
  222.  
  223.                    information there (most notably Art Studio).
  224.  
  225.  
  226.  
  227.  
  228.  
  229.                              The Formats
  230.  
  231.                              -----------
  232.  
  233.  
  234.  
  235. <NEOchrome>     *.NEO
  236.  
  237.  
  238.  
  239. 1 word          flag byte [always 0]
  240.  
  241. 1 word          resolution [0 = low res, 1 = medium res, 2 = high res]
  242.  
  243. 16 words        palette
  244.  
  245. 12 bytes        filename [usually "        .   "]
  246.  
  247. 1 word          color animation limits.  High bit (bit 15) set if color
  248.  
  249.                 animation data is valid.  Low byte contains color animation
  250.  
  251.                 limits (4 most significant bits are left/lower limit,
  252.  
  253.                 4 least significant bits are right/upper limit).
  254.  
  255. 1 word          color animation speed and direction.  High bit (bit 15) set
  256.  
  257.                 if animation is on.  Low order byte is # vblanks per step.
  258.  
  259.                 If negative, scroll is left (decreasing).  Number of vblanks
  260.  
  261.                 between cycles is |x| - 1
  262.  
  263. 1 word          # of color steps (as defined in previous word) to display
  264.  
  265.                 picture before going to the next.  (For use in slide shows)
  266.  
  267. 1 word          image X offset [unused, always 0]
  268.  
  269. 1 word          image Y offset [unused, always 0]
  270.  
  271. 1 word          image width [unused, always 320]
  272.  
  273. 1 word          image height [unused, always 200]
  274.  
  275. 33 words        reserved for future expansion
  276.  
  277. 16000 words     picture data (screen memory)
  278.  
  279. -----------
  280.  
  281. 32128 bytes     total
  282.  
  283.  
  284.  
  285.  
  286.  
  287. <NEOchrome Animation>        *.ANI
  288.  
  289.  
  290.  
  291. NOTE:      To get this feature on versions 0.9 and later select the Grabber
  292.  
  293.         icon and click both mouse buttons in the eye of the second R in the
  294.  
  295.         word GRABBER.
  296.  
  297.            Interestingly enough, some versions of NEO only require you
  298.  
  299.         to press the right button, not both.  Hmmm...
  300.  
  301.  
  302.  
  303. 1 long          magic number BABEEBEA (hex) (seems to be ignored)
  304.  
  305. 1 word          width of image in bytes (always divisible by 8)
  306.  
  307. 1 word          height of image in scan lines
  308.  
  309. 1 word          size of image in bytes + 10 (!)
  310.  
  311. 1 word          x coordinate of image (must be divisible by 16) - 1
  312.  
  313. 1 word          y coordinate of image - 1
  314.  
  315. 1 word          number of frames
  316.  
  317. 1 word          animation speed (# vblanks to delay between frames)
  318.  
  319. 1 long          reserved; should be zero
  320.  
  321. --------
  322.  
  323. 22 bytes        total for header
  324.  
  325.  
  326.  
  327. ? words         image data (words of screen memory) for each frame, in 
  328.  
  329.                 order
  330.  
  331.  
  332.  
  333.  
  334.  
  335. <DEGAS>         *.PI1 (low resolution)
  336.  
  337.                 *.PI2 (medium resolution)
  338.  
  339.                 *.PI3 (high resolution)
  340.  
  341.  
  342.  
  343. 1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
  344.  
  345.                 Other bits may be used in the future; use a simple bit
  346.  
  347.                 test rather than checking for specific word values.
  348.  
  349. 16 words        palette
  350.  
  351. 16000 words     picture data (screen memory)
  352.  
  353. -----------
  354.  
  355. 32034 bytes     total
  356.  
  357.  
  358.  
  359.  
  360.  
  361. <DEGAS Elite>   *.PI1 (low resolution)
  362.  
  363.                 *.PI2 (medium resolution)
  364.  
  365.                 *.PI3 (high resolution)
  366.  
  367.  
  368.  
  369. 1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
  370.  
  371.                 Other bits may be used in the future; use a simple bit
  372.  
  373.                 test rather than checking for specific word values.
  374.  
  375. 16 words        palette
  376.  
  377. 16000 words     picture data (screen memory)
  378.  
  379. 4 words         left color animtion limit table (starting color numbers)
  380.  
  381. 4 words         right color animation limit table (ending color numbers)
  382.  
  383. 4 words         animation channel direction flag (0 = left, 1 = off, 2 = right)
  384.  
  385. 4 words         128 - animation channel delay in 1/60's of a second. [0 - 128]
  386.  
  387.                 (I.e., subtract word from 128 to get 1/60th's of a second.)
  388.  
  389. -----------
  390.  
  391. 32066 bytes     total
  392.  
  393.  
  394.  
  395.  
  396.  
  397. <DEGAS Elite (Compressed)>      *.PC1 (low resolution)
  398.  
  399.                                 *.PC2 (medium resolution)
  400.  
  401.                                 *.PC3 (high resolution)
  402.  
  403.  
  404.  
  405. 1 word          resolution (same as Degas, but high order bit is set;
  406.  
  407.                 i.e., hex 8000 = low res, hex 8001 = medium res,
  408.  
  409.                 hex 8002 = high res).  Other bits may be used in the
  410.  
  411.                 future; use a simple bit test rather than checking
  412.  
  413.                 for specific word values.
  414.  
  415. 16 words        palette
  416.  
  417. < 32000 bytes   control/data bytes
  418.  
  419. 4 words         left color animation limit table (starting color numbers)
  420.  
  421. 4 words         right color animation limit table (ending color numbers)
  422.  
  423. 4 words         animation channel direction flag [0 = left, 1 = off, 2 = right]
  424.  
  425. 4 words         128 - animation channel delay in 1/60's of a second. [0 - 128]
  426.  
  427.                 (I.e., subtract word from 128 to get 1/60th's of a second.)
  428.  
  429. -----------
  430.  
  431. < 32066 bytes   total
  432.  
  433.  
  434.  
  435. Compression Scheme:
  436.  
  437.  
  438.    PackBits compression is used (see below).  Each scan line is compressed
  439.  
  440. separately; i.e., all data for a given scan line appears before any data
  441.  
  442. for the next scan line.  The scan lines are specified from top to bottom
  443.  
  444. (i.e., 0 is first).  For each scan line, all the data for a given bit plane
  445.  
  446. appears before any data for the next higher order bit plane.  Note this is
  447.  
  448. identical to the IFF 'BODY' image data.
  449.  
  450.    To clarify:  The first data in the file will be the data for the lowest
  451.  
  452. order bit plane of scan line zero, followed by the data for the next higher
  453.  
  454. order bit plane of scan line zero, etc., until all bit planes have been
  455.  
  456. specified for scan line zero.  The next data in the file will be the data
  457.  
  458. for the lowest order bit plane of scan line one, followed by the data for
  459.  
  460. the next higher order bit plane of scan line one, etc., until all bit planes
  461.  
  462. have been specified for all scan lines.
  463.  
  464.  
  465.  
  466. Caveats:
  467.  
  468.  
  469.  
  470.    DEGAS Elite's picture loading routine places some restrictions on
  471.  
  472. compressed DEGAS files:
  473.  
  474.  
  475.  
  476.         o Elite uses a 40-byte buffer to store data being decompressed.
  477.  
  478.  
  479.  
  480.         o Whenever a control command is encountered, bytes are stuffed
  481.  
  482.         in this buffer.
  483.  
  484.  
  485.  
  486.         o The buffer is only emptied when there are EXACTLY 40
  487.  
  488.         characters in it.
  489.  
  490.  
  491.  
  492. The important conclusion here is that
  493.  
  494.  
  495.  
  496.         No control command may cause the buffer to have more than 40
  497.  
  498.         bytes in it.  In other words, all control commands must end on
  499.  
  500.         or before the 40-byte boundary.
  501.  
  502.  
  503.  
  504. Any picture violating the last condition will cause Elite to get a bus
  505.  
  506. error when the picture is loaded.
  507.  
  508.  
  509.  
  510.  
  511.  
  512. <Tiny>  *.TNY (any resolution)
  513.  
  514.         *.TN1 (low resolution)
  515.  
  516.         *.TN2 (medium resolution)
  517.  
  518.         *.TN3 (high resolution)
  519.  
  520.  
  521.  
  522.    Several people have reported sightings of mutated Tiny pictures that
  523.  
  524. do not follow the standard format, so let's be careful out there.  What
  525.  
  526. is described here is the format that David Mumper's original
  527.  
  528. TNYSTUFF.PRG produces.
  529.  
  530.  
  531.  
  532. 1 byte          resolution (same as NEO, but +3 indicates rotation
  533.  
  534.                 information also follows)
  535.  
  536.  
  537.  
  538. If resolution > 2 {
  539.  
  540. 1 byte          left and right color animation limits.  High 4 bits
  541.  
  542.                 hold left (start) limit; low 4 bits hold right (end)
  543.  
  544.                 limit
  545.  
  546. 1 byte          direction and speed of color animation (negative value
  547.  
  548.                 indicates left, positive indicates right, absolute value
  549.  
  550.                 is delay in 1/60's of a second.
  551.  
  552. 1 word          color rotation duration (number of iterations)
  553.  
  554. }
  555.  
  556.  
  557.  
  558. 16 words        palette
  559.  
  560. 1 word          number of control bytes
  561.  
  562. 1 word          number of data words
  563.  
  564. 3-10667 bytes   control bytes
  565.  
  566. 1-16000 words   data words
  567.  
  568. -------------
  569.  
  570. 42-32044 bytes  total
  571.  
  572.  
  573.  
  574. Control byte meanings:
  575.  
  576.  
  577.  
  578.         For a given control byte, x:
  579.  
  580.  
  581.  
  582.         x < 0   Absolute value specifies the number of unique words to
  583.  
  584.                 take from the data section (from 1 to 127)
  585.  
  586.         x = 0   1 word is taken from the control section which specifies
  587.  
  588.                 the number of times to repeat the next data word (from
  589.  
  590.                 128 to 32767)
  591.  
  592.         x = 1   1 word is taken from the control section which specifies
  593.  
  594.                 the number of unique words to be taken from the data
  595.  
  596.                 section (from 128 - 32767)
  597.  
  598.         x > 1   Specifies the number of times to repeat the next word
  599.  
  600.                 taken from the data section (from 2 to 127)
  601.  
  602.  
  603.  
  604. Format of expanded data:
  605.  
  606.  
  607.  
  608.    The expanded data is not simply screen memory bitmap data; instead, the 
  609.  
  610. data is divided into four sets of vertical columns.  (This results in
  611.  
  612. better compression.)  A column consists of one specific word taken
  613.  
  614. from each scan line, going from top to bottom.  For example, column 1 
  615.  
  616. consists of word 1 on scanline 1 followed by word 1 on scanline 2, etc., 
  617.  
  618. followed by word 1 on scanline 200.
  619.  
  620.    The columns appear in the following order:
  621.  
  622.  
  623.  
  624.    1st set contains columns 1, 5,  9, 13, ..., 69, 73, 77 in order
  625.  
  626.    2nd set contains columns 2, 6, 10, 14, ..., 70, 74, 78 in order
  627.  
  628.    3rd set contains columns 3, 7, 11, 15, ..., 71, 75, 79 in order
  629.  
  630.    4th set contains columns 4, 8, 12, 16, ..., 72, 76, 80 in order
  631.  
  632.  
  633.  
  634. Note that Tiny partitions the screen this way regardless of resolution; i.e., 
  635.  
  636. these aren't bitplanes.  For example, medium resoltion only has two bitplanes, 
  637.  
  638. but Tiny still divides medium resolution pictures into four parts.
  639.  
  640.  
  641.  
  642.  
  643.  
  644. <Spectrum 512>  *.SPU
  645.  
  646.  
  647.  
  648. 80 words        first scan line of picture (unused) -- should be zeroes
  649.  
  650. 15920 words     picture data (screen memory) for scan lines 1 through 199
  651.  
  652. 9552 words      3 palettes for each scan line (the top scan line is
  653.  
  654.                 not included because Spectrum 512 can't display it)
  655.  
  656. -----------
  657.  
  658. 51104 bytes     total
  659.  
  660.  
  661.  
  662.  
  663.  
  664. <Spectrum 512 (Compressed)>        *.SPC
  665.  
  666.  
  667. 1 word          flag word [$5350 or "SP"]
  668.  
  669. 1 word          reserved for future use [always 0]
  670.  
  671. 1 long          length of data bit map
  672.  
  673. 1 long          length of color bit map
  674.  
  675. <= 32092 bytes  compressed data bit map
  676.  
  677. <= 17910 bytes  compressed color bit map
  678.  
  679. --------------
  680.  
  681. <= 50014 bytes   total
  682.  
  683.  
  684.  
  685. Data compression:
  686.  
  687.  
  688.  
  689.    Compression is via a modified run length encoding (RLE) scheme,
  690.  
  691. similar to DEGAS compressed and Tiny.  The data map is stored as a
  692.  
  693. sequence of records.  Each record consists of a header byte followed by
  694.  
  695. one or more data bytes.  The meaning of the header byte is as follows:
  696.  
  697.  
  698.  
  699.         For a given header byte, x:
  700.  
  701.  
  702.  
  703.            0 <= x <= 127   Use the next x + 1 bytes literally (no repetition)
  704.  
  705.         -128 <= x <=  -1   Use the next byte -x + 2 times
  706.  
  707.  
  708.  
  709. The data appears in the following order:
  710.  
  711.  
  712.         1. Picture data, bit plane 0, scan lines 1 - 199
  713.  
  714.         2. Picture data, bit plane 1, scan lines 1 - 199
  715.  
  716.         3. Picture data, bit plane 2, scan lines 1 - 199
  717.  
  718.         4. Picture data, bit plane 3, scan lines 1 - 199
  719.  
  720.  
  721.  
  722. Decompression of data ends when 31840 data bytes have been used.
  723.  
  724.  
  725.  
  726. Color map compression:
  727.  
  728.  
  729.  
  730.    Each 16-word palette is compressed separately.  There are three
  731.  
  732. palettes for each scan line (597 total).  The color map is stored as a
  733.  
  734. sequence of records.  Each record starts with a 1-word bit vector which
  735.  
  736. specifies which of the 16 palette entries are included in the data
  737.  
  738. following the bit vector (1 = included, 0 = not included).  If a palette
  739.  
  740. entry is not included, it is assumed to be zero (black).  The least
  741.  
  742. significant bit of the bit vector refers to palette entry zero, while the
  743.  
  744. most significant bit refers to palette entry 15.  Bit 15 must be zero,
  745.  
  746. since Spectrum 512 does not use palette entry 15.  Bit 0 should also be
  747.  
  748. zero, since Spectrum 512 always makes the background color black.
  749.  
  750.    The words specifying the values for the palette entries indicated in
  751.  
  752. the bit vector follow the bit vector itself, in order (0 - 15).
  753.  
  754.  
  755.  
  756.  
  757. <Art Director>  *.ART (low resolution only)
  758.  
  759.  
  760.  
  761. 16000 words     picture data (screen memory)
  762.  
  763. 16 words        palette
  764.  
  765. 15 * 16 words   15 more palettes for animation
  766.  
  767. -------------
  768.  
  769. 32512 bytes     total
  770.  
  771.  
  772.  
  773.  
  774.  
  775. <C.O.L.R. Object Editor Mural>        *.MUR (low resolution only)
  776.  
  777.  
  778.  
  779. 16000 words     picture data (screen memory)
  780.  
  781.                 (palettes are stored in separate files)
  782.  
  783. -----------
  784.  
  785. 32000 bytes     total
  786.  
  787.  
  788.  
  789.  
  790.  
  791. <Doodle>        *.DOO (high resolution only)
  792.  
  793.  
  794.  
  795. 16000 words     picture data (screen memory)
  796.  
  797. -----------
  798.  
  799. 32000 bytes     total
  800.  
  801.  
  802.  
  803.  
  804. <Animatic Film> *.FLM (low resolution only)
  805.  
  806.  
  807.  
  808. 1 word          number of frames
  809.  
  810. 16 words        palette
  811.  
  812. 1 word          speed (0 - 99; value is 99 - # vblanks to delay between frames)
  813.  
  814. 1 word          direction (0 = forwards, 1 = backwards)
  815.  
  816. 1 word          end action (what to do after the last frame)
  817.  
  818.                 0 = pause, then repeat from beginning
  819.  
  820.                 1 = immediately repeat from beginning
  821.  
  822.                 2 = reverse (change direction)
  823.  
  824. 1 word          width of film in pixels
  825.  
  826. 1 word          height of film in pixels
  827.  
  828. 1 word          Animatic version number (major)
  829.  
  830. 1 word          Animatic version number (minor)
  831.  
  832. 1 long          magic number 27182818 (hex)
  833.  
  834. 3 longs         reserved for expansion (should be all zeros)
  835.  
  836. --------
  837.  
  838. 32 words        total for header
  839.  
  840.  
  841.  
  842. ? words         image data (words of screen memory) for each frame, in order
  843.  
  844.  
  845.  
  846.  
  847. <GEM Bit Image> *.IMG
  848.  
  849.  
  850.  
  851. 1 word          version number of image file [1]
  852.  
  853. 1 word          length of header in words [usually 8]
  854.  
  855. 1 word          number of color planes [1 for monochrome]
  856.  
  857. 1 word          pattern length in bytes [1-8, usually 2 for screen images]
  858.  
  859. 1 word          pixel width in microns (1/1000 mm, 25400 microns per inch)
  860.  
  861. 1 word          pixel height in microns
  862.  
  863. 1 word          line width in pixels
  864.  
  865. 1 word          number of lines
  866.  
  867. -------
  868.  
  869. ? words         header length defined in 2nd word of header
  870.  
  871.  
  872.  
  873. ? bytes         data
  874.  
  875.  
  876.  
  877. NOTES:  If the image is a color image (planes > 1), the planes are stored
  878.  
  879. separately starting with plane 0.  There is, however, no standard way of
  880.  
  881. storing the color palette.  Some programs may save the palette in separate
  882.  
  883. files, some may extend the header.  For this reason, you should never
  884.  
  885. assume the header is 8 words long, always get the header length from the
  886.  
  887. 2nd word of the header.  Also, the line width in the 7th word is the number
  888.  
  889. of pixels in a line.  Since the data is encoded in byte-wide packets, the
  890.  
  891. actual unpacked line width is always a multiple of 8, and may be 1-7 pixels
  892.  
  893. longer than the length specified in the header.
  894.  
  895.  
  896.  
  897. For each byte x in the data section,
  898.  
  899.  
  900.  
  901.         x = 0           Pattern/scanline run.
  902.  
  903.                         Read the next byte, n (unsigned).
  904.  
  905.  
  906.  
  907.                         If n > 0 then:
  908.  
  909.                                 Read a number of bytes equal to the "pattern
  910.  
  911.                                 length" word in the header.  Repeat this
  912.  
  913.                                 pattern n times.
  914.  
  915.  
  916.  
  917.                         If n = 0 then:
  918.  
  919.                                 Scanline run.  Data for the next scanline
  920.  
  921.                                 is to be used multiple times.  Read the
  922.  
  923.                                 following record:
  924.  
  925.  
  926.  
  927.                                 1 byte          flag byte [$FF]
  928.  
  929.                                 1 byte          number of times to use
  930.  
  931.                                                 next scanline data
  932.  
  933.  
  934.  
  935.                                 The data for the next scanline follows,
  936.  
  937.  
  938.  
  939.  
  940.         x = 80 (hex)    Uncompressed bit string.  The next byte
  941.  
  942.                         determines the number of bytes to use
  943.  
  944.                         literally.  The literal data bytes follow.
  945.  
  946.  
  947.  
  948.         otherwise       Solid run.  The value of x determines
  949.  
  950.                         what to draw.  The high bit specifies whether
  951.  
  952.                         the pixels are set or cleared.  A 1 indicates
  953.  
  954.                         a byte-run using $FF, a 0 indicates a byte-run
  955.  
  956.                         using $00.  The low 7 bits, taken as an unsigned
  957.  
  958.                         quantity, specify the length of the run in bytes.
  959.  
  960.  
  961.  
  962.  
  963.  
  964. <STAD>          *.PAC (high resolution only)
  965.  
  966.  
  967.  
  968. 4 bytes         "pM86" (vertically packed) or "pM85" (horizontally packed)
  969.  
  970. 1 byte          id byte
  971.  
  972. 1 byte          pack byte (most frequently occuring byte in bitmap)
  973.  
  974. 1 byte          "special" byte
  975.  
  976. -------
  977.  
  978. 7 bytes         total for header
  979.  
  980.  
  981.  
  982. bytes         data
  983.  
  984.  
  985.  
  986. The data is encoded as follows.  For each byte x in the data section:
  987.  
  988.  
  989.  
  990.         x = id byte             Read one more byte, n.  Use pack byte 
  991.  
  992.                                 n + 1 times.
  993.  
  994.         x = "special" byte      Read two more bytes, d, and n (in order).
  995.  
  996.                                 Use byte d n times.
  997.  
  998.         otherwise               Use byte x literally.
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004. <Imagic Film/Picture>           *.IC1 (low resolution)
  1005.  
  1006.                                 *.IC2 (medium resolution)
  1007.  
  1008.                                 *.IC3 (high resolution)
  1009.  
  1010.  
  1011.  
  1012. 4 bytes         "IMDC"
  1013.  
  1014. 1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
  1015.  
  1016. 16 words        palette
  1017.  
  1018. 1 word          date (GEMDOS format)
  1019.  
  1020. 1 word          time (GEMDOS format)
  1021.  
  1022. 8 bytes         name of base picture file (for delta compression), or zeroes
  1023.  
  1024. 1 word          length of data (?)
  1025.  
  1026. 1 long          registration number
  1027.  
  1028. 8 bytes         reserved
  1029.  
  1030. 1 byte          compressed? (0 = no, 1 = yes)
  1031.  
  1032.  
  1033.  
  1034. If compressed {
  1035.  
  1036. 1 byte          delta-compressed? (-1 = no, > -1 = yes)
  1037.  
  1038. 1 byte          ?
  1039.  
  1040. 1 byte          escape byte
  1041.  
  1042. }
  1043.  
  1044. -------
  1045.  
  1046. 65 bytes        total for header (68 bytes if compressed)
  1047.  
  1048.  
  1049.  
  1050. ? bytes         data
  1051.  
  1052.  
  1053.  
  1054.    Compressed data may be either stand-alone or delta-compressed (relative
  1055.  
  1056. to the base picture named in the header).  Delta compression involves
  1057.  
  1058. storing only how the picture differs from the base picture (i.e., only
  1059.  
  1060. portions of the screen that have changed are stored).  This is used to
  1061.  
  1062. to encode animated sequences efficiently.
  1063.  
  1064.  
  1065.  
  1066. Compressed data, stand-alone:
  1067.  
  1068.  
  1069.  
  1070. For each byte x in the data section:
  1071.  
  1072.  
  1073.  
  1074.         x = escape byte         Read one more byte, n.  (n is unsigned).
  1075.  
  1076.  
  1077.  
  1078.                                 If n >= 2, use the next byte n times.
  1079.  
  1080.                                 If n = 1, keep reading bytes until a
  1081.  
  1082.                                 byte k not equal to 1 is encountered.
  1083.  
  1084.                                 Then read the next byte d.
  1085.  
  1086.                                 If the number of 1 bytes encountered is o,
  1087.  
  1088.                                 use d (256 * o + k) times.  I.e.,
  1089.  
  1090.  
  1091.  
  1092.                                 if (n == 1) {
  1093.  
  1094.                                         o = 0;
  1095.  
  1096.                                         while (n == 1) {
  1097.  
  1098.                                                 o++;
  1099.  
  1100.                                                 n = next byte;
  1101.  
  1102.                                         }
  1103.  
  1104.  
  1105.  
  1106.                                         k = n;
  1107.  
  1108.                                         d = next byte;
  1109.  
  1110.  
  1111.  
  1112.                                         Use d (256 * o + k) times.
  1113.  
  1114.                                 }
  1115.  
  1116.                                 else {
  1117.  
  1118.                                         d = next byte;
  1119.  
  1120.                                         Use d (n) times.
  1121.  
  1122.                                 }
  1123.  
  1124.  
  1125.  
  1126.         x != escape byte        Use x literally.
  1127.  
  1128.  
  1129.  
  1130. Compressed data, delta compressed:
  1131.  
  1132.  
  1133.  
  1134. For each byte x in the data section:
  1135.  
  1136.  
  1137.  
  1138.         x = escape byte         Read one more byte, n.  (n is unsigned).
  1139.  
  1140.  
  1141.  
  1142.                                 If n >= 3, use the next byte n times.
  1143.  
  1144.                                 If n = 1, do the same as for n = 1 in
  1145.  
  1146.                                 stand-alone compression (above).
  1147.  
  1148.                                 If n = 2, then set n = next byte.
  1149.  
  1150.                                         If n = 0, end of picture.
  1151.  
  1152.                                         If n >= 2, take n bytes from base
  1153.  
  1154.                                         picture.
  1155.  
  1156.                                         If n = 1, do the same as for n = 1
  1157.  
  1158.                                         in stand-alone compression (above),
  1159.  
  1160.                                         but take (256 * o + k) bytes from 
  1161.  
  1162.                                         base picture.
  1163.  
  1164.  
  1165.  
  1166.         x != escape byte        Use x literally.
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172. <IFF Format>    *.IFF
  1173.  
  1174.  
  1175.  
  1176. 4 bytes         "FORM" (FORM chunk ID)
  1177.  
  1178. 1 long          length of file that follows
  1179.  
  1180. 4 bytes         "ILBM" (InterLeaved BitMap file ID)
  1181.  
  1182.  
  1183.  
  1184. 4 bytes         "BMHD" (BitMap HeaDer chunk ID)
  1185.  
  1186. 1 long          length of chunk [20]
  1187.  
  1188. 20 bytes        1 word = image width in pixels
  1189.  
  1190.                 1 word = image height in lines
  1191.  
  1192.                 1 word = image x-offset [usually 0]
  1193.  
  1194.                 1 word = image y-offset [usually 0]
  1195.  
  1196.                 1 byte = # bitplanes
  1197.  
  1198.                 1 byte = mask (0=no, 1=impl., 2=transparent, 3=lasso)
  1199.  
  1200.                 1 byte = compressed [1] or uncompressed [0]
  1201.  
  1202.                 1 byte = unused [0]
  1203.  
  1204.                 1 word = transparent color (for mask=2)
  1205.  
  1206.                 1 byte = x-aspect [5=640x200, 10=320x200/640x400, 20=320x400]
  1207.  
  1208.                 1 byte = y-aspect [11]
  1209.  
  1210.                 1 word = page width (usually the same as image width)
  1211.  
  1212.                 1 word = page height (usually the same as image height)
  1213.  
  1214.  
  1215.  
  1216. 4 bytes         "CMAP" (ColorMAP chunk ID)
  1217.  
  1218. 1 long          length of chunk [3*n where n is the # colors]
  1219.  
  1220. 3n bytes        3 bytes per RGB color.  Each color value is a byte
  1221.  
  1222.                 and the actual color value is left-justified in the
  1223.  
  1224.                 byte such that the most significant bit of the value
  1225.  
  1226.                 is the MSB of the byte.  (ie. a color value of 15 ($0F)
  1227.  
  1228.                 is stored as $F0)  The bytes are stored in R,G,B order.
  1229.  
  1230.  
  1231.  
  1232. 4 bytes         "CRNG" (Color RaNGe chunk ID)
  1233.  
  1234. 1 long          length of chunk [8]
  1235.  
  1236. 8 bytes         1 word = reserved [0]
  1237.  
  1238.                 1 word = animation speed (16384 = 60 steps per second)
  1239.  
  1240.                 1 word = active [1] or inactive [0]
  1241.  
  1242.                 1 byte = left/lower color animation limit
  1243.  
  1244.                 1 byte = right/upper color animation limit
  1245.  
  1246.  
  1247.  
  1248. 4 bytes         "CAMG" (Commodore AMiGa viewport mode chunk ID)
  1249.  
  1250. 1 long          length of chunk [4]
  1251.  
  1252. 1 long          viewport mode bits (bit 11 = HAM, bit 3 = interlaced)
  1253.  
  1254.  
  1255.  
  1256. 4 bytes         "BODY" (BODY chunk ID)
  1257.  
  1258. 1 long          length of chunk [# bytes of image data that follow]
  1259.  
  1260. ? bytes         actual image data
  1261.  
  1262.  
  1263.  
  1264. NOTES: Some of these chunks may not be present in every IFF file, and may
  1265.  
  1266. not be in this order.  You should always look for the ID bytes to find a
  1267.  
  1268. certain chunk.  All chunk IDs are followed by a long value that tells the
  1269.  
  1270. size of the chunk.  This is the number of bytes that FOLLOW the 4 ID bytes
  1271.  
  1272. and size longword.  The exception to this is the FORM chunk.  The size
  1273.  
  1274. longword that follows the FORM ID is the size of the remainder of the file.
  1275.  
  1276. The FORM chunk must always be the first chunk in an IFF file.
  1277.  
  1278.  
  1279.  
  1280. The R,G,B ranges of AMIGA and ST are different (AMIGA 0...15, ST 0...7),
  1281.  
  1282. as is the maximum number of bitplanes (AMIGA: 5, ST: 4).
  1283.  
  1284.  
  1285.  
  1286. Format of body data
  1287.  
  1288.  
  1289.  
  1290. An expanded picture is simply a bitmap.  The packing method is PackBits
  1291.  
  1292. (see below), and is identical to MacPaint and DEGAS Elite compressed.
  1293.  
  1294.  
  1295.  
  1296. The (decompressed) body data appears in the following order:
  1297.  
  1298.  
  1299.  
  1300.         line 1 plane 0 ... line 1 plane 1 ... ... line 1 plane m
  1301.  
  1302.         [line 1 mask (if appropriate)]
  1303.  
  1304.         line 2 plane 0 ... line 2 plane 1 ... ... line 2 plane m
  1305.  
  1306.         [line 2 mask (if appropriate)]
  1307.  
  1308.         ...
  1309.  
  1310.         line x plane 0 ... line x plane 1 ... ... line x plane m
  1311.  
  1312.         [line x mask (if appropriate)]
  1313.  
  1314.  
  1315.  
  1316. The FORM chunk identifies the type of data:
  1317.  
  1318.  
  1319.  
  1320.         "ILBM" = interleaved bit map
  1321.  
  1322.         "8SVX" = 8-bit sample voice
  1323.  
  1324.         "SMUS" = simple music score
  1325.  
  1326.         "FTXT" = formatted text (Amiga)
  1327.  
  1328.  
  1329.  
  1330.  
  1331.  
  1332. <MacPaint>      *.MAC
  1333.  
  1334.  
  1335.  
  1336. 1 long          version number [0=ignore header, 2=header valid]
  1337.  
  1338. 38 * 8 bytes    8x8 brush/fill patterns.  Each byte is a pattern row,
  1339.  
  1340.                 and the bytes map the pattern rows top to bottom.  The
  1341.  
  1342.                 patterns are stored in the order they appear at the bottom
  1343.  
  1344.                 of the MacPaint screen top to bottom, left to right.
  1345.  
  1346. 204 bytes       unused
  1347.  
  1348. -------------
  1349.  
  1350. 512 bytes       total for header
  1351.  
  1352.  
  1353.  
  1354. < 51200 bytes   compressed bitmap data
  1355.  
  1356. -------------
  1357.  
  1358. < 51712 bytes   total
  1359.  
  1360.  
  1361.  
  1362. NOTE:  The version number is actually a flag to MacPaint to indicate if
  1363.  
  1364. the brush/fill patterns are present in the file.  If the version is 0,
  1365.  
  1366. the default patterns are used.  Therefore you can simply save a MacPaint
  1367.  
  1368. file by writing a blank header (512 $00 bytes), followed by the packed
  1369.  
  1370. image data.
  1371.  
  1372.  
  1373.  
  1374. Bitmap compression:
  1375.  
  1376.  
  1377.  
  1378.    The bitmap data is for a 576 pixel by 720 pixel monochrome image.
  1379.  
  1380. The packing method is PackBits (see below).  There are 72 bytes per
  1381.  
  1382. scan line.  Each bit represents one pixel; 0 = white, 1 = black.
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388. <PackBits Compression Algorithm>
  1389.  
  1390.  
  1391.  
  1392. The following packing algorithm originated on the Mac, was adopted by
  1393.  
  1394. Electronic Arts/Commodore for use in the IFF standard, and then by Tom
  1395.  
  1396. Hudson for use in DEGAS Elite.  The algorithm is currently used in
  1397.  
  1398. MacPaint, IFF, and DEGAS Elite compressed file formats.  Each scan line
  1399.  
  1400. is packed separately, and packing never extends beyond a scan line.
  1401.  
  1402.  
  1403.  
  1404. For a given control byte 'n':
  1405.  
  1406.     0 <= n <= 127   : use the next n + 1 bytes literally (no repetition).
  1407.  
  1408.  -127 <= n <= -1    : use the next byte -n + 1 times.
  1409.  
  1410.          n = -128   : no operation, not used.
  1411.  
  1412.  
  1413.  
  1414. -------------------------------------------------------------------------
  1415.  
  1416.  
  1417.  
  1418. * Roland Waldi contributed extensive information on the following formats:
  1419.  
  1420.  
  1421.  
  1422.         GEM, IMG, Doodle, STAD, Imagic Film/Picture, Art Director, IFF
  1423.  
  1424.  
  1425.  
  1426. ** John Brochu, ST picture formats guru, provided sage advice and many
  1427.  
  1428.    corrections to the following formats:
  1429.  
  1430.  
  1431.  
  1432.         NeoChrome, DEGAS Elite Compressed, Spectrum 512 Compressed,
  1433.  
  1434.         GEM Bit Image, IFF, MacPaint
  1435.  
  1436.  
  1437.  
  1438. Version of Wed May 16 18:02:25 EDT 1990
  1439.  
  1440.