Header
typedef struct
{
WORD idReserved; // Reserved.Must always be 0.
WORD idType; // Specifies image type: 1 for icon(.ico)image, 2 for cursor(.cur) image.Other values are invalid.
WORD idCount; // Specifies number of images in the file.
ICONDIRENTRY idEntries[1]; // An entry for each image (idCount of 'em)
} ICONDIR, *LPICONDIR;
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 |
typedef struct
{
BYTE bWidth; // Specifies image width in pixels.Can be any number between 0 and 255.Value 0 means image width is 256 pixels(vista).
BYTE bHeight; // Specifies image height in pixels.
BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
BYTE bReserved; // Reserved ( must be 0)
WORD wPlanes; // Color Planes.Should be 0 or 1.
WORD wBitCount; // Bits per pixel
DWORD dwBytesInRes; // Specifies the size of the image's data in bytes.
DWORD dwImageOffset; // Specifies the offset of BMP or PNG data from the beginning of the ICO/CUR file.
} ICONDIRENTRY, *LPICONDIRENTRY;
Referenced image dataAll 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./*Store them order by define in ICONDIREENTRY*/
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./* BMP file must exclude BITMAPFILEHEADER, PNG file must clude entire*/
[notice]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.