Each pixel of a PBM picture is a byte, a colour number from 0 to 255, and the
CMAP chunk gives the colour for each number. There are no display modes:
the Amiga’s hold-and-modify and Extra Half-Brite need bitplanes, which a PBM does not
have, and no PBM file seen has a CAMG.
CMAP, the colour map
A list of ColorRegister entries, one for each colour number from 0:
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 1 | UBYTE | red | Red, 0 to 255. |
| 1 | 1 | UBYTE | green | Green, 0 to 255. |
| 2 | 1 | UBYTE | blue | Blue, 0 to 255. |
- The number of colours is
ckSize ÷ 3. The files seen hold 256, a 768-byte chunk. Fewer is allowed by the ILBM rules. - Without a
CMAPa reader uses colours of its own; the explorer shows greys. Some write-ups say that a picture without a colour map is a greyscale picture. - The colour map is often the reason for the file: Deluxe Paint’s 1 × 1 pictures hold a full 256-colour map and serve as palettes, as far as can be told from their names and sizes.
The scaling rule
The ILBM document asks readers to check whether every value in the map has its low
four bits zero. If so, the map was written by an old Amiga program that stored 4-bit
values in the high half of each byte, and should be scaled. The explorer applies the
rule to PBM files too: it then spreads each value as v | (v >> 4),
so 0xF0 becomes 0xFF, and shows both the stored and the
shown values. The PC files examined for this site use the whole range of each byte,
so the rule does not change them.
00000028 43 4D 41 50 00 00 03 00 6B 2B 2B 8B 73 83 F3 F3 F3 …
#6B2B2B, colour 1 #8B7383, colour 2 #F3F3F3Transparency
The bitmap header’s masking field says which pixels are transparent:
| Masking | What is transparent |
|---|---|
| 0 | Nothing. |
| 2 | Every pixel of colour transparentColor. |
| 3 (lasso) | Pixels of colour transparentColor that join the edge of the picture through other pixels of that colour; the same colour enclosed by others stays opaque. |
The explorer applies masking 2 and 3 in its preview. Masking 1, a mask plane, has no meaning in a PBM and is ignored.