Solved

BitBlt cannot copy color?

Posted on 2003-12-12
6
300 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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
Perl Awk Need Help 3 138
Hibernate methods 2 83
Execute multiple curl cmds with sleep and send output to file 10 114
Increment column based of a FK 8 50
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

756 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