15,979
社区成员
发帖
与我相关
我的任务
分享
HBITMAP hOldBmp=(HBITMAP)::SelectObject(m_hMemDC,m_hBrightBmp);
HDC hmMemDC=CreateCompatibleDC(m_hMemDC);
//把没有处理过的位图的一部分贴到mmemDC上
HBITMAP hOldMemBmp=(HBITMAP)::SelectObject(hmMemDC,m_hScreenBmp);
rc=m_rcTrack.m_rect;creen
int nWidth=rc.right-rc.left;
int nHeight=rc.bottom-rc.top;
//复制mmemDC到memDC上
::BitBlt(m_hMemDC,rc.left,rc.top,nWidth,nHeight,hmMemDC,rc.left,rc.top,SRCCOPY);
HBITMAP CMyFormats::CopyHBitmap(HBITMAP hSourceHbitmap)
{
CDC sourceDC;
CDC destDC;
sourceDC.CreateCompatibleDC(NULL);
destDC.CreateCompatibleDC(NULL);
//The bitmap information.
BITMAP bm = {0};
//Get the bitmap information.
::GetObject(hSourceHbitmap, sizeof(bm), &bm);
// Create a bitmap to hold the result
HBITMAP hbmResult = ::CreateCompatibleBitmap(CClientDC(NULL), bm.bmWidth, bm.bmHeight);
HBITMAP hbmOldSource = (HBITMAP)::SelectObject(sourceDC.m_hDC, hSourceHbitmap);
HBITMAP hbmOldDest = (HBITMAP)::SelectObject(destDC.m_hDC, hbmResult);
destDC.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &sourceDC, 0, 0, SRCCOPY );
// Restore DCs
::SelectObject(sourceDC.m_hDC, hbmOldSource);
::SelectObject(destDC.m_hDC, hbmOldDest);
::DeleteObject(sourceDC.m_hDC);
::DeleteObject(destDC.m_hDC);
return hbmResult;
}