ICO (icon image file format)
Encyclopedia
The ICO file format is an image file format for computer icon
Computer icon
A computer icon is a pictogram displayed on a computer screen and used to navigate a computer system or mobile device. The icon itself is a small picture or symbol serving as a quick, intuitive representation of a software tool, function or a data file accessible on the system. It functions as an...

s in Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

. ICO files contain one or more small images at multiple sizes and color depth
Color depth
In computer graphics, color depth or bit depth is the number of bits used to represent the color of a single pixel in a bitmapped image or video frame buffer. This concept is also known as bits per pixel , particularly when specified along with the number of bits used...

s, such that they may be scaled
Image scaling
In computer graphics, image scaling is the process of resizing a digital image. Scaling is a non-trivial process that involves a trade-off between efficiency, smoothness and sharpness. As the size of an image is increased, so the pixels which comprise the image become increasingly visible, making...

 appropriately. In Windows, all executable
Executable
In computing, an executable file causes a computer "to perform indicated tasks according to encoded instructions," as opposed to a data file that must be parsed by a program to be meaningful. These instructions are traditionally machine code instructions for a physical CPU...

s that display an icon to the user, on the desktop, in the Start Menu, or in Windows Explorer, must carry the icon in ICO format.

The 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 the bytes used to identify them and the addition of a hotspot in the CUR format header; the hotspot is defined as the pixel offset (in x,y coordinates) from the top-left corner of the cursor image where the user is actually pointing the mouse.

History

Icons introduced in Windows 1.0
Windows 1.0
Windows 1.0 is a 16-bit graphical operating environment, developed by Microsoft and released on 20 November 1985. It was Microsoft's first attempt to implement a multi-tasking graphical user interface-based operating environment on the PC platform. Windows 1.0 was the first version of Windows...

 were 32×32 pixels in size and were monochrome. Support for 256 colors was introduced in Windows 3.0
Windows 3.0
Windows 3.0, a graphical environment, is the third major release of Microsoft Windows, and was released on 22 May 1990. It became the first widely successful version of Windows and a rival to Apple Macintosh and the Commodore Amiga on the GUI front...

.

Win32 introduced support for storing icon images of up to 16.7 million colors (Truecolor) and up to 256x256 pixels in dimensions. Windows 95 also introduced a new Device Independent Bitmap (DIB) engine. 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 or by purchasing Microsoft Plus!
Microsoft Plus!
Microsoft Plus! was a commercial operating system enhancement product by Microsoft. The last edition is the Plus! SuperPack, which includes an assortment of screensavers, themes, and games, as well as multimedia applications...

 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. Thus, even prior to Windows XP
Windows XP
Windows XP is an operating system produced by Microsoft for use on personal computers, including home and business desktops, laptops and media centers. First released to computer manufacturers on August 24, 2001, it is the second most popular version of Windows, based on installed user base...

, 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
Taskbar
In computing, a taskbar is a bar displayed on a full edge of a GUI desktop that is used to launch and monitor running applications. Microsoft incorporated a taskbar in Windows 95 and it has been a defining aspect of Microsoft Windows's graphical user interface ever since. Some desktop environments,...

 was limited to 16 color icons by default until Windows Me
Windows Me
Windows Millennium Edition, or Windows Me , is a graphical operating system released on September 14, 2000 by Microsoft, and was the last operating system released in the Windows 9x series. Support for Windows Me ended on July 11, 2006....

 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
Drop shadow
In computer graphics, a drop shadow is a visual effect consisting of drawing that looks like the shadow of an object, giving the impression that the object is raised above the objects behind it. The drop shadow is often used for elements of a graphical user interface such as windows or menus, and...

, anti-aliasing
Anti-aliasing
In digital signal processing, spatial anti-aliasing is the technique of minimizing the distortion artifacts known as aliasing when representing a high-resolution image at a lower resolution...

, and glass-like shapes to be drawn in an icon.

