Article View: comp.sys.mac
Article #2849Re: PackBits
From: Kent Borg
Date: Fri, 11 Aug 1989 21:48
Date: Fri, 11 Aug 1989 21:48
45 lines
2049 bytes
2049 bytes
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
Technical Details
Message-ID:
<470@lloyd.camex.uucp>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!ginosko!rex!ukma!husc6!lloyd!kentReferences:
<21167@cup.portal.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ginosko!rex!ukma!husc6!lloyd!kent From: kent@lloyd.camex.uucp (Kent Borg) Newsgroups: comp.sys.mac Subject: Re: PackBits Message-ID: <470@lloyd.camex.uucp> Date: 11 Aug 89 21:48:36 GMT References: <21167@cup.portal.com> Reply-To: kent@lloyd.UUCP (Kent Borg) Organization: Camex, Inc., Boston, Mass USA Lines: 45