summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorminiak <milan.burda@gmail.com>2009-09-22 08:33:30 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2009-09-22 08:33:30 (GMT)
commite689e41ad1baad65d90866eefe88a96f5e16fa04 (patch)
tree1914948c3416a725ff243b2ee5b09a4d04d8321d /src/gui/image
parentac7fca3606d1a7dd5985b6fc284c40c0f2682fe5 (diff)
downloadQt-e689e41ad1baad65d90866eefe88a96f5e16fa04.zip
Qt-e689e41ad1baad65d90866eefe88a96f5e16fa04.tar.gz
Qt-e689e41ad1baad65d90866eefe88a96f5e16fa04.tar.bz2
Cleanup convertHIconToPixmap() & loadIconFromShell32()
Replace convertHIconToPixmap() by QPixmap::fromWinHICON() Move loadIconFromShell32() to qwindowsstyle.cpp Merge-request: 1570 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qpixmap_win.cpp50
-rw-r--r--src/gui/image/qpixmapdata_p.h9
2 files changed, 16 insertions, 43 deletions
diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp
index 7f0c8e3..a9bcca2 100644
--- a/src/gui/image/qpixmap_win.cpp
+++ b/src/gui/image/qpixmap_win.cpp
@@ -274,11 +274,6 @@ HICON QPixmap::toWinHICON() const
return hIcon;
}
-QPixmap QPixmap::fromWinHICON(HICON icon)
-{
- return convertHIconToPixmap(icon);
-}
-
#ifdef Q_WS_WIN
#ifndef Q_WS_WINCE
@@ -316,7 +311,7 @@ static QImage qt_fromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h)
return image;
}
-QPixmap convertHIconToPixmap( const HICON icon)
+QPixmap QPixmap::fromWinHICON(HICON icon)
{
bool foundAlpha = false;
HDC screenDevice = GetDC(0);
@@ -326,7 +321,7 @@ QPixmap convertHIconToPixmap( const HICON icon)
ICONINFO iconinfo;
bool result = GetIconInfo(icon, &iconinfo); //x and y Hotspot describes the icon center
if (!result)
- qWarning("convertHIconToPixmap(), failed to GetIconInfo()");
+ qWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()");
int w = iconinfo.xHotspot * 2;
int h = iconinfo.yHotspot * 2;
@@ -385,19 +380,25 @@ QPixmap convertHIconToPixmap( const HICON icon)
return QPixmap::fromImage(image);
}
#else //ifndef Q_WS_WINCE
-QPixmap convertHIconToPixmap( const HICON icon, bool large)
+QPixmap QPixmap::fromWinHICON(HICON icon)
{
HDC screenDevice = GetDC(0);
HDC hdc = CreateCompatibleDC(screenDevice);
ReleaseDC(0, screenDevice);
- int size = large ? 64 : 32;
+ ICONINFO iconinfo;
+ bool result = GetIconInfo(icon, &iconinfo); //x and y Hotspot describes the icon center
+ if (!result)
+ qWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()");
+
+ int w = iconinfo.xHotspot * 2;
+ int h = iconinfo.yHotspot * 2;
BITMAPINFO bmi;
memset(&bmi, 0, sizeof(bmi));
bmi.bmiHeader.biSize = sizeof(BITMAPINFO);
- bmi.bmiHeader.biWidth = size;
- bmi.bmiHeader.biHeight = -size;
+ bmi.bmiHeader.biWidth = w;
+ bmi.bmiHeader.biHeight = -h;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
@@ -409,13 +410,13 @@ QPixmap convertHIconToPixmap( const HICON icon, bool large)
if (winBitmap )
memset(bits, 0xff, size*size*4);
if (!winBitmap) {
- qWarning("convertHIconToPixmap(), failed to CreateDIBSection()");
+ qWarning("QPixmap::fromWinHICON(), failed to CreateDIBSection()");
return QPixmap();
}
HGDIOBJ oldhdc = (HBITMAP)SelectObject(hdc, winBitmap);
if (!DrawIconEx( hdc, 0, 0, icon, size, size, 0, 0, DI_NORMAL))
- qWarning("convertHIconToPixmap(), failed to DrawIcon()");
+ qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()");
uint mask = 0xff000000;
// Create image and copy data into image.
@@ -432,7 +433,7 @@ QPixmap convertHIconToPixmap( const HICON icon, bool large)
}
}
if (!DrawIconEx( hdc, 0, 0, icon, size, size, 0, 0, DI_MASK))
- qWarning("convertHIconToPixmap(), failed to DrawIcon()");
+ qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()");
if (!image.isNull()) { // failed to alloc?
int bytes_per_line = size * sizeof(QRgb);
for (int y=0; y<size; ++y) {
@@ -450,25 +451,6 @@ QPixmap convertHIconToPixmap( const HICON icon, bool large)
return QPixmap::fromImage(image);
}
#endif //ifndef Q_WS_WINCE
-
-QPixmap loadIconFromShell32( int resourceId, int size )
-{
-#ifdef Q_OS_WINCE
- HMODULE hmod = LoadLibrary(L"ceshell.dll");
-#else
- HMODULE hmod = LoadLibrary(L"shell32.dll");
-#endif
- if( hmod ) {
- HICON iconHandle = (HICON)LoadImage(hmod, MAKEINTRESOURCE(resourceId), IMAGE_ICON, size, size, 0);
- if( iconHandle ) {
- QPixmap iconpixmap = convertHIconToPixmap( iconHandle );
- DestroyIcon(iconHandle);
- return iconpixmap;
- }
- }
- return QPixmap();
-}
-
-#endif
+#endif //ifdef Q_WS_WIN
QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h
index bac5065..5920a06 100644
--- a/src/gui/image/qpixmapdata_p.h
+++ b/src/gui/image/qpixmapdata_p.h
@@ -141,15 +141,6 @@ private:
uint is_cached;
};
-#ifdef Q_WS_WIN
-#ifndef Q_WS_WINCE
-QPixmap convertHIconToPixmap( const HICON icon);
-#else
-QPixmap convertHIconToPixmap( const HICON icon, bool large = false);
-#endif
-QPixmap loadIconFromShell32( int resourceId, int size );
-#endif
-
# define QT_XFORM_TYPE_MSBFIRST 0
# define QT_XFORM_TYPE_LSBFIRST 1
# if defined(Q_WS_WIN)