In an ArcMap 10 add-in, I am attempting to create a toggle button of sorts whose image changes based on the button's state.
This answer describes how to set an add-in button's image programmatically and I am using the same technique. The problem is that this method does not appear to support full alpha channel transparency, only single-color transparency, so those fancy PNG icons they added at ArcGIS 10 don't look quite right.
The button's image is set initially by the add-in framework (using a 32-bit PNG file with alpha channel) -- the image looks as you would expect with proper partial transparency.
To create the image toggling behavior, in the button's
OnClick method, I check the state of a boolean variable and set the button's image (using the technique in the above-mentioned answer) to one of two bitmaps stored as resources in the add-in assembly. This all works fine except that the button's image is given a gray background instead of a transparent background.
I have searched around a bit and come to the conclusion that ESRI's
GetIPictureDispFromBitmap method converts from a GDI+ bitmap to a GDI bitmap and in doing so loses the alpha channel of the original bitmap.
I have found a solution to this issue and will post it as an answer shortly.