The classic icon image uses the Workbench screen’s few pens. Two later schemes added icons with their own palettes while keeping the classic image for older systems: NewIcons, which hide the colour image in the tool types, and the AmigaOS 3.5 colour icons, which append an IFF form to the file. When both are present, AROS uses the AmigaOS 3.5 image and ignores the NewIcon.
NewIcons
A NewIcon keeps its images as extra tool
types, so any system can copy and store them unchanged. They come after a tool
type that reads exactly *** DON'T EDIT THE FOLLOWING LINES!! ***. Lines
starting IM1= hold the normal image and lines starting
IM2= the selected one, which must be the same size.
The first line of each image
Straight after IM1= or IM2= come five header
characters:
| Character | Meaning |
|---|---|
| 1 | B: colour 0 is transparent; C: no transparency |
| 2 | width + 33 (the character’s code minus 0x21 is the width) |
| 3 | height + 33 |
| 4 and 5 | number of colours: (first − 33) × 64 + (second − 33) |
The rest of that line, continuing on more lines of the same image if needed, is the palette: a red, green and blue byte for each colour. The pixels start on the next new line, one colour number per pixel, row by row from the top, using the fewest bits that can hold the number of colours (1 bit for 2 colours, 2 for 3 or 4, and so on).
Encoding
Every character of the data carries 7 bits:
| Character code | Meaning |
|---|---|
20–9F | the 7-bit value code − 0x20 |
A0–D0 | the 7-bit value code − 0x51 |
D1–FF | a run of (code − 0xD0) 7-bit groups of zeros |
The 7-bit groups are joined into one bit stream, most significant bit first, and the stream is cut into 8-bit palette bytes or into pixels of the image’s bit depth. Bits left over at the end of a line are dropped: each line starts afresh.
For example, a 36 × 20 image with 4 colours and transparency starts
IM1=BE5!%: E is 0x45, 36 + 33;
5 is 0x35, 20 + 33; ! and % give
0 × 64 + 4 colours.
AmigaOS 3.5 colour icons
AmigaOS 3.5 appends an IFF FORM of type ICON after the
classic data, at the end of the file. Like all IFF, its chunks are a four-character
ID, a 32-bit big-endian length and the data, padded to an even length. It holds one
FACE chunk and then one or two IMAG chunks, the normal image
then the selected one.
FACE
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 1 | u8 | width | the image width minus 1 |
| 1 | 1 | u8 | height | the image height minus 1 |
| 2 | 1 | u8 | flags | bit 0: frameless, the icon is drawn without a border |
| 3 | 1 | u8 | aspect | the pixel aspect ratio: horizontal part in the high 4 bits, vertical in the low 4; 0 unknown |
| 4 | 2 | u16 | max palette bytes | the size of the larger of the two palettes, in bytes, minus 1 |
IMAG
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 1 | u8 | transparent colour | the colour number drawn as transparent, if flag bit 0 is set |
| 1 | 1 | u8 | colours | the number of palette entries minus 1 |
| 2 | 1 | u8 | flags | bit 0: has a transparent colour; bit 1: has a palette |
| 3 | 1 | u8 | image format | 0 uncompressed, 1 run-length coded |
| 4 | 1 | u8 | palette format | 0 uncompressed, 1 run-length coded |
| 5 | 1 | u8 | depth | bits per pixel in the coded image, 1 to 8 |
| 6 | 2 | u16 | image bytes | the size of the image data minus 1 |
| 8 | 2 | u16 | palette bytes | the size of the palette data minus 1; meaningful only with a palette |
| 10 | varies | bytes | image data | the pixels |
| … | varies | bytes | palette data | if flag bit 1: red, green and blue bytes for each colour |
Uncompressed image data is one byte per pixel, row by row from the top. A selected image without its own palette uses the normal image’s.
Run-length coding
Coded data is a bit stream read most significant bit first. An 8-bit control value n is followed by values of depth bits for the image, or 8 bits for the palette:
| Control n | Meaning |
|---|---|
| 0 to 127 | the next n + 1 values are taken as they are |
| 128 | no operation |
| 129 to 255 | the next single value is repeated 257 − n times |
This is PackBits applied to values of any bit width rather than whole bytes.
Later extensions
AROS also reads two further chunk types in the same FORM ICON, one or two
of each, for the normal and selected images:
| Chunk | Contents |
|---|---|
ARGB | a 10-byte header (a 32-bit 1, the 32-bit compressed size, a 16-bit 0) and then zlib-compressed pixels, 4 bytes each: alpha, red, green, blue. Alpha 0 is transparent. The size comes from FACE |
png | a complete PNG image; the ID ends in a space |
Some later Amiga-like systems also accept a .info file that is a whole
PNG image with the icon settings in a chunk of its own. That form is not described
here.