• Advertisement
Sign in to follow this  

BitBlt color key

This topic is 4215 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working in Win32 and using BitBlt to copy my bitmaps to a memory DC. This is ultimately copied to the screen. All the bitmaps I'm using have a black background, so when I copy the background gets carried along. The end result is a black rectangle around my sprites. How do I set a color key (for lack of a better term) such that the background doesn't get copied but the colored portions of the bitmap do?? I've dug through a number of BitBlt tutorials as well as MSDN and Petzold, but can't seem to find anything. -Kirk

Share this post


Link to post
Share on other sites
Advertisement
This may be of interest. I'm not sure there is any simpler way of getting transparency out of BitBlt, although I may be wrong since I don't know much about GDI really.

HTH

Share this post


Link to post
Share on other sites
What you need to do is create a mask that has white where you want transparency, blit that to the screen with SRCAND, and then after that blit your image (with black as transparency) over top using SRCPAINT (OR).

Here's an article I found on it:

Blt Transparency

Edit: Okay, easily confused beat me to it.

Okay, to try and make myself useful, and since I was also interested in this, I found another article here that explains the same technique, but at the bottom it shows another method that can do it directly by setting a transparent colour in the destination if the device supports it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement