cwinapiiconsico

BITMAPINFOHEADER biHeight is twice what I expect


I'm writing an application in C to parse Windows Icon files (ICO).

When I read in the BITMAPINFOHEADER struct for an existing icon entry, all of the variables within the struct contain values that are expected, except that biHeight, which should contain the height in pixels of the image, is always twice what it should be.

So for example if I have a 64x64 icon, biWidth is 64, but biHeight is 128.

Is this expected behavior? This is my first time dealing with BITMAPINFOHEADER.

I'm mainly operating from the MSDN article on BITMAPINFOHEADER.


Solution

  • Yes, this is normal. It is the added height of the "AND" bitmap mask and the "XOR" bitmap mask, so for any normal icon it is simply 2X the icon height. (Those masks aren't used for 32-bit icons anymore; they are a holdover.) Just divide by two.