TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: FERNANDO ARIEL GONT
from: ADAM MAJER
date: 1998-03-26 16:20:00
subject: .ico file format

FAG>Does any of you have a "description" of the .ico file format, or know 
where
FAG>I could get it from?
This is directly off my help file
Icon-Resource File Format
An icon-resource file contains image data for icons used by Windows
applications. The file consists of an icon directory identifying the
number and types of icon images in the file, plus one or more icon
images. The default filename extension for an icon-resource file is
.ICO.
Icon Directory
Each icon-resource file starts with an icon directory. The icon
directory, defined as an ICONDIR structure, specifies the number of
icons in the resource and the dimensions and color format of each icon
image. The ICONDIR structure has the following form:
typedef struct ICONDIR {
    WORD          idReserved;
    WORD          idType;
    WORD          idCount;
    ICONDIRENTRY  idEntries[1];
} ICONHEADER;
Following are the members in the ICONDIR structure:
idReserved        Reserved; must be zero.
idType            Specifies the resource type. This member is set to 1.
idCount           Specifies the number of entries in the directory.
idEntries          Specifies an array of ICONDIRENTRY structures
                        containing information about individual icons.
                        The idCount member specifies the number of
                        structures in the array.
The ICONDIRENTRY structure specifies the dimensions and color format for
an icon. The structure
has the following form:
struct IconDirectoryEntry {
    BYTE  bWidth;
    BYTE  bHeight;
    BYTE  bColorCount;
    BYTE  bReserved;
    WORD  wPlanes;
    WORD  wBitCount;
    DWORD dwBytesInRes;
    DWORD dwImageOffset;
};
Following are the members in the ICONDIRENTRY structure:
bWidth        Specifies the width of the icon, in pixels. Acceptable
                values are 16, 32, and 64.
bHeight        Specifies the height of the icon, in pixels. Acceptable
                values are 16, 32, and 64.
bColorCount     Specifies the number of colors in the icon. Acceptable
                values are 2, 8, and 16.
bReserved       Reserved; must be zero.
wPlanes         Specifies the number of color planes in the icon bitmap.
wBitCount       Specifies the number of bits in the icon bitmap.
dwBytesInRes    Specifies the size of the resource, in bytes.
dwImageOffset   Specifies the offset, in bytes, from the beginning of
                the file to the icon image.
Icon Image
Each icon-resource file contains one icon image for each image
identified in the icon directory. An icon image consists of an
icon-image header, a color table, an XOR mask, and an AND mask. The icon
image has the following form:
BITMAPINFOHEADER    icHeader;
RGBQUAD             icColors[];
BYTE                icXOR[];
BYTE                icAND[];
The icon-image header, defined as a BITMAPINFOHEADER structure,
specifies the dimensions and color format of the icon bitmap. Only the
biSize through biBitCount members and the biSizeImage member are used.
All other members (such as biCompression and biClrImportant) must be set
to zero. The color table, defined as an array of RGBQUAD structures,
specifies the colors used in the XOR mask. As with the color table in a
bitmap file, the biBitCount member in the icon-image header determines
the number of elements in the array. The XOR mask, immediately following
the color table, is an array of BYTE values representing consecutive
rows of a bitmap. The bitmap defines the basic shape and color of the
icon image. As with the bitmap bits in a bitmap file, the bitmap data in
an icon-resource file is organized in scan lines, with each byte
representing one or more pixels, as defined by the color format.
The AND mask, immediately following the XOR mask, is an array of BYTE
values, representing a monochrome bitmap with the same width and height
as the XOR mask. The array is organized in scan lines, with each byte
representing 8 pixels. When Windows draws an icon, it uses the AND and
XOR masks to combine the icon image with the pixels already on the
display surface. Windows first applies the AND mask by using a bitwise
AND operation; this preserves or removes existing pixel color. Windows
then applies the XOR mask by using a bitwise XOR operation. This sets
the final color for each pixel. The following illustration shows the XOR
and AND masks that create a monochrome icon (measuring 8 pixels by 8
pixels) in the form of an uppercase K:
Windows Icon Selection
Windows detects the resolution of the current display and matches it
against the width and height specified for each version of the icon
image. If Windows determines that there is an exact match between an
icon image and the current device, it uses the matching image.
Otherwise, it selects the closest match and stretches the image to the
proper size. If an icon-resource file contains more than one image for a
particular resolution, Windows uses the icon image that most closely
matches the color capabilities of the current display. If no image
matches the device capabilities exactly, Windows selects the image that
has the greatest number of colors without exceeding the number of
display colors. If all images exceed the color capabilities of the
current display, Windows uses the icon image with the least number of
colors.
Hope that helps! :)
 * SLMR 2.1a * If this were an actual tagline, it would be funny.
--- FMail 0.92
---------------
* Origin: The Programmer's Oasis on FIDONET! (1:348/203)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.