Introduction
The OS/2 icon is a black and white icon stored as a BMP file with the type code
IC. It holds one 1-bit bitmap twice the icon’s height, made of two masks
one above the other. Together the masks make each pixel black, white, transparent or
the inverse of whatever is behind it.
OS/2 icons are usually named .ico, but they are not the same format as a
Windows icon. An icon file often holds several sizes for
different screens, in which case it is a bitmap
array whose entries are IC or colour
icon images.
Structure
The file has the same parts as a BM bitmap. The DIB header describes a 1-bit image whose height is twice the icon’s height, and the colour table has two entries. All numbers are little-endian.
0File headerIC, size, hotspot and the offset of the pixels14 bytes14DIB header width, double height, 1 bit per pixel12 to 64 bytes…Colour table two entries, black and white6 or 8 bytes…Masks 1-bit rows padded to 4 bytes, the AND mask and the XOR mask one above the othervaries
File header
OS/2 gives the two reserved fields of the bitmap file header a use:
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 2 | char[2] | usType | The signature IC (49 43). |
| 2 | 4 | u32 | cbSize | A size field; readers should not depend on it. |
| 6 | 2 | i16 | xHotspot | The hotspot’s x position. It matters for pointers; icons usually leave it 0. |
| 8 | 2 | i16 | yHotspot | The hotspot’s y position. |
| 10 | 4 | u32 | offBits | The offset from the start of the file to the mask bits. |
How the masks combine
Each pixel of the icon has one bit in the AND mask and one in the XOR mask. When the icon is drawn, the screen is ANDed with the first and then XORed with the second:
| AND | XOR | Result |
|---|---|---|
0 | 0 | Black |
0 | 1 | White |
1 | 0 | Transparent: the screen shows through |
1 | 1 | The screen, inverted |
Telling it apart
The file starts with IC (49 43), and its DIB header gives 1
bit per pixel with a height twice the width. An OS/2
pointer is laid out the same way and differs only in its type code,
PT. A colour icon starts with
CI instead and has a second file header. 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 bitmaps: a header, an optional palette and rows of pixels
- 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