Hi everyone, is there any way in c++ to take a region (by using a rectangle) and copy its contents to redraw it later? I am trying to make a map editor and update my map. Whenever I resize the window, the map disappears. I want to copy the image when the window is resized and redraw it after it is resized. Please help.
Ryan
Copying an image by using a rectangle?
Where hdc is your window's device context and
HDC memdc;
HBITMAP membmp;
HBITMAP oldbmp;
are globals, use this code to construct buffer:
memdc = CreateCompatibleDC(hdc);
membmp = CreateCompatibleBitmap(hdc, width, height);
oldbmp = SelectObject(memdc, membmp);
Then use BitBlt function to copy to and from buffer.
Don't forget to call
SelectObject(memdc, oldbmp);
DeleteDC(memdc);
DeleteObject(membmp);
when done with buffer.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment