A MacPaint file starts with a 512-byte header: a version number, the 38 fill patterns of the document, and reserved space. All numbers are big-endian, as on the 68000. The compressed picture starts at offset 512.
Fields
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | LONGINT | Version | the header version: 2 when the patterns are stored, 0 when the document uses the default patterns (below) |
| 4 | 304 | 38 × Pattern | PatArray | the document’s 38 fill patterns, 8 bytes each |
| 308 | 204 | bytes | Future | reserved for future expansion; written as zeros |
| 512 | varies | bytes | bitmap | 720 PackBits-compressed rows; see Bitmap |
The names are those of the MPHeader record in Apple’s Technical Note
PT24. The file has a data fork only; a MacPaint document has no resource fork that
matters, and a reader can ignore one if present.
Version
| Value | Meaning |
|---|---|
| 0 | the document uses MacPaint’s default patterns, and the rest of the header can be ignored |
| 2 | the default value: PatArray holds the document’s own patterns |
PT24 defines only these two values. A program that writes MacPaint files may write 512 zero bytes as the header, and Apple’s own sample code does exactly that. Most readers skip the header entirely, since the patterns only matter to a paint program that will go on editing the picture. Some readers also accept 1 and 3; no published specification gives them a meaning.
Patterns
Each of the 38 patterns is a QuickDraw Pattern: 8 bytes, one per row of
an 8 × 8 tile, top row first. In each byte the most significant bit is the leftmost
pixel, and a 1 bit is black. These are the fill patterns shown in the palette along
the bottom of the MacPaint window, which the user could edit; the document keeps its
own copy so that edited patterns survive.
| Bytes | Pattern |
|---|---|
00 00 00 00 00 00 00 00 | white |
FF FF FF FF FF FF FF FF | black |
AA 55 AA 55 AA 55 AA 55 | 50% grey: a checkerboard of single pixels |
The patterns do not affect the picture: the bitmap already holds every pixel. They are needed only to restore the palette when the document is opened for editing.
MacBinary wrapper
A Mac file keeps its type and creator outside its data, so a MacPaint file copied to another system loses them. To keep them, many files were stored in MacBinary, which puts a 128-byte header in front of the data fork. MacBinary is not part of the MacPaint format, but readers commonly check for it and skip it.
| Offset | Size | Name | Value in a MacPaint file |
|---|---|---|---|
| 0 | 1 | old version | 0 |
| 1 | 1 | name length | 1 to 63 |
| 2 | 63 | file name | the Mac file name |
| 65 | 4 | file type | PNTG |
| 69 | 4 | creator | MPNT for MacPaint itself; other paint programs use their own |
| 83 | 4 | data fork length | the length of the MacPaint data |
| 128 | varies | data fork | the MacPaint file, starting with its 512-byte header |
A reader that finds a zero byte at 0, a name length from 1 to 63 at 1 and
PNTG at 65 should take the MacPaint data from offset 128.
Example
The start of a file that stores its patterns:
| Offset | Bytes | Field | Value |
|---|---|---|---|
| 0 | 00 00 00 02 | Version | 2, patterns stored |
| 4 | FF FF FF FF FF FF FF FF | pattern 1 | black |
| 12 | 8 bytes | pattern 2 | |
| … | patterns 3 to 38 | ||
| 308 | 204 × 00 | Future | reserved |
| 512 | bitmap | the first packed row |
A file written by Apple’s sample code has 512 zero bytes before the bitmap: version 0, default patterns.