Sign in to follow this  
kirkd

BitBlt color key

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this