Introduction
The OS/2 colour icon is a BMP file with the type code CI that holds two
bitmaps one after the other. The first is the same 1-bit pair of masks as a
black and white icon, which decides where the icon
is transparent. The second is a colour image that gives the colour of the rest.
Colour icons are usually named .ico, which on Windows means a
different format. A file with several sizes is a
bitmap array whose entries are CI
images.
Structure
All the headers come first and the pixels after them. Each of the two file headers
starts with CI and holds the offset of its own bitmap’s pixels. All numbers
are little-endian.
0File headerCI, size, hotspot and the offset of the masks14 bytes14DIB header for the masks: width, double height, 1 bit per pixel, in the 12-byte or OS/2 2.x layout12 to 64 bytes…Colour table for the masks, two entries of 3 or 4 bytes each6 or 8 bytes…Second file headerCIagain, with the offset of the colour image14 bytes…DIB header for the colour image, at the icon’s real height12 to 64 bytes…Colour table for the colour imagevaries…Masks 1-bit rows: first the XOR mask, then the AND maskvaries…Colour image rows, stored like the pixels of a 12-byte or OS/2 2.x bitmapvaries
The file header fields are the same as in a black and
white icon, with the hotspot in the two fields a bitmap reserves. The type code is
the constant BFT_COLORICON, and cbSize is the size of the
header structure, as IBM defines it. The colour image’s DIB header gives its real
height, not twice it.
How the masks and colour combine
IBM’s table for colour icons and pointers gives what each pair of mask bits does with the colour image. Unlike a black and white icon, the XOR mask does not choose between black and white here:
| XOR | AND | Result |
|---|---|---|
1 | 1 | The screen, inverted |
0 | 0 | The colour image’s pixel |
0 | 1 | Transparent: the screen shows through |
1 | 0 | The colour image’s pixel |
The explorer draws the icon this way, with inverted pixels shown in magenta, as they cannot be drawn without a screen behind them.
The two bitmaps are the same size: IBM says the colour bitmap’s cy “must
be the real height”, half the masks’, and its cx equals the masks’. The
explorer reports a colour image of another size, and still draws the icon by scaling
the colour image to the masks.
Telling it apart
The file starts with CI (43 49). After the first DIB header
and its two-entry colour table comes a second file header, also starting with
CI. An OS/2 colour pointer is laid
out the same way and differs only in its type code, CP. A Windows
.ico file starts with 00 00 01 00.
Also used for
- Windows icon – Windows icons and cursors: one picture in several sizes, as bitmaps or PNGs.
Variants
- Windows bitmap (BM) – Windows 3.0 and later: a 40- to 124-byte header
- Windows 2 and OS/2 1.x bitmap (BM) – the first bitmaps, with a 12-byte header
- OS/2 2.x bitmap (BM) – a 16- to 64-byte header, with Huffman 1D and RLE24
- OS/2 bitmap array (BA) – several OS/2 bitmaps, icons or pointers for different screens, chained in one file
- OS/2 icon (IC) – a black and white OS/2 icon: AND and XOR masks in one 1-bit bitmap
- OS/2 colour icon (CI) – a colour OS/2 icon: a 1-bit mask bitmap followed by a colour image
- OS/2 pointer (PT) – a black and white OS/2 mouse pointer, with its hotspot in the header
- OS/2 colour pointer (CP) – a colour OS/2 mouse pointer: masks, a colour image and a hotspot