HBITMAP xxxxx::ZoomHBitmap(HBITMAP hBitmap, INT32 ZoomWidth, INT32 ZoomHeight)
{
DWORD dwNewWidth = 0;
DWORD dwNewHeight = 0;
BITMAP Bitmap;
HBITMAP hBitmapNx = NULL;
HBITMAP hBitmapTemp = NULL;
HDC hDC = NULL;
HDC hDCNx = NULL;
HDC hScreenDC = NULL;
if (hBitmap == NULL)
{
return NULL;
}
::GetObject(hBitmap, sizeof(BITMAP), &Bitmap);
dwNewWidth = ZoomWidth;
dwNewHeight = ZoomHeight;
hScreenDC = ::GetDC(NULL);
hBitmapNx = ::CreateCompatibleBitmap(hScreenDC, dwNewWidth, dwNewHeight);
hBitmapTemp = ::CreateCompatibleBitmap(hScreenDC, dwNewWidth, dwNewHeight);
hDC = ::CreateCompatibleDC(hScreenDC);
hDCNx = ::CreateCompatibleDC(hScreenDC);
if (hBitmapNx == NULL || hBitmapTemp == NULL ||
hDC == NULL || hDCNx == NULL)
{
return NULL;
}
::SelectObject(hDC, hBitmap);
::SelectObject(hDCNx, hBitmapNx);
// 放大圖片
::StretchBlt(hDCNx, 0, 0, dwNewWidth, dwNewHeight, hDC, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight, SRCCOPY);
::SelectObject(hDCNx, hBitmapTemp);
::DeleteDC(hDC);
::DeleteDC(hDCNx);
::DeleteObject(hBitmapTemp);
::ReleaseDC(NULL, hScreenDC);
return hBitmapNx;
}