Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

About Bitmap ReDrawing..

Posted on 2002-04-17
5
Medium Priority
?
267 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 200 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

610 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