PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Weird DrawIcon problem

I've come across a very aggravating problem. Bear with me while I set this up.

I'm creating a 24 bit DIB (CreateDIBSection), selecting it into a Memory DC (CreateCompatibleDC), filling it with a background color which is my transparent color, then drawing icons to it (DrawIcon / DrawIconEx). Now, what is happening (seemingly randomly) is that when I DrawIcon to the DC, the transparent portions of the icon are modifying my background color values. So if I fill with 0x00ff00ff, then DrawIcon to it, the transparent regions are now 0x00fb04fb. Yes, I verified the bitmap's bits with the debugger and it contained ff 00 ff triplets after the fill as it should, then fb 04 fb after the DrawIcon.
Now for the kicker. If I choose 0x00fb04fb as my transparent fill color, then DrawIcon, the transparent regions have become 0x00ff00ff!

Anybody have any clue what is going on with this? The icons are being extracted from an ImageList. Sometimes the problem occurs with some icons, other runs it will effect a different set of icons.

Dan East
Well, I found a way to work around this problem. I simply draw the icon (DrawIcon) twice in a row. If that icon is going to distort the transparent pixels, then the second draw corrects it. Very strange, and not an optimum solution, but at the moment I just want it to work.

Dan East
This is really weird. Let us know if you find anything.