1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
if(!OpenClipboard(NULL))
return 0;
EmptyClipboard();
Bitmap* imgSrc = new Bitmap(L"C:\\Users\\user1\\Desktop\\1.jpg");
UINT w = imgSrc->GetWidth();
UINT h = imgSrc->GetHeight();
Graphics* g = Graphics::FromImage(imgSrc);
HDC hdcSrc = g->GetHDC();
HBITMAP hbitmapSrc;
Color bgColor = Color::White;
imgSrc->GetHBITMAP(bgColor, &hbitmapSrc);
SelectObject(hdcSrc, hbitmapSrc);
BitBlt(hdcDst, 0, 0, w, h, hdcSrc, 0, 0, SRCCOPY);
HBRUSH brush = CreateSolidBrush( RGB( 255, 0, 0 ));
SelectObject( hdcDst, brush );
Rectangle( hdcDst, 100, 100, 300, 200 );
HANDLE resultH = SetClipboardData(CF_BITMAP, hbitmapDst);
Bitmap* resultB = Bitmap::FromHBITMAP((HBITMAP)resultH, NULL);
UINT wD = resultB->GetWidth();
UINT hD = resultB->GetHeight();
CloseClipboard();
g->ReleaseHDC(hdcSrc);
if(resultH == NULL)
return 0;
return 1;
|