[英]HICON loaded with Gdiplus from PNG has low quality
我试图将一些PNG图像加载到WinAPI ImageList
,作为要在ListView
显示的元素的图标。 我使用Gdiplus
进行此Gdiplus
,但我Gdiplus
的问题是质量太差了。 就像颜色深度降低了一样。
这就是我的方法(在循环之前,从WinMain
调用的函数中):
HIMAGELIST hLarge;
HIMAGELIST hSmall;
hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON),
GetSystemMetrics(SM_CYICON),
ILC_MASK, 1, 1);
hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
ILC_MASK, 1, 1);
ListView_SetImageList(hWndListView, hLarge, LVSIL_NORMAL);
ListView_SetImageList(hWndListView, hSmall, LVSIL_SMALL);
HICON hIconItem
Gdiplus::Bitmap *bitmap = new Gdiplus::Bitmap(image_path, 0);
bitmap->GetHICON(&hIconItem);
ImageList_AddIcon(hSmall, hiconItem);
ImageList_AddIcon(hLarge, hiconItem);
现在,我缺少什么,图像在哪里丢失信息?
我已将ILC_MASK
更改为ILC_MASK | ILC_COLOR32
ILC_MASK | ILC_COLOR32
。 质量稍微好一点,但是没有抗锯齿。
您的PNG很可能是32位颜色。 在您的ImageList_Create()
调用中,使用标志ILC_COLOR32 | ILC_MASK
ILC_COLOR32 | ILC_MASK
,而ILC_MASK
。
根据MSDN ,如果您未指定ILC_COLORxxx
标志之一,则默认为ILC_COLOR4
,这是4位16色图形。 这说明了图像质量下降。 明确指定ILC_COLOR32
将为您提供所需的全色图标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.