|
发表于 2020-3-29 10:00:01
|
显示全部楼层
HBITMAP hBitmap = NULL;
if(OpenClipboard())
{
hBitmap = (HBITMAP)GetClipboardData(CF_BITMAP);
if(hBitmap)
{
CDC* pdc = GetDC();
CBitmap* pCBmp = new CBitmap;
pCBmp->Attach(hBitmap);
BITMAP bm;
pCBmp->GetBitmap(&bm);
CDC dcCompatible;
dcCompatible.CreateCompatibleDC(pdc);
dcCompatible.SelectObject(pCBmp);
CDC dcMemDC;
dcMemDC.CreateCompatibleDC(pdc);
dcMemDC.SetStretchBltMode(COLORONCOLOR);
dcMemDC.SelectObject(pCBmp);
BOOL bBitblt = dcMemDC.StretchBlt(0,0,bm.bmWidth,bm.bmHeight,&dcCompatible,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
DWORD dwErrorCode = GetLastError();
hBitmap = CreateCompatibleBitmap(dcMemDC.m_hDC, bm.bmWidth/5, bm.bmHeight/5);
pCBmp->Detach();
pCBmp->Attach(hBitmap);
pCBmp->GetBitmap(&bm);
EmptyClipboard();
HANDLE hTemp = SetClipboardData(CF_BITMAP, hBitmap);
delete pCBmp;
}
CloseClipboard();
}
|
|