I am getting a Windows file icon via Win Api methods. Then I convert it to QT QIcon and use in my application. Everything seems to be good, but I see a little difference between my icons and those in Windows Explorer(Look at the attached image, left part is my app, right part is Windows Explorer). I think it may be related to shadows or Alpha channel. May be smb can help me to fix this?
Here is my code for obtaining an icon:
// fileInfo.hIcon obtained via SHGetFileInfo with flags SHGFI_ICON | SHGFI_SMALLICON
ICONINFO iconInfo;
if ( GetIconInfo(fileInfo.hIcon, &iconInfo) )
{
iconInfo.hbmColor,
QPixmap::fromWinHBITMAP(iconInfo.
hbmMask,
iconPixmap.setMask(iconMaskBitmap);
resultingIcon
= QIcon(iconPixmap
) ;
}
// fileInfo.hIcon obtained via SHGetFileInfo with flags SHGFI_ICON | SHGFI_SMALLICON
ICONINFO iconInfo;
if ( GetIconInfo(fileInfo.hIcon, &iconInfo) )
{
QPixmap &iconPixmap = QPixmap::fromWinHBITMAP(
iconInfo.hbmColor,
QPixmap::NoAlpha);
QBitmap iconMaskBitmap(
QPixmap::fromWinHBITMAP(iconInfo.hbmMask,
QPixmap::NoAlpha) );
iconPixmap.setMask(iconMaskBitmap);
resultingIcon = QIcon(iconPixmap) ;
}
To copy to clipboard, switch view to plain text mode
Bookmarks