Solved

BitBlt cannot copy color?

Posted on 2003-12-12
6
301 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 100 total points
ID: 9927472
Change the "CreateCompatibleBitmap" line to

bmp.CreateCompatibleBitmap(pDC, 100, 100);

Good Luck

0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9927793
Is that problem solved?
Rosh :)
0
 

Author Comment

by:friendkey
ID: 9927806
I get it, thank you!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9927826
Please rate this Question

Rosh :)
0
 

Author Comment

by:friendkey
ID: 9927844
don't be so impatient :)
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9927854
:)
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Process filename extension 3 218
Looking for a specific application/software 2 124
has22 challenge 11 111
changeXy challenge 13 98
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.

751 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