| |

VerySource

 Forgot password?
 Register
Search
View: 624|Reply: 2

Ask a simple question

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-24 08:40:01
| Show all posts |Read mode
I have a bitmap in the clipboard, and I want to reduce it to 1/5 size (that is, copy the bitmap into a VC program, then manipulate the HBitmap, and then copy it back to the clipboard. How can I achieve this?
Reply

Use magic Report

0

Threads

24

Posts

19.00

Credits

Newbie

Rank: 1

Credits
19.00

 Korea, Republic of

Post time: 2020-2-9 16:30:01
| Show all posts
GetClipboardData => Bitmap process => SetClipboardData
Reply

Use magic Report

0

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-29 10:00:01
| Show all posts
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 ();
}
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list