BLT 2 compatible bitmap to memory DC

I've created 2 separate compatible bitmap with some drawing on it. However, I couldn't achieve the correct effect. Its either I get a translucent color effect or I get inverted color display. (I tried using NOTSRCCOPY with SRCINVERT). Anyone can advise on how to which operation should I use? ( The size of the bitmaps is the same. )

I will also award more points if someone can explain to me when each operation is being used. (Pls don't code from MSDN. I've seem that already. What I need is example.) Thanks.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What is the correct effect that you're hoping for?
KeithTeoAuthor Commented:
I wished to have the original coloring that I have for my 2 bitmaps. For example, if I have a yellow circle and a purple rectangle on each of the compatible bitmaps, I wished to have it merge into one compatible bitmap which can then BLT to the screen. So the end effect is I see a yellow and a purple circle and rectangle respectively.

Can help?
if the yellow circle and purple rectangle have a black background and don't overlap then the Raster operation you're searching for is: SRCPAINT.

If it's not that simple (for example you may not have black backgrounds) Then you might use an extra 'mask' bitmap to black out the area that you'll be painting too. before you paint there.

I guess it's kind of like primer ;)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KeithTeoAuthor Commented:
The thing is the drawing overlaps. The circle is sitting on top of the rectangle. In fact, there are lots of circles not just one. And some circles overlap too.

The masking operation that you suggested is for the circle, am I right? Can you give some more guidance pls? Thanks.

You should create another bitmap identical to the circle:
Except that the color of the circle is white and the background is black:

// dcScreen is the screen device context:
// bmCircle is your circle bitmap:
// bmMask is an almost identical bitmap, described above:

CDC dcMem1, dcMem2;
BITMAP bitmap;
dcMem2.BitBlt(0, 0, bitmap.bmWidth, bitmap.bmHeight,
   &dcMem1, 0, 0, SRCAND);

// Now dcMem2 contains only the circle with a black
// background which you can SRCPAINT like the following:

dcScreen.BitBlt(x,y,bitmap.bmWidth, bitmap.bmHeight,
   &dcMem2, 0, 0, SRCPAINT);

// If you want a different shape than a circle, than
// the mask should reflect that shape:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.