It turns out that GDI+ never brings across the alpha channel when creating a Bitmap from an HBITMAP.
The answer is to:
- Use GetObject passing in a BITMAP and the HBITMAP, to get the width and height (and if the input bitmap is a DIB, the pixel data) of the input HBITMAP.
- Create a Bitmap of the correct size with 32 bit PARGB pixel format.
- Use LockBits to get hold of the pixelData memory of your new Bitmap.
- If you got the pixels from GetObject, copy the ARGB values across using memcpy.
- Call UnlockBits on the new Bitmap.
In my case, the format of the input HBITMAP is correct for doing a straight memcpy from input bitmap pixel data to the new Bitmap pixel data.
If you didnt get the input pixel data from GetObject, use GetDIBits to get a copy in the correct format.