ICO (file format)
From Wikipedia, the free encyclopedia
This article needs additional citations for verification. Please help improve this article by adding reliable references. Unsourced material may be challenged and removed. (November 2009) |
Filename extension | .ico |
---|---|
Internet media type | image/vnd.microsoft.icon |
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 |
ICO file format is an image file format for icons in Microsoft Windows. .ICO files contain one or more small images at multiple sizes and color depths.
CUR file format is an almost identical image file format for non-animated cursors in Microsoft Windows. The only differences between these two file formats are their identification bytes and the specification of a hotspot in the cursor file's header.
Contents[hide] |
[edit] MIME type
The official IANA-registered MIME type for .ICO files is image/vnd.microsoft.icon. Erroneous labels “image/ico”, “image/icon”, “text/ico”, “application/ico” and “image/x-icon” were in use at the time of official registration and assignment of the MIME type.[1]
[edit] Icon size, transparency and color depths
Icons introduced in Windows 1.0 were 32×32 pixels in size and had 16 colors.[2] Support for 256 colors was introduced in Windows 3.0.[3]
Win32 introduced support for storing icon images of up to 16.7 million colors (Truecolor) and up to 256x256 pixels in dimensions.[4] Windows 95 also introduced a new Device Independent Bitmap (DIB) engine.[5] However, 256 color was the default icon color depth in Windows 95. It was possible to enable 65535 color (Highcolor) icons by either modifying the Shell Icon BPP value in the registry[4] [6] or by installing the Microsoft Plus! pack for Windows 95. The Shell Icon Size value allows using larger icons in place of 32×32 icons and the Shell Small Icon Size value allows using custom sizes in place of 16×16 icons. [4] Thus, even prior to Windows XP, a single icon file could store images of any size from 1×1 pixel up to 256×256 pixels (including non-square sizes) with 16, 256, 65535, or 16.7 million colors; but the shell could not display very large sized icons. The notification area of the Windows taskbar was limited to 16 color icons by default until Windows Me when it was updated to support high color icons.
Windows XP adds support for 32-bit color (16.7 million colors plus alpha channel transparency) icon images, thus allowing semitransparent areas like shadows, anti-aliasing or glass-like shapes to be drawn in an icon.
Windows XP, by default, employs 48×48 pixel icons in Windows Explorer. Windows XP can be forced to use icons as large as 256×256 by modifying the Shell icon size value but this would cause all 32×32 sized icons throughout the shell to be upsized.[4] Microsoft only recommended icon sizes up to 48×48 pixels for Windows XP.[7] 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[citation needed].
Windows Vista adds support for displaying 256×256 pixel icon images as a separate view in Windows Explorer, and supports (but does not require) the compressed PNG format. Microsoft recommends that all 256×256 icons in the .ICO files should be stored in PNG format to reduce the overall size of the file.[8] The Windows Vista Explorer supports smoothly scaling icons to non-standard sizes which are rendered on the fly even if an image is not present for that size in the icon file. The Windows Vista shell adds a slider for "zooming" the icon sizes in and out. With users using higher resolutions and high DPI modes, larger icon formats (such as 256×256) are recommended.[8]
[edit] Icon resource structure
[edit] Legacy format
![]() |
This article may be confusing or unclear to readers. Please help clarify the article; suggestions may be found on the talk page. (November 2009) |
Icon image data for 4-bit and 8-bit icons is made up of a BitmapInfoHeader, a RGB color palette made up of RGBQUAD structures and two masked bitmaps. The AND mask and the XOR mask. The AND mask is 1 bit per pixel and specifies which pixels are transparent and which show colors. The AND mask is read first while displaying an icon to decide which areas of the image are affected by the background. The XOR mask which has numerical indices for each of the RGBQUAD arrays that a pixel should be, is then read. This allows for transparent areas in the image but also allows for inverting the background and other tricks. 16 bit and 24 bit icons are independent of the RGB colour look-up table and the XOR mask directly indicates the color values.
When displaying 32-bit images in 32-bit mode (Windows XP onwards), the AND mask is not used, instead a single mask with an 8-bit alpha channel is used. Windows XP can also and will use a 32-bit image in 24-bit mode by removing the alpha channel and applying the AND mask for transparency if no 24-bit image is available. Since the AND mask describes the transparency in 24-bit mode, if it is not included, an incorrect transparency pattern will be produced.
All values are represented in little-endian (Intel standard) format.
Header
Offset# | Size (in bytes) | Purpose |
---|---|---|
0 | 2 | Reserved. Should always be 0. |
2 | 2 | Specifies image type: 1 for icon (.ICO) image, 2 for cursor (.CUR) image. Other values are invalid. |
4 | 2 | Specifies number of images in the file. |
Structure of image directory
Image #1 | Data for the first image |
Image #2 | Data for the second image |
... | |
Image #n | Data for the last image |
Image
Offset# | Size (in bytes) | Purpose |
---|---|---|
0 | 1 | Specifies image width in pixels. Can be 0, 255 or a number between 0 to 255. Should be 0 if image width is 256 pixels. |
1 | 1 | Specifies image height in pixels. Can be 0, 255 or a number between 0 to 255. Should be 0 if image height is 256 pixels. |
2 | 1 | Specifies number of colors in the color palette. Should be 0 if the image is truecolor. |
3 | 1 | Reserved. Should be 0.[Notes 1] |
4 | 2 | In .ICO format: Specifies color planes. Should be 0 or 1.[Notes 2]
In .CUR format: Specifies the horizontal coordinates of the hotspot in number of pixels from the left. |
6 | 2 | In .ICO format: Specifies bits per pixel. [Notes 3]
In .CUR format: Specifies the vertical coordinates of the hotspot in number of pixels from the top. |
8 | 4 | Specifies the size of the bitmap data in bytes |
12 | 4 | Specifies the offset of actuall bitmap data address in the file |
[edit] PNG format
The PNG format introduced with Windows Vista encodes the image transparency data directly as a PNG image; it contains neither the XOR nor the AND bitmap data of the older icon image format.
[edit] Icon library
An icon library is a way to package Windows icons. It is typically a 16-bit New Executable or a 32-bit Portable Executable binary file having .ICL extension with icon resources being the packaged icons.
[edit] See also
- Apple Icon Image, the icon format used in Mac OS X.
- Computer icon
- Favicon, an icon format used for websites
- List of icon software
- Windows bitmap, a very similar file format
[edit] Notes
- ^ 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 color planes to 0 or 1 is treated equivalently by the operating system, but if the color planes are set higher than 1, this value should be multiplied by the bits per pixel to determine the final color depth of the image. It is unknown if the various Windows operating system versions are resilient to different color 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] References
- ^ Butcher, Simon (2003-09-03). "Published specification". iana.org. http://www.iana.org/assignments/media-types/image/vnd.microsoft.icon. Retrieved 24 October 2009. "This media type is currently being labelled with a potpourri of names, including “text/ico”, “image/ico”, “image/icon”, “application/ico”, and so on. While “image/x-icon” is also used, this registration intends to finally clarify the media type for this file format."
- ^ Operating System Interface Design Between 1981-2009
- ^ 256-Color Support in Windows
- ^ a b c d Icons in Win32
- ^ Windows 95 Architecture Components
- ^ Shell Icon BPP
- ^ Creating Windows XP Icons
- ^ a b The Windows User Experience Guidelines: Icons