Solved

About Bitmap ReDrawing..

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Rewrite URL With Encoded Characters 6 64
Perl Awk Need Help 3 94
EvenOdd challenge 10 83
Making an alias 7 54
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now