BOOL StretchBlt( HDC hdcDest, // handle to destination DC int nXOriginDest, // x-coord of destination upper-left corner int nYOriginDest, // y-coord of destination upper-left corner int nWidthDest, // width of destination rectangle int nHeightDest, // height of destination rectangle HDC hdcSrc, // handle to source DC int nXOriginSrc, // x-coord of source upper-left corner int nYOriginSrc, // y-coord of source upper-left corner int nWidthSrc, // width of source rectangle int nHeightSrc, // height of source rectangle DWORD dwRop // raster operation code ); The following example code is taken from an application that displays an image either at its original size or at twice its original size. (This application uses the default stretch mode.) hdcScaled = CreateCompatibleDC(hdcScreen);
HDC hdcDest, // handle to destination DC
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
int nWidthDest, // width of destination rectangle
int nHeightDest, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXOriginSrc, // x-coord of source upper-left corner
int nYOriginSrc, // y-coord of source upper-left corner
int nWidthSrc, // width of source rectangle
int nHeightSrc, // height of source rectangle
DWORD dwRop // raster operation code
);
The following example code is taken from an application that displays an image either at its original size or at twice its original size. (This application uses the default stretch mode.) hdcScaled = CreateCompatibleDC(hdcScreen);
hbmScaled = CreateCompatibleBitmap(hdcScreen,
GetDeviceCaps(hdcScreen, HORZRES) * 2,
GetDeviceCaps(hdcScreen, VERTRES) * 2);
if (hbmScaled == 0)
errhandler("hbmScaled", hwnd);
// Select the bitmaps into the compatible DC.
if (!SelectObject(hdcScaled, hbmScaled))
errhandler("Scaled Bitmap Selection", hwnd);
case WM_COMMAND: // message: command from application menu
switch(wParam)
{
case IDM_SCALEX1:
if (fBlt)
{
fScaled = FALSE;
hdcWin = GetDC(hwnd);
BitBlt(hdcWin,
0,0,
bmp.bmWidth, bmp.bmHeight,
hdcCompatible,
0,0,
SRCCOPY);
ReleaseDC(hwnd, hdcWin);
}
break;
case IDM_SCALEX2:
if (fBlt)
{
fScaled = TRUE;
StretchBlt(hdcScaled,
0, 0,
bmp.bmWidth * 2, bmp.bmHeight * 2,
hdcCompatible,
0, 0,
bmp.bmWidth, bmp.bmHeight,
SRCCOPY);
hdcWin = GetDC(hwnd);
BitBlt(hdcWin,
0,0,
bmp.bmWidth, bmp.bmHeight,
hdcScaled,
0,0,
SRCCOPY);
ReleaseDC(hwnd, hdcWin);
}
break;