About Bitmap ReDrawing..

Hi Friends
      Is there any function to Redraw Bitmap...
Who is Participating?
manojbkumarConnect With a Mentor Commented:
>>want to make a copy of the loaded bitmap
You can use the following function
void CYourView::CopyBitmap(CBitmap &BmpIn, CBitmap &BmpOut)
     CClientDC dc(this);
     CDC TempDC;
     CDC memDC;
     BITMAP bm;

     BmpOut.CreateCompatibleBitmap(&dc,bm.bmWidth, bm.bmHeight);
     TempDC.BitBlt(0,0,bm.bmWidth, bm.bmHeight,&memDC,0,0,SRCCOPY);
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

BitBlt(pDC, 0, 0, 1024, 800, BitmapDC, 0, 0, SRCCOPY);
JonMacAuthor Commented:
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.

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. :)
Administrative Action - Force Accepted

Community Support Moderator @Experts Exchange
All Courses

From novice to tech pro — start learning today.