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