Windows XP, by default, employs 48×48 pixel icons in Windows Explorer
Windows Explorer
This article is about the Windows file system browser. For the similarly named web browser, see Internet ExplorerWindows Explorer is a file manager application that is included with releases of the Microsoft Windows operating system from Windows 95 onwards. It provides a graphical user interface...

. 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. Microsoft only recommended icon sizes up to 48×48 pixels for Windows XP. 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.

Windows Vista
Windows Vista
Windows Vista is an operating system released in several variations developed by Microsoft for use on personal computers, including home and business desktops, laptops, tablet PCs, and media center PCs...

 adds support for displaying 256×256 pixel icon images as a separate view in Windows Explorer, and supports (but does not require) the compressed
Data compression
In computer science and information theory, data compression, source coding or bit-rate reduction is the process of encoding information using fewer bits than the original representation would use....

 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. 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.

MIME type

The official IANA
Internet Assigned Numbers Authority
The Internet Assigned Numbers Authority is the entity that oversees global IP address allocation, autonomous system number allocation, root zone management in the Domain Name System , media types, and other Internet Protocol-related symbols and numbers...

-registered MIME type for ICO files is image/vnd.microsoft.icon, registered in 2003. Erroneous labels "image/ico", "image/icon", "text/ico" and "application/ico", along with the unofficial name "image/x-icon" were in use at the time of official registration and assignment of the MIME type.

When using the ICO format for (X)HTML img elements, Internet Explorer versions 6 - 9b2 cannot display files served with the correct MIME type. A workaround is to use the non-standard "image/x-icon" MIME type.

Icon resource structure

An ICO or CUR file is made up of an ICONDIR ("Icon directory") structure, containing an ICONDIRENTRY structure for each image in the file, followed by a contiguous block of all image bitmap data (which may be in either Windows BMP format, excluding the BITMAPFILEHEADER structure, or in PNG format, stored in its entirety).

Images with less than 32 bits of color depth follow a particular format: the image is encoded as a single image consisting of a color mask (the "XOR mask") together with an opacity mask (the "AND mask"). The XOR mask must precede the AND mask inside the bitmap data; if the image is stored in bottom-up order (which it most likely is), the XOR mask would be drawn below the AND mask. The AND mask is 1 bit per pixel, regardless of the color depth specified by the BMP header, and specifies which pixels are fully transparent and which are fully opaque. The XOR mask conforms to the bit depth specified in the BMP header and specifies the numerical color or palette value for each pixel. Together, the AND mask and XOR mask make for a non-transparent image representing an image with 1-bit transparency; they also allow for inversion of the background. The height for the image in the ICONDIRENTRY structure of the ICO/CUR file takes on that of the intended image dimensions (after the masks are composited), whereas the height in the BMP header takes on that of the two mask images combined (before they are composited). Therefore, the masks must each be of the same dimensions, and the height specified in the BMP header must be exactly twice the height specified in the ICONDIRENTRY structure.

32-bit images (including 32-bit BITMAPINFOHEADER-format BMP imagesThe classic BITMAPINFOHEADER bitmap format supports storing images with 32 bits per pixel. When saved as a standalone .BMP file, "the high byte in each [pixel] is not used". However, when this same data is stored inside a ICO or CUR file, Windows XP (the first Windows version to support ICO/CUR files with more than 1 bit of transparency) and above interpret this byte as an alpha value.) are specifically a 24-bit image with the addition of an 8-bit channel for alpha compositing
Alpha compositing
In computer graphics, alpha compositing is the process of combining an image with a background to create the appearance of partial or full transparency. It is often useful to render image elements in separate passes, and then combine the resulting multiple 2D images into a single, final image in a...

