ICO (icon image file format)
From Wikipedia, the free encyclopedia
Filename extension | .ico |
---|---|
Internet media type |
|
Uniform Type Identifier | com.microsoft.ico |
Developed by | Microsoft |
Type of format | icon graphics file format |
Filename extension | .cur |
---|---|
Developed by | Microsoft |
Type of format | cursor graphics file format |
The ICO file format is an image file format used for icons in Microsoft Windows. The CUR file format for cursors is almost identical, as the only differences are the identification byte and a specification of a hotspot in the header.
ICO files contain one or more small images at multiple sizes and colour depths.
The official IANA registered MIME type for ico files is image/vnd.microsoft.icon
. Before this was registered, image/x-icon
was the accepted option that complied with the rules of using x- for unregistered tokens. However, many others are seen, including image/ico
, image/icon
, text/ico
, and application/ico
. Many web servers do not come configured with a MIME type setting for .ico files, and may send their default MIME type, which might be text/html
or text/plain
.
Contents |
[edit] Icon sizes, colour depths, and transparency data
Originally 32×32 pixels square and using 16 colors, more recent versions of Microsoft Windows support icons at multiple sizes and color depths. Prior to Windows XP, icon images could be any size from 1×1 pixel up to 255×255 pixels (including non-square sizes), and 4-, 8-, 16-, or 24-bit colour depth. Commonly an icon file would contain both 16x16 and 32x32 (for the start menu and folder "large icons" view) and 16x16 (for window title bars, submenus of the start menu and folder small icons, list and details views).
Icon image data was always made up of two bitmaps: the AND bitmap and the XOR bitmap. The AND bitmap is 1 bit per pixel and is applied first to decide which areas of the image are affected by the background. The XOR bitmap is then applied using XOR. This allows for transparent areas in the image but also allows for inverting the background and other tricks.
Windows XP adds support for 32-bit colour depth icon images, with transparency taken from the alpha channel of the image, allowing semitransparent areas like shadows and antialiased edges. The AND bitmap is not used when displaying 32-bit images in 32-bit mode, however it is still required as Windows XP can and will use a 32-bit image when in 24-bit mode by removing the alpha channel and applying the AND bitmap for transparency if no 24-bit image is available. If the AND bitmap is not included in 32-bit images, when forced to display these in 24-bit mode, the AND map will be assumed in an overflow read, producing an undesirable transparency pattern. Windows XP also adds the ability to display icons at up to 96×96 pixel resolution in the graphical shell; however, Microsoft only recommended icon sizes up to 48×48 pixels, so larger icon sizes are uncommon. Windows XP can read 256×256 pixel icon images and larger and it can resize them to use if no closer image size is available, but it has no native mode for common usage of these sizes.
Windows Vista adds support for natively displaying 256×256 pixel icon images, and supports (but does not require) the compressed PNG format. The PNG format encodes the image transparency data directly; it contains neither the XOR nor the AND bitmap data of the other icon image formats. It is recommended that all 256×256 icons should be stored in the ICO file in PNG format to reduce the overall size of the file. The Windows Vista graphical shell supports "zooming" the display in and out; as a result, more icon formats (including the larger, 256×256 format) are recommended.
ICO files can be edited or exported with a number of graphics programs, among them CorelDraw, IrfanView and Paint.NET (via a plugin).
[edit] Icon library
An icon library is a way to package Windows icons. It is typically a New Executable binary having .ICL extension with icon resources being the packaged icons.
[edit] File structure
All values are represented in little-endian (Intel standard) format.
Icon Header | Stores general information about the ICO file. |
Directory[1..n] | Stores general information about every image in the file. |
Icon #1 | The actual "data" for the first image in old AND/XOR DIB format or newer PNG |
... | |
Icon #n | Data for the last icon image |
[edit] Header
Offset# | Size | Purpose |
---|---|---|
0 | 2 | reserved. should always be 0 |
2 | 2 | type. 1 for icon (.ICO), 2 for cursor (.CUR) file |
4 | 2 | count; number of images in the file |
[edit] Directory
Offset# | Size | Purpose |
---|---|---|
0 | 1 | width, should be 0 if 256 pixels |
1 | 1 | height, should be 0 if 256 pixels |
2 | 1 | colour count, should be 0 if more than 256 colours |
3 | 1 | reserved, should be 0[1] |
4 | 2 | colour planes when in .ICO format, should be 0 or 1[2], or the X hotspot when in .CUR format |
6 | 2 | bits per pixel when in .ICO format[3], or the Y hotspot when in .CUR format |
8 | 4 | size in bytes of the bitmap data |
12 | 4 | offset, bitmap data address in the file |
[edit] Recommended icon sizes for Windows Vista compatibility
The full set of standard icon sizes which should be provided for full Windows Vista compatibility:
- 256×256, 32-bit color, PNG compressed
- 48×48, 32-bit color, uncompressed
- 48×48, 8-bit color, uncompressed
- 48×48, 4-bit color, uncompressed
- 32×32, 32-bit color, uncompressed
- 32×32, 8-bit color, uncompressed
- 32×32, 4-bit color, uncompressed
- 16×16, 32-bit color, uncompressed
- 16×16, 8-bit color, uncompressed
- 16×16, 4-bit color, uncompressed
[edit] References
- ^ Although Microsoft's technical documentation states that this value must be zero, the icon encoder built into .NET (System.Drawing.Icon.Save) sets this value to 255. It appears that the operating system ignores this value altogether.
- ^ Setting the colour planes to 0 or 1 is treated equivalently by the operating system, but if the colour planes are set higher than 1, this value should be multiplied by the bits per pixel to determine the final colour depth of the image. It is unknown if the various Windows operating system versions are resilient to different colour plane values.
- ^ The bits per pixel might be set to zero, but can be inferred from the other data; specifically, if the bitmap is not PNG compressed, then the bits per pixel can be calculated based on the length of the bitmap data relative to the size of the image. If the bitmap is PNG compressed, the bits per pixel are stored within the PNG data. It is unknown if the various Windows operating system versions contain logic to infer the bit depth for all possibilities if this value is set to zero.
[edit] See also
- Windows bitmap, a very similar file format
- (Note that many of the external links in that article are relevant to ICO files as well).
- Apple Icon Image, the icon format used in Mac OS X.
- Favicon, an icon format used for websites
- Icon editor
[edit] External links
- Explanation of the ICO implementation from Microsoft (Does not include Vista additions.)