Icon file format has a variety of common, there are PNG, ICL, IP, and is the next small series to introduce the ICO format icon, ICO format icon A monochrome icon, widely in the Windows system in the DLL, EXE file.
The icon file has a fixed file header, and its data structure is as follows:
typedef struct {
WORD idreserved;
WORD Idtype;
WORD Idcount;
Icondirentry Identries[1];
} Icondir, *lpicondir;
Where the idreserved reserved for the system must be 0
Where Idtype is the resource type, 1 is the icon, and 2 is the cursor
Where the Idcount icon contains a number of small images in the resource composition
Where Identries is a data point to the icondirentry structure, its length is determined by the Idcount.
Let's take a look at how the Icondirentry structure is defined.
typedef struct {
BYTE Bwidth;
BYTE Bheight;
BYTE Bcolorcount;
BYTE breserved;
WORD Wplanes;
WORD Wbitcount;
DWORD Dwbytesinres;
DWORD Dwimageoffset;
} icondirentry, *lpicondirentry;
It's a long series of structures ...
*bwidth and Bheight represent the width and height of the image, at first, the system supports only 1 to 255 of the size, that is, the size of the 2^8-1,
But starting with WIDNOWS95, you can support the size of 256.
*wbitcount and Wplanes are used to describe the color depth of the image, which is 1 for monochrome icons.
*breserved is the system reserved field of 0
*dwbytesinres represents image data size
*DWIMAGEOFFSE represents the location of the image data, which is the offset address.
* But there is a place to be noted, bcolorcount it is assumed to be equal to the number of colors in the image, which means that it equals:
Bcolorcount = 1 << (Wbitcount * wplanes)
When Wbitcount * Wplanes >= 8 o'clock, the Bcolorcount is 0
* In reality, many people bother to fill in the Bcolorcount value, even if the 4-color or 16-color icon, it is set to 0. Starting with Windows XP,
Windows detects this common error, but for planar bitmaps, there are some problems with this automatic error-correcting mechanism, and fortunately, few people use planar bitmaps.
But you should not rely on the automatic error-correcting mechanism provided by Windows, but fill in the Bcolorcount value correctly. The wrong bcolorcount means that, given the wrong color depth information,
Windows may choose a less-than-ideal image in the ICO file.
* The monochrome icon consists of two bitmaps, often called masks, respectively called and and Xor, and the drawing icon is divided into two steps: first mask and screen for "and" operation, and then "XOR" operation.
Pixel = (screen and mask) XOR image
Select the appropriate value for mask and image to overwrite all monochrome BLT operations.
Mask Image Result Action
0 0 (screen and 0) XOR 0 = 0 Black
0 1 (screen and 0) XOR 1 = 1 White
1 0 (screen and 1) XOR 0 = Screen invariant
1 1 (screen and 1) XOR 1 = no screen anti-color
* Theoretically, mask Specifies whether pixels of image are copied to the screen, and black pixels in mask indicate that the corresponding pixels in image are copied to the screen.
*mask and image bitmaps are physically stored as individual but doubly highly-named Dib. First is the image bitmap, then the mask. Since the DIB is a bottom-up save format,
So if you want to observe a bitmap, then mask on the top and image below). bmp file format uses the data coordinate system, that is to say (0,0) in the lower left corner,
The data in a BMP file is the first to download one row of pixels.
* According to the format, the image of each icon is saved in the form of a bitmapinfo structure, according to which Bitmapinfoheader to decide if there is no palette data, then the pixel data of image and mask pixel data.
Where bicompression must be BI_RGB, because it is double the height of the bitmap, so biwidth is the width of the image, biheight twice times the height of the image.
* For the icon of the monochrome icon first written here ...