summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@nokia.com>2009-09-22 16:10:07 (GMT)
committerJoerg Bornemann <joerg.bornemann@nokia.com>2009-09-22 16:12:38 (GMT)
commit285addaaa632ebfd3bc6bdccbe8b114c0bb83882 (patch)
treec28daeddb3634404c5ac5cfc11d22a23de9978a3 /src/gui/image
parent2fafc136542a4aea51d1aee3e0d07374b1f52b41 (diff)
downloadQt-285addaaa632ebfd3bc6bdccbe8b114c0bb83882.zip
Qt-285addaaa632ebfd3bc6bdccbe8b114c0bb83882.tar.gz
Qt-285addaaa632ebfd3bc6bdccbe8b114c0bb83882.tar.bz2
fix QPixmap::fromWinHICON for Windows CE mobile
On WinCE GetIconInfo returns a 0 hotspot for the system icons, thus we cannot use this value to determine width / height of the icon. Instead, we use the icon's bitmap to get this information.
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qpixmap_win.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp
index 87cb46c..1b61484 100644
--- a/src/gui/image/qpixmap_win.cpp
+++ b/src/gui/image/qpixmap_win.cpp
@@ -387,12 +387,29 @@ QPixmap QPixmap::fromWinHICON(HICON icon)
ReleaseDC(0, screenDevice);
ICONINFO iconinfo;
- bool result = GetIconInfo(icon, &iconinfo); //x and y Hotspot describes the icon center
+ bool result = GetIconInfo(icon, &iconinfo);
if (!result)
qWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()");
- int w = iconinfo.xHotspot * 2;
- int h = iconinfo.yHotspot * 2;
+ int w = 0;
+ int h = 0;
+ if (!iconinfo.xHotspot || !iconinfo.yHotspot) {
+ // We could not retrieve the icon size via GetIconInfo,
+ // so we try again using the icon bitmap.
+ BITMAP bm;
+ int result = GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bm);
+ if (!result) result = GetObject(iconinfo.hbmMask, sizeof(BITMAP), &bm);
+ if (!result) {
+ qWarning("QPixmap::fromWinHICON(), failed to retrieve icon size");
+ return QPixmap();
+ }
+ w = bm.bmWidth;
+ h = bm.bmHeight;
+ } else {
+ // x and y Hotspot describes the icon center
+ w = iconinfo.xHotspot * 2;
+ h = iconinfo.yHotspot * 2;
+ }
const DWORD dwImageSize = w * h * 4;
BITMAPINFO bmi;