Introduction
ICO is the icon format of Microsoft
Windows. One file holds the same picture at several sizes and colour depths, such as
16, 32, 48 and 256 pixels square, and Windows picks the best match for where the icon is
shown. Web sites use it for favicon.ico, the small icon in a browser
tab.
Mouse cursors use the same layout with the extension .cur; their
directory entries give the hotspot, the point that clicks. Since Windows Vista, each image
in the file can be a complete PNG as well as the older bitmap form.
Structure
An ICO file starts with a 6-byte header: two zero bytes, the type (1 for an icon, 2 for a cursor) and the number of images, all little-endian. A 16-byte directory entry for each image follows, giving its width and height (0 meaning 256), colour count, planes and bit count (or the hotspot in a cursor), its size in bytes and its offset in the file.
Each image is either a PNG file or a device independent bitmap like those in BMP files, starting at the BITMAPINFOHEADER with no file header. In the bitmap form the stated height is doubled, because the colour pixels are followed by a 1-bit transparency mask of the same size.
0Header reserved, type, image count6 bytes6Directory one entry per image: size, colours, bytes, offset16 bytes each…Images each a PNG, or a bitmap with its AND maskvaries
Also used for
- OS/2 bitmap array (BA) .ico
- OS/2 colour icon (CI) .ico
- OS/2 icon (IC) .ico
Links
Software
Developers
- Pillow, Python imaging library that reads and writes ICO