Solved

BitBlt cannot copy color?

Posted on 2003-12-12
6
293 Views
Last Modified: 2013-11-20
when i use BitBlt copy a graphic from a bitmap device context into client device context, the color in the source DC is lost.The graphic changed into black and white.

this is the code:

void CBrushTestView::OnDraw(CDC* pDC)
{
      CBrushTestDoc* pDoc = GetDocument();
      ASSERT_VALID(pDoc);
      if (!pDoc)
            return;

      CBitmap bmp;
      CDC dcBmp;
      CBrush brush;
      RECT rect={0,0,100,100};
      LOGBRUSH lb;
      lb.lbColor = RGB(255,0,0);
      lb.lbHatch = HS_BDIAGONAL;
      lb.lbStyle = BS_SOLID;
      brush.CreateBrushIndirect(&lb);

      dcBmp.CreateCompatibleDC(pDC);
      bmp.CreateCompatibleBitmap(&dcBmp, 100, 100);
      dcBmp.SelectObject(&bmp);
      dcBmp.SelectObject(&brush);
      dcBmp.Rectangle(&rect);
      pDC->BitBlt(200,0,100,100,&dcBmp,0,0,SRCCOPY);
      pDC->SelectObject(&brush); // black and white
      pDC->Rectangle(&rect);// red
}
0
Comment
Question by:friendkey
  • 4
  • 2
6 Comments
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 100 total points
Comment Utility
Change the "CreateCompatibleBitmap" line to

bmp.CreateCompatibleBitmap(pDC, 100, 100);

Good Luck

0
 
LVL 23

Expert Comment

by:Roshan Davis
Comment Utility
Is that problem solved?
Rosh :)
0
 

Author Comment

by:friendkey
Comment Utility
I get it, thank you!
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 23

Expert Comment

by:Roshan Davis
Comment Utility
Please rate this Question

Rosh :)
0
 

Author Comment

by:friendkey
Comment Utility
don't be so impatient :)
0
 
LVL 23

Expert Comment

by:Roshan Davis
Comment Utility
:)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli‚Ķ
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now