Meh*_*dad 1 winapi transparency gdi+ gdi visual-c++
无论我做什么,我都会在图标周围出现白色/黑色边框......是什么给出了什么?!
甚至可以正确地做到这一点吗?如何将HICON复制到具有透明度的GDI +位图?
我浪费了好几个小时.
加上我之前多次浪费了多少次,是的,这令人沮丧.
原来这是GDI +的一个问题.解决方法就在这里 ; 这里有一些可能有用的代码:
HICON hIcon = ...;
ICONINFO ii; GetIconInfo(hIcon, &ii);
BITMAP bmp; GetObject(ii.hbmColor, sizeof(bmp), &bmp);
Gdiplus::Bitmap temp(ii.hbmColor, NULL);
Gdiplus::BitmapData lockedBitmapData;
Gdiplus::Rect rc(0, 0, temp.GetWidth(), temp.GetHeight());
temp.LockBits(&rc, Gdiplus::ImageLockModeRead, temp.GetPixelFormat(), &lockedBitmapData);
Gdiplus::Bitmap image(
lockedBitmapData.Width, lockedBitmapData.Height, lockedBitmapData.Stride,
PixelFormat32bppARGB, reinterpret_cast<BYTE *>(lockedBitmapData.Scan0));
temp.UnlockBits(&lockedBitmapData);
// Now 'image' has the icon, with transparency
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1506 次 |
| 最近记录: |