Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!ut-sally!utah-cs!peterson From: peterson@utah-cs.UUCP (John W Peterson) Newsgroups: net.micro.mac Subject: Re: packbits algo on pain files Message-ID: <3804@utah-cs.UUCP> Date: Tue, 3-Jun-86 00:15:50 EDT Article-I.D.: utah-cs.3804 Posted: Tue Jun 3 00:15:50 1986 Date-Received: Wed, 4-Jun-86 08:09:06 EDT References: <306@gumby.UUCP> <2537@columbia.UUCP> Organization: University of Utah CS Dept Lines: 28 Keywords: packbits algorithm Summary: Macpaint format revealed. Since several have asked, here's the gory details on MacPaint files (This is from an old INFO-MAC posting). ----------------------------------------------------------------------- For those interested, here is a description of the format of MACpaint files. This format is the common interchange format for full-page bitmap images on the MACintosh. The first 512 bytes of the file are the header. The first four bytes comprise the version number, followed by 38*8 = 304 bytes of patterns. The remaining 204 bytes of the header are reserved for future expansion. If the version number is zero, the patterns are ignored. Hence, programs that wish to create files to be read into MACpaint can just write out 512 bytes of zero as the header. Following the header are 720 compressed scanlines of data which form the 576 wide by 720 tall bitmap. The bitmap is compressed as follows ; Any run of three or more equal bytes is compressed into a count byte and a single data byte. Runs of unequal bytes are passed on literally, preceded also by a count byte. I.E. count = -1..-127 --> replicate byte 2..128 times count = 0.. 127 --> copy 1..128 bytes uncompressed count = -128 ignored for backward compatibility That's it. A nice simple scheme. Thanks to Bill Atkinson for providing this info.