[Webinar] Streamline your web hosting managementRegister Today


BLT 2 compatible bitmap to memory DC

Posted on 1999-12-13
Medium Priority
Last Modified: 2013-11-20
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.
Question by:KeithTeo
  • 3
  • 2

Expert Comment

ID: 2277345
What is the correct effect that you're hoping for?

Author Comment

ID: 2282032
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?

Accepted Solution

mjswart earned 100 total points
ID: 2283386
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 ;)

Author Comment

ID: 2289078
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.


Expert Comment

ID: 2289843
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:

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question