Mac Paint File Format --------------------- By Bob Denny 75226,3126 In the absence of Inside Mac, I have decoded the MacPaint file format by trial-and-error. Beware! The following info is suspect, though I have successfully printed MacPaint files on our QMS 1200 laser printer, and they look GREAT!! Thanks to Rick Marucci at Discrete-Time Systems in Atlanta for some valuable hints and encouragement. The "picture" is an 8"x10" image, mapped to 576x720 pixels. The file is a compressed bitmap of the picture, with the brush/fill patterns occupying the first block (512 bytes). Pixel information is encoded & compressed a row at a time. So there is at least one "entry" for each of the 720 rows. An "entry" is a block of encoded pixels, and there are two flavors, straight bitmap and run-length encoded patterns. Both types start with a 1-byte count. Pixels are encoded left to right, top to bottom, and within a byte, the most significant bit is the leftmost pixel. "1" means "black" and "0" means "white" on the Mac screen. The picture starts in the second block of the file and is encoded using the abovementioned "entries". In the bitmap flavor, the count indicates the number of pixel bytes which follow, minus one (i.e., count of zero means one pixel byte). For example, a pattern of 0100101011010010 (bin) would be encoded 014AD2 (hex). Count value of 1 means 2 pixel bytes, encoded 4AD2. The second (encoded) flavor is distinguished by its count byte being negative (hi bit set). In this case, the count (after negating it) indicates the number of times that the following 8-bit pattern is to be repeated, minus one. For example a string of 32 one (dark) pixels would be coded as FDFF hex. FD is -3, so there are 3+1=4 bytes of "FF", or "FFFFFFFF". An empty row is encoded B900 (B9 = -71 ... 71+1=72 bytes of 8 light (0) pixels, total 576 pixels). Most important is that the pattern can be any sequence of 8 bits to be repeated, not just all 1's or all 0's. Strings of 16 1's or 0's are not encoded, but are represented as 01FFFF (2 bytes, all 1's) or whatever. The first 4 bytes of the file contain 00000002, which I don't know the meaning of. Starting 4 bytes into the file are 38 blocks of 8 bytes each that are the brush/fill patterns. Each byte is a pattern row, and the bytes map the pattern rows left to right and top to bottom. The patterns appear in the order shown at the bottom of the MacPaint screen top to bottom, left to right. The patterns are not encoded. The remainder of the 1st block is filled with nulls. I recommend that you experiment with MacPaint files and BINHEX V3.0 ... Use BINHEX to convert a few simple pictures to HEX for visual analysis. Start off with a few simple FATBITS patterns of 1, 2, 3, 4 pixels in a row, runs of 16, 24, 32, 48 and 64 pixels, then fool around with more complex patterns of bits to see how MacPaint decides when to encode. Once you get brave, edit the HEX file to change the picture, maybe a brush pattern or two, then convert it back to MacPaint binary and try it. Don't forget to update the BINHEX checksum, or patch out the checksumming code in BINHEX for these experiments. Bob Denny Creative System Designs 234 E. Colorado Blvd Pasadena, CA 91101 (818) 792-9474