Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!samsung!usc!ucsd!tut.cis.ohio-state.edu!n8emr!cmhgate!p3.f200.n226.z1.FIDONET.ORG!Michael.Burton From: Michael.Burton@p3.f200.n226.z1.FIDONET.ORG (Michael Burton) Newsgroups: comp.sys.mac.programmer Subject: RE: PackBits/UnpackBits Format Message-ID: <56063.2670FB02@cmhgate.FIDONET.ORG> Date: 8 Jun 90 02:03:50 GMT Sender: ufgate@cmhgate.FIDONET.ORG (newsout1.26) Organization: FidoNet node 1:226/200.3 - Aurora Borealis, Gahanna Oh Lines: 51 Robert Morgan asked: > Does anyone know what format PackBits/UnpackBits uses ? > Inside Mac vI-p470 is no help at all. > ... > I have to write such a routine on a non-macintosh (in order to > unpack/pack bitmaps/PixMaps in PICT files). Quoting from Tech Note #171: PackBits Data Format: First there is a byte which specifies whether or not the the data is packed, and is also the count byte. It is a negative number if packed (i.e. the high bit is set). If the high bit is set, then that complete byte is a twos 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 there are. 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 * under them are the count/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). END QUOTE. You should also note this caveat from the Tech Note: > WARNING! This information is provided for informational purposes only! > It is accurate for now, but may change in the future. -- Michael Burton via cmhGate - Net 226 fido<=>uucp gateway Col, OH UUCP: ...!osu-cis!n8emr!cmhgate!200.3!Michael.Burton INET: Michael.Burton@p3.f200.n226.z1.FIDONET.ORG