Resize bitmap from Clipborad?
-
What I am up to is resizing the bitmap from the clipboard then re send it to clipborad so it's kinda easy in VB take a look
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
My.Computer.Clipboard.SetImage(New Bitmap(bmp, CInt(bmp.Width / 2), CInt(bmp.Height / 2))) ' resized and pasted to Excel
End SubNo how to do this under C? So i can send the bitmap to the clipboard with these instructions
OpenClipboard(NULL);
EmptyClipboard();
SetClipboardData(CF_BITMAP, Hbitmap);
CloseClipboard();
OpenClipboard(NULL);and for bringing it
HBITMAP hbitmap = (HBITMAP)getclipboardData(CF_BITMAP)
and i know that I should use
StretchBlt()
but i do not know how to accomplice that?
-
What I am up to is resizing the bitmap from the clipboard then re send it to clipborad so it's kinda easy in VB take a look
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
My.Computer.Clipboard.SetImage(New Bitmap(bmp, CInt(bmp.Width / 2), CInt(bmp.Height / 2))) ' resized and pasted to Excel
End SubNo how to do this under C? So i can send the bitmap to the clipboard with these instructions
OpenClipboard(NULL);
EmptyClipboard();
SetClipboardData(CF_BITMAP, Hbitmap);
CloseClipboard();
OpenClipboard(NULL);and for bringing it
HBITMAP hbitmap = (HBITMAP)getclipboardData(CF_BITMAP)
and i know that I should use
StretchBlt()
but i do not know how to accomplice that?
Assume you have a
HBITMAP hbitmap
which already contains your clipboard data. Then you can StretchBlt that data to a destinationHDC hdc
as below: 1. Create a compatible HDC in memory with your destination hdcHDC memDC= CreateCompatibleDC(hdc);
2. Select your hbitmap into the memory DC
HBITMAP hOldBmp = (HBITMAP)SelectObject(memDC, hbitmap);
3. Use StretchBlt to resize it
StretchBlt(hdc, 0, 0, new_Width, new_Height, memDC, 0, 0, org_Width, org_Height, SRCCOPY);
4. Restore the old bitmap and free memory
SelectObject(memDC, hOldBmp);
DeleteDC(memDC);Hope it helps :)
-
What I am up to is resizing the bitmap from the clipboard then re send it to clipborad so it's kinda easy in VB take a look
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
My.Computer.Clipboard.SetImage(New Bitmap(bmp, CInt(bmp.Width / 2), CInt(bmp.Height / 2))) ' resized and pasted to Excel
End SubNo how to do this under C? So i can send the bitmap to the clipboard with these instructions
OpenClipboard(NULL);
EmptyClipboard();
SetClipboardData(CF_BITMAP, Hbitmap);
CloseClipboard();
OpenClipboard(NULL);and for bringing it
HBITMAP hbitmap = (HBITMAP)getclipboardData(CF_BITMAP)
and i know that I should use
StretchBlt()
but i do not know how to accomplice that?
You may use the CopyImage()[^] function:
BITMAP bm;
GetObject(hBitmap, sizeof(bm), &bm);
HBITMAP hCopy = (HBITMAP)CopyImage(hBitmap, IMAGE_BITMAP,
bm.bmWidth / 2, bm.bmHeight / 2,
LR_COPYDELETEORG);
SetClipboardData(CF_BITMAP, hCopy); -
Assume you have a
HBITMAP hbitmap
which already contains your clipboard data. Then you can StretchBlt that data to a destinationHDC hdc
as below: 1. Create a compatible HDC in memory with your destination hdcHDC memDC= CreateCompatibleDC(hdc);
2. Select your hbitmap into the memory DC
HBITMAP hOldBmp = (HBITMAP)SelectObject(memDC, hbitmap);
3. Use StretchBlt to resize it
StretchBlt(hdc, 0, 0, new_Width, new_Height, memDC, 0, 0, org_Width, org_Height, SRCCOPY);
4. Restore the old bitmap and free memory
SelectObject(memDC, hOldBmp);
DeleteDC(memDC);Hope it helps :)
-
You may use the CopyImage()[^] function:
BITMAP bm;
GetObject(hBitmap, sizeof(bm), &bm);
HBITMAP hCopy = (HBITMAP)CopyImage(hBitmap, IMAGE_BITMAP,
bm.bmWidth / 2, bm.bmHeight / 2,
LR_COPYDELETEORG);
SetClipboardData(CF_BITMAP, hCopy);