问题
As stated in MSDN ICONINFO, depending on whether the structure defines a black and white icon, the hbmMask
and hbmColor
are formatted differently.
hbmMask
Type: HBITMAP
The icon bitmask bitmap. If this structure defines a black and white icon, this bitmask is formatted so that the upper half is the icon AND bitmask and the lower half is the icon XOR bitmask. Under this condition, the height should be an even multiple of two. If this structure defines a color icon, this mask only defines the AND bitmask of the icon.
This means we need to detect the existences of hbmColor
to properly calculate the icon's height.
However, I later notice Gdiplus::Bitmap::FromHICON()
, which accepts a HICON
and converts it to a Gdiplus::Bitmap
.
Since I don't see any material mentioning about the "black and white" icon in GDI+, does this method has taken care of this situation internally?
(Unfortunately, I don't have a handy icon for testing. I'm not sure how to create a proper test case either.)
来源:https://stackoverflow.com/questions/45867852/does-gdiplusbitmapfromhicon-handle-black-and-white-icon-properly