Reputation: 103
I am new to MFC. Now I have the following question: I have a large-size picture (e.g. size of 2000*2000) display in a small-size window (e.g. size of 640*480). No wonder that the picture cannot show itself fully without zooming out. I know I can save the original picture without losing any pixel if the picture can fit into the window, however, I cannot do this at this time:
CClientDC SHDC(this); //"this" is a CMDIChildWnd derived class
CDC memDC;
CRect rect;
GetClientRect(&rect);
memDC.CreateCompatibleDC(&SHDC);
CBitmap bm;
int uWidth = rect.Width();
int uHeight = rect.Height();
bm.CreateCompatibleBitmap(&SHDC, uWidth, uHeight);
CBitmap *pOld = memDC.SelectObject(&bm);
memDC.BitBlt(0, 0, uWidth, uHeight, &SHDC, 0, 0, SRCCOPY);
......
The saved picture only show the client area, but I would like to get all of the picture saved. Anyone who can help me? Thanks in advance.
Xi
Upvotes: 0
Views: 1040
Reputation: 3874
Instead of BitBlt
try StretchBlt
. It'll handle the shrinking for you.
The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary. The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.
If you want higher quality stretching/shrinking look at GDI+. There's a variety of interpolation modes you can use. More info here:
http://msdn.microsoft.com/en-us/library/k0fsyd4e.aspx
Upvotes: 2