. Thus, in 32-bit images, the AND mask is not required, but recommended for consideration. Windows XP and higher will use a 32-bit image in less than True color mode by constructing an AND mask based on the alpha channel (if one does not reside with the image already) if no 24-bit version of the image is supplied in the ICO/CUR file. However, earlier versions of Windows interpret all pixels with 100% opacity unless an AND mask is supplied with the image. Supplying a custom AND mask will also allow for tweaking and hinting by the icon author. Even if the AND mask is not supplied, if the image is in Windows BMP format, the BMP header must still specify a doubled height.

Outline

All values in ICO/CUR files are represented in little-endian byte order.

Header
ICONDIR structure
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 Entry for the first image
Image #2 Entry for the second image
...
Image #n Entry for the last image



ICONDIRENTRY structure
Offset# Size (in bytes) Purpose
0 1 Specifies image width in pixels. Can be any number between 0 to 255. Value 0 means image width is 256 pixels.
1 1 Specifies image height in pixels. Can be any number between 0 to 255. Value 0 means image height is 256 pixels.
2 1 Specifies number of colors in the color palette. Should be 0 if the image does not use a color palette.
3 1 Reserved. Should be 0.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.
4 2 In ICO format: Specifies color planes. Should be 0 or 1.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.

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. 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.

In CUR format: Specifies the vertical coordinates of the hotspot in number of pixels from the top.
8 4 Specifies the size of the image's data in bytes
12 4 Specifies the offset of BMP or PNG data from the beginning of the ICO/CUR file


Referenced image data

All image data referenced by entries in the image directory proceed directly after the image directory. It is customary practice to store them in the same order as defined in the image directory.

Recall that if an image is stored in BMP format, it must exclude the opening BITMAPFILEHEADER structure, whereas if it is stored in PNG format, it must be stored in its entirety.

PNG format

The ability to read PNG images from ICO and CUR format images was introduced in Windows Vista. A PNG image can be stored in the image in the same way as done for a standard Windows BMP format image, with the exception that the PNG image must be stored in its entirety, with its file header.

Icon library

An icon library is a way to package Windows icons. It is typically a 16-bit New Executable
New Executable
The New Executable is a 16-bit .exe file format, a successor to the DOS MZ executable format. It was used in a special version of MS-DOS, Windows 1.0, Windows 2.x, and Windows 3.x...

 or a 32-bit Portable Executable
Portable Executable
The Portable Executable format is a file format for executables, object code and DLLs, used in 32-bit and 64-bit versions of Windows operating systems. The term "portable" refers to the format's versatility in numerous environments of operating system software architecture...

 binary file having .ICL extension with icon resource
Resource (Windows)
In Microsoft Windows, resources are read-only data embedded in EXE, DLL, CPL or MUI files.The Windows API provides for easy access to all applications' resources.-Types:...

s being the packaged icons. Windows Vista
Windows Vista
Windows Vista is an operating system released in several variations developed by Microsoft for use on personal computers, including home and business desktops, laptops, tablet PCs, and media center PCs...

 and later versions do not support viewing icons from 16-bit (New Executable
New Executable
The New Executable is a 16-bit .exe file format, a successor to the DOS MZ executable format. It was used in a special version of MS-DOS, Windows 1.0, Windows 2.x, and Windows 3.x...

) files.

See also

  • Apple Icon Image
    Apple Icon Image
    The Apple Icon Image format is the icon format used in Apple Inc.'s Mac OS X. It supports icons of 16×16, 32×32, 48×48, 128×128, 256×256 and 512×512 pixels, with both 1- and 8-bit alpha channels and multiple image states...

  • Computer icon
    Computer icon
    A computer icon is a pictogram displayed on a computer screen and used to navigate a computer system or mobile device. The icon itself is a small picture or symbol serving as a quick, intuitive representation of a software tool, function or a data file accessible on the system. It functions as an...

  • Favicon
    Favicon
    A favicon , also known as a shortcut icon, Web site icon, URL icon, or bookmark icon, is a file containing one small icons, most commonly 16×16 pixels, associated with a particular Web site or Web page...

  • List of icon software
  • BMP file format

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK