[comp.sys.amiga.tech] ILBM & compression

chris@genly.UUCP (Chris Hind Genly) (12/21/90)

I'm trying to write an ILBM file using compression.  I'm using dpaint, ngi,
superview, and diskmaster to try to read the file.  Diskmaster and superview
are never able to read the files I write.  Dpaint and ngi are able to read
the file only if the width, as specified in the BMHD chunk, is an even
multiple of 8.  Dpaint will crash if it is an odd multple.

Without compression dpaint seems to handle arbitrary widths.  Of course I
always write an even number of bytes per row.  With compression, dpaint seems
to require that the width as specified in the BMHD chunk be an even multiple
of eight.  If its an odd multiple, dpaint will crash.  The same with ngi.

So my general question is, what am I doing wrong?

My specific question is:  How many bytes should I compress per row?  Should I
compress just enough bytes to cover the width, which may be odd.  Or should I
always compress an even number of bytes?  I assume I should compress an even
number.

One thing I noticed about dpaint.  If the compressed bitmap contains an odd
number of bytes, dpaint will report the file as mangled.  After all the
compressed data is written out, a pad byte must be written if the file size
is odd.  Not very surprising.  It seems to be a fuzzy part of the ILBM docs. 
The padding could be interpreted as being needed only if there is data which
follows.  Other programs I've tried don't require the last byte of the file
to be padded to make the file size even.

Here is one of the files dpaint doesn't like.  its 120 x 2 pixels, 1 plane,
compressed.  I've compressed an even number of bytes.

type u0.ilbm hex
   
0000: 464F524D 00000058 494C424D 424D4844    FORM...XILBMBMHD
0010: 00000014 00780002 00000000 01000100    .....x..........
0020: 00000A0A 00780002 43414D47 00000004    .....x..CAMG....
0030: 00008000 434D4150 00000006 000000FF    ....CMAP........
0040: FFFF424F 44590000 001601F6 7FFAFF00    ..BODY..........
0050: FEFB0001 0980FA00 0301FFFF E0FE0000    ................

Am I missing something?


As a side note.  I saw a discussion on how nice it is to have the IFF
standard.  I have to agree.  However, while writing code to generate ilbm
files I've noticed a lot of programs aren't very robust.  Many programs I've
tried just crash if you feed them a bad iff file.  Most people wont feed their
programs bad iff file.  But its not a good idea to crash.


       *                        *                        *
                                                            \|/
               *           _______                         --O--
                      ____/ KC1VP \____        *            /|\
 *             ______/  (203) 389-8680 \______
        ______/   Eggplant Software Tools     \________
 ______/  95 Fountain Terr., New Haven, CT, USA, 06515 \_______
/ Chris Hind Genly    chris@genly.uucp   uunet!hsi!genly!chris \
----------------------------------------------------------------