Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

BitBlt cannot copy color?

Posted on 2003-12-12
6
Medium Priority
?
304 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 400 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

670 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