19,468
社区成员
发帖
与我相关
我的任务
分享
//---------------------------------------------------
// Function : CopyBitmap
// Description : Copy a block bitmap from the source
// bitmap Specifies location
//
// 2007-11-09 LiJun crated.
//---------------------------------------------------
HBITMAP WINAPI
CopyBitmap(
IN HBITMAP hSrcBmp,
IN int nWidth,
IN int nHeight,
IN int xSrc,
IN int ySrc
)
{
HDC hDC, hMemDC, hSrcDC;
HBITMAP hNew, hOldBmp, hOldSrc;
if( hSrcBmp == NULL )
return NULL;
hDC = GetDC(NULL);
if( hDC == NULL )
return NULL;
hSrcDC = CreateCompatibleDC(hDC);
hMemDC = CreateCompatibleDC(hDC);
hNew = CreateCompatibleBitmap(hDC, nWidth, nHeight);
hOldSrc = (HBITMAP)SelectObject(hSrcDC, hSrcBmp);
hOldBmp = (HBITMAP)SelectObject(hMemDC, hNew);
BitBlt(hMemDC, 0, 0, nWidth, nHeight, hSrcDC, xSrc, ySrc, SRCCOPY);
SelectObject(hSrcDC, hOldSrc);
SelectObject(hMemDC, hOldBmp);
DeleteDC(hSrcDC);
DeleteDC(hMemDC);
ReleaseDC(NULL, hDC);
return hNew;
}