Each pixel of an ILBM is a number made of one bit from each bitplane. Usually that
number picks a colour from the CMAP chunk. The
CAMG chunk, the Amiga display mode, can say that the
number means something else: half of another colour in
Extra Half-Brite, or a change to the previous pixel in
hold-and-modify. A deep picture, with 24 or 32
planes, stores each colour directly.
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. It is normally 2nPlanes, but fewer is allowed, and a reader ignores any entries beyond what the planes can reach. When the size is odd a pad byte follows. - Without a
CMAPa reader uses colours of its own. The explorer shows greys. Some write-ups say that an 8-plane picture without a colour map is a greyscale picture. - A file with
nPlanes0 and noBODYholds only a colour map: a palette file.
Scaling old 4-bit values
The original Amiga had 4 bits for each of red, green and blue, and old writers
stored the 4-bit value in the high half of the byte, so 15 became
0xF0. The document now asks writers to repeat the 4 bits, so that 15
is 0xFF, and asks readers to spot the old way: if the low four bits of
every value in the map are zero, the map “was stored shifted rather than scaled”,
and should be scaled.
The explorer does this. When every low half is zero it spreads each value as
v | (v >> 4), so 0xF0 becomes 0xFF and
0x80 becomes 0x88, and shows both the stored and the shown
values.
00000028 43 4D 41 50 00 00 03 00 00 00 00 10 10 10 20 20
00000038 20 35 35 35 45 45 45 55 …
CMAP, 256 colours: colour 0 is black, colour 1 #101010, then #202020, #353535, #454545CAMG, the Amiga display mode
The CAMG chunk holds one ULONG: the Amiga viewport mode the picture was
made for. Its low 16 bits are mode flags, from the Amiga’s
graphics/view.h:
| Bit | Name | Meaning |
|---|---|---|
0x8000 | HIRES | High resolution, 640 pixels wide. |
0x4000 | SPRITES | Sprites are used. |
0x2000 | VP_HIDE | The viewport is hidden. |
0x1000 | EXTENDED_MODE | The value is a whole AmigaOS 2.0 ModeID (see below). |
0x0800 | HAM | Hold-and-modify. |
0x0400 | DUALPF | Dual playfield. |
0x0100 | GENLOCK_AUDIO | Genlock audio. |
0x0080 | EXTRA_HALFBRITE | Extra Half-Brite. |
0x0040 | PFBA | Playfield B in front of A. |
0x0020 | SUPERHIRES | Super-high resolution (AmigaOS 2.0, ECS). |
0x0008 | DOUBLESCAN | Double-scanned. |
0x0004 | LACE | Interlaced, twice the lines. |
0x0002 | GENLOCK_VIDEO | Genlock video. |
ModeIDs
From AmigaOS 2.0, by Commodore’s rules in the document, writers store a whole
32-bit ModeID: a monitor in the upper 16 bits, with EXTENDED_MODE set,
and the mode in the lower 16. The monitor is the value under
MONITOR_ID_MASK, 0xFFFF1000, as in the Amiga’s
graphics/modeid.h:
| Value | Name | Monitor |
|---|---|---|
0x00000000 | DEFAULT_MONITOR_ID | The default: PAL or NTSC, depending on the machine |
0x00011000 | NTSC_MONITOR_ID | NTSC |
0x00021000 | PAL_MONITOR_ID | PAL |
0x00031000 | VGA_MONITOR_ID | VGA (Productivity) |
0x00041000 | A2024_MONITOR_ID | A2024 |
0x00051000 | PROTO_MONITOR_ID | Proto |
0x00061000 | EURO72_MONITOR_ID | Euro72 |
0x00071000 | EURO36_MONITOR_ID | Euro36 |
0x00081000 | SUPER72_MONITOR_ID | Super72 |
0x00091000 | DBLNTSC_MONITOR_ID | DblNTSC |
0x000A1000 | DBLPAL_MONITOR_ID | DblPAL |
A common value is 0x00019004: the NTSC monitor with
HIRES, LACE and EXTENDED_MODE, a 640 × 400
screen.
Old values and bad values
- Writers for AmigaOS 1.3 store a 16-bit value with the upper word zero. They
clear the bits that do not describe the picture:
EXTENDED_MODE,SPRITES,VP_HIDE,GENLOCK_AUDIOandGENLOCK_VIDEO(together0x7102), so the value is masked with0x8EFD. - Readers should mask those bits off only when the upper word is zero. The explorer says so beside such a value.
- Some programs that save brushes put junk in the upper word without setting
EXTENDED_MODE. The document’s code throws such a value away and picksHIRESif the width is 640 or more andLACEif the height is 400 or more; when it keeps an old value, it keeps onlyHIRES,LACE,HAMandEXTRA_HALFBRITE.
The explorer shows the names of the bits that are set, and the monitor when the
upper word is a known ModeID. It reads HAM and Extra Half-Brite from the low word
only when that word can be trusted: when the upper word is not zero and
EXTENDED_MODE is clear, it says the upper word is not a ModeID and, as
the document’s code does, ignores the value and goes by the plane count; and when
the upper word is not one of Commodore’s monitors, the low word may belong to a
graphics card’s mode, so it does not ask for HAM or Extra Half-Brite.
43 41 4D 47 00 00 00 04 50 02 10 00
CAMG written by ASDG’s Art Department Professional: EXTENDED_MODE with the upper word 0x5002, which the explorer does not name; probably a graphics card’s monitor, but that is not confirmedExtra Half-Brite
An Extra Half-Brite picture has 6 planes and the CAMG bit
0x80. The lower five planes pick one of 32 colours from the colour map.
When the top plane, plane 5, is set, the colour is shown at half brightness: colours
32 to 63 are colours 0 to 31 with red, green and blue each shifted right by one bit.
A reader can expand the map to 64 entries that way and then treat the picture as
ordinary 64-colour pixels.
Deluxe Paint added Extra Half-Brite in Deluxe Paint III (1989). The explorer adds the 32 derived colours to the palette it shows, marked as halves of the first 32.
Hold-and-modify
A HAM picture has the CAMG bit 0x800. Each pixel either
picks a colour from the map or keeps two of the previous pixel’s components and
changes the third. This shows far more colours than the planes could pick, with some
fringing at sharp edges.
HAM6
6 planes; 5 are also possible, the sixth then taken as 0. The lower four bits of each pixel are data, and bits 5 and 4, from planes 5 and 4, say what to do with it:
| Bits 5, 4 | Meaning |
|---|---|
00 | The data is a colour number, 0 to 15, from the colour map. |
01 | Keep the previous pixel’s red and green; blue is the data. |
10 | Keep green and blue; red is the data. |
11 | Keep red and blue; green is the data. |
A 4-bit value v becomes v × 17 in 8 bits. The ILBM document
lists the planes in the order 4, 5, and so writes 01 and
10 the other way round; the table follows the hardware, as does
Wikipedia’s article on HAM. “If the first pixel of a scan line is a modification
pixel, it modifies the RGB value of the border color (register 0).”
HAM8
The AGA chips of the Amiga 1200 and 4000 added HAM8: 8 planes (7 are possible), six data bits, and the control bits in the top two planes, 7 and 6. There are 64 base colours. A change replaces the upper six bits of the component and keeps its lower two bits “as set by the most recent set operation”.
Some AGA documentation puts HAM8’s control bits in the two lowest planes. A note on HAM8 at Lysator says that is wrong and that “bpl 7 and bpl 8 are the control bitplanes”, counting from 1; FFmpeg and Netpbm read the top two, and so does the explorer.
Without a CAMG
The ILBM document says a 6-plane picture without a CAMG is “probably
HAM”. The explorer guesses HAM6 for 6 planes and up to 16 colours with no
CAMG, and Extra Half-Brite for 6 planes and exactly 32 colours, and
says that it guessed.
HAM came to Deluxe Paint in Deluxe Paint IV (1991). Deluxe Paint V shows its 24-bit pictures in HAM8.
Deep pictures
A deep picture has no colour map. Each pixel’s colour is stored directly, one bit of it in each plane:
| Planes | Order, plane 0 first |
|---|---|
| 24 | R0 to R7, G0 to G7, B0 to B7: plane 0 is the lowest bit of red, plane 23 the highest bit of blue. |
| 32 | The same, then A0 to A7, the alpha (opacity). |
- A mask plane can follow the 24 planes, with masking 1. Some 24-bit brushes, such as those that came with LightWave 3D, have one.
- The document’s “21-bit NewTek format” stores “R7 G7 B7 R6 G6 B6 R5 G5 B5 R4 G4 B4 R3 G3 B3 R2 G2 B2 R1 G1 B1 R0 G0 B0”. That list has 24 names, though the format is called 21-bit, and the document does not explain the mismatch. The explorer reads 21-plane pictures as the first 21 of those names, R7 to B1, with the lowest bit of each channel left out. It cannot tell a 24-plane NewTek picture from an ordinary 24-plane one, so it reads those in the usual order.
- The unofficial
DCOLchunk gives direct-colour pictures other plane counts, red first; seeDCOL. XBMIcan mark a deep picture as CMYK; seeXBMI.- The explorer paints 24- and 32-plane pictures. It also paints other multiples of 3 above 8 planes in the red, green, blue order, scaled up; that is an assumption.
Transparency
| Masking | What is transparent |
|---|---|
| 1 | Every pixel whose bit in the mask plane is 0. |
| 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 explorer applies all three in its preview. On a hold-and-modify picture a transparent colour applies to set-colour pixels, whose data is a colour number; such a pixel still sets the running colour for the next pixel, as the display hardware would. Deep pictures have no colour numbers, so a transparent colour does nothing for them, but their mask plane is applied.
Palettes that change line by line
Three chunks change the colour registers as the picture is drawn, so one picture
can use more colours than one CMAP holds:
PCHG,
CTBL and
SHAM. The explorer
applies the highest of them, in the order Netpbm uses, to indexed, Extra Half-Brite
and hold-and-modify pictures, and each row gets the colours in force for it.