- I have a radio button that should display an image (style
BS_AUTORADIOBUTTON|BS_PUSHLIKE|BS_BITMAP
). - I create a bitmap via
CreateDIBSection
(using aBITMAPINFO
withBI_RGB
) and obtain a pointer to the raw pixels via theppvBits
, so that I can manipulate them freely. - I use
BM_SETIMAGE
to set the button's image to the bitmap I created.
So far, I can set the RGB and alpha by manipulating the pixels by hand. I tested that even semi-transparent (non-premultiplied) alpha values look good.
As far as I can tell, everything works, except if all pixels in the image are transparent. In that case, the button apparently ignores the alpha value, simply displaying a rectangle with each pixel having the respective color with full opacity.
I found a hint that Windows - at least in some cases - actually seems to interpret images whose pixels' alpha values are all 0 as completely opaque images:
When the window manager sees a 32bpp bitmap, it looks at the alpha channel. If it's all zeroes, then it assumes that the image is in 0RGB format; otherwise it assumes it is in ARGB format
Is this behavior documented somewhere?
CreateDIBSection
, try to useBITMAPV4HEADER
withBI_BITFIELDS
to specify the alpha mask. This could allow the system to determine that the bitmap actually is inARGB
format, without using heuristics. If that doesn't work, a workaround could be to set the top-left pixel alpha value to 1, which I bet nobody will notice. – zett42