Solved

About Bitmap ReDrawing..

Posted on 2002-04-17
5
264 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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
canBalance challenge 34 111
changeXy challenge 13 98
JQuery serialize and unserialize 8 268
Increment column based of a FK 8 68
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

734 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