Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BITMAPINFOHEADER biHeight is twice what I expect

Tags:

c

icons

ico

winapi

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.

like image 395
Michael Avatar asked Apr 28 '11 02:04

Michael


1 Answers

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.

like image 99
JohnSpeeks Avatar answered Sep 29 '22 07:09

JohnSpeeks