File types:
- HFS 'PNTG', often with creator 'MPNT'
Primary references:
- Macintosh Technical Note PT 24, "MacPaint Document Format" (revised June 1989), http://www.idea2ic.com/File_Formats/macpaint.pdf
- Technical Note TN1023, "Understanding PackBits", http://web.archive.org/web/20080705155158/http://developer.apple.com/technotes/tn/tn1023.html
- PackBits wikipedia page: https://en.wikipedia.org/wiki/PackBits
MacPaint is a raster graphics editor developed by Apple Computer for the original Macintosh. The documents it creates are 576x720 monochrome bitmaps; at 72dpi, this matches the 8x10 inch area of a standard ImageWriter printer page. (The resolution of the original Macintosh was 512x342, so the bitmap was larger than the screen in both directions.)
To reduce disk space, the bitmap is compressed with a simple run-length encoding algorithm implemented by the built-in "PackBits" function.
On HFS filesystems, these documents used the file type 'PNTG'. On other systems, the filename extension ".pntg" or simply ".mac" were sometimes used. Images uploaded to online services were often prefixed with a MacBinary header. Without one of these, it's very difficult to identify a MacPaint document as such, except by attempting to fully decode it.
The source code for MacPaint is available from the Computer History Museum.
The file format is:
+$000 / 4: big-endian version number (0 or 2)
+$004 /304: for version=2, 38 sets of 8-byte patterns; otherwise junk
+$134 /204: reserved
+$200 /nnn: bitmap data
Files with version zero use default patterns, so the pattern section should be ignored.
The bitmap data consists of 720 rows, each of which is compressed in isolation with PackBits. The leftmost pixel corresponds to the high bit in a byte. A '1' bit indicates a black pixel.
The PackBits function compressed data using a byte-oriented form of run-length encoding.
The compressed data has a "flag-counter" byte, followed by one or more data bytes, and then the next flag-counter byte. The flag-counter byte is taken as a signed value:
- -128: not generated by ROM, should be ignored except for application-specific uses
- N < 0: repeat the next byte (1 - N) times
- N >= 0: copy the next (1 + N) bytes verbatim