Solved

About Bitmap ReDrawing..

Posted on 2002-04-17
5
265 Views
Last Modified: 2013-11-20
Hi Friends
      Is there any function to Redraw Bitmap...
0
Comment
Question by:JonMac
[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
5 Comments
 
LVL 3

Expert Comment

by:Crius
ID: 6948237
Use BitBlt() from the bitmap or bitmap DC to the screen DC. It's the fastest way.

BOOL BitBlt(
  HDC hdcDest, // handle to destination DC
  int nXDest,  // x-coord of destination upper-left corner
  int nYDest,  // y-coord of destination upper-left corner
  int nWidth,  // width of destination rectangle
  int nHeight, // height of destination rectangle
  HDC hdcSrc,  // handle to source DC
  int nXSrc,   // x-coordinate of source upper-left corner
  int nYSrc,   // y-coordinate of source upper-left corner
  DWORD dwRop  // raster operation code
);

Ex:
BitBlt(pDC, 0, 0, 1024, 800, BitmapDC, 0, 0, SRCCOPY);
0
 

Author Comment

by:JonMac
ID: 6949809
Thanks crius for ur help , but my question is different , i already using stretchblt function, again explaning my question..
     In my application i load the bitmap from the disk(using CFileDialog) & then set in a view as a background , then using CPen object i have made some changes in the bitmap which is in the background,now i want to restore t
he original bitmap without loading it again from the disk.
  Infact i want to make a copy of the loaded bitmap & then set that copy in the view & then all the changes occur only in that copy & when i want to restore bitmap i can replace that copy with the original one .how can it possible?

 if anybody knows pls. help me.



JonMac
0
 
LVL 2

Accepted Solution

by:
manojbkumar earned 50 total points
ID: 6949901
>>want to make a copy of the loaded bitmap
You can use the following function
void CYourView::CopyBitmap(CBitmap &BmpIn, CBitmap &BmpOut)
{
     if(!BmpIn.GetSafeHandle())
          return;
     CClientDC dc(this);
     CDC TempDC;
     CDC memDC;
     BITMAP bm;

     TempDC.CreateCompatibleDC(&dc);
     memDC.CreateCompatibleDC(&dc);
     BmpIn.GetBitmap(&bm);
     BmpOut.DeleteObject();
     BmpOut.CreateCompatibleBitmap(&dc,bm.bmWidth, bm.bmHeight);
     TempDC.SelectObject(&BmpOut);
     memDC.SelectObject(&BmpIn);
     TempDC.BitBlt(0,0,bm.bmWidth, bm.bmHeight,&memDC,0,0,SRCCOPY);
}
0
 
LVL 3

Expert Comment

by:Crius
ID: 6950620
Manojbkumar has the solution - A Bitblt, or StretchBlt is not limited to copying from a Bitmap DC to the screen DC. It can copy from Bitmap DC to Bitmap DC, or actually between any compatible DCs.

The solution provided above uses CBitmap, but you can use HBITMAP instead, and HDCs.

If you have any questions about these methods, just let us know. :)
0
 

Expert Comment

by:SpideyMod
ID: 8145209
Administrative Action - Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Independent Software Vendors: 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!

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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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