Lou@cup.portal.com (William Joseph Marriott) (08/10/89)
Before a MacPaint file is saved, a call is made to the Mac ROM call PackBits(). The only thing I've found describing this call is that it is a very simple data compression technique; this was from the relevant section in Inside Macintosh. Does anyone know precisely how the bitmapped image is packed? The data is needed so that a "MacPaint" file can be created on a PC-compatible and transmitted to the Mac. APDA lacks the formats and information required, apparently. Any other obvious resources I'm overlooking?
kent@lloyd.camex.uucp (Kent Borg) (08/12/89)
In article <21167@cup.portal.com> Lou@cup.portal.com (William Joseph Marriott) writes: >Does anyone know precisely how the bitmapped image is packed? You want tech note #171. Here is an excerpt: First there is a byte which specifies whether or not the the data is packed, and this byte is also the count byte. It is a negative number if the data is packed (i.e., the high bit is set). If the high bit is set, then that complete byte is a two s complement number that tells you how many bytes were packed. If it is a positive number, then it is simply a zero-based count of how many discrete data bytes exist. Consider the following example: Unpacked data: AA AA AA 80 00 2A AA AA AA AA 80 00 2A 22 AA AA AA AA AA AA AA AA AA AA After being packed by _PackBits: FE AA ; (-(-2)+1) = 3 bytes of the pattern $AA 02 80 00 2A ; (2)+1 = 3 bytes of discrete data FD AA ; (-(-3)+1) = 4 bytes of the pattern $AA 03 80 00 2A 22 ; (3)+1 = 4 bytes of discrete data F7 AA ; (-(-9)+1) = 10 bytes of the pattern $AA or FE AA 02 80 00 2A FD AA 03 80 00 2A 22 F7 AA * * * * * The bytes with the asterisk (*) under them are the count or flag bytes. _PackBits will only pack the data when there are 3 or more consecutive bytes with the same data, otherwise it just copies the data byte for byte (and adds the count byte). Hope that makes some sense for you. Credit to MultiFinder, RAM, the Tech Notes HyperCard stack, and Guillermo Ortiz and Cameron Birse, who wrote the tech note itself. Kent Borg kent@lloyd.uucp or ...!husc6!lloyd!kent