summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/image/qpixmap_win.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp
index a9bcca2..87cb46c 100644
--- a/src/gui/image/qpixmap_win.cpp
+++ b/src/gui/image/qpixmap_win.cpp
@@ -393,6 +393,7 @@ QPixmap QPixmap::fromWinHICON(HICON icon)
int w = iconinfo.xHotspot * 2;
int h = iconinfo.yHotspot * 2;
+ const DWORD dwImageSize = w * h * 4;
BITMAPINFO bmi;
memset(&bmi, 0, sizeof(bmi));
@@ -402,44 +403,44 @@ QPixmap QPixmap::fromWinHICON(HICON icon)
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biSizeImage = size*size*4;
+ bmi.bmiHeader.biSizeImage = dwImageSize;
uchar* bits;
HBITMAP winBitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**) &bits, 0, 0);
if (winBitmap )
- memset(bits, 0xff, size*size*4);
+ memset(bits, 0xff, dwImageSize);
if (!winBitmap) {
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))
+ if (!DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_NORMAL))
qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()");
uint mask = 0xff000000;
// Create image and copy data into image.
- QImage image(size, size, QImage::Format_ARGB32);
+ QImage image(w, h, QImage::Format_ARGB32);
if (!image.isNull()) { // failed to alloc?
- int bytes_per_line = size * sizeof(QRgb);
- for (int y=0; y<size; ++y) {
+ int bytes_per_line = w * sizeof(QRgb);
+ for (int y=0; y < h; ++y) {
QRgb *dest = (QRgb *) image.scanLine(y);
const QRgb *src = (const QRgb *) (bits + y * bytes_per_line);
- for (int x=0; x<size; ++x) {
+ for (int x=0; x < w; ++x) {
dest[x] = src[x];
}
}
}
- if (!DrawIconEx( hdc, 0, 0, icon, size, size, 0, 0, DI_MASK))
+ if (!DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_MASK))
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) {
+ int bytes_per_line = w * sizeof(QRgb);
+ for (int y=0; y < h; ++y) {
QRgb *dest = (QRgb *) image.scanLine(y);
const QRgb *src = (const QRgb *) (bits + y * bytes_per_line);
- for (int x=0; x<size; ++x) {
+ for (int x=0; x < w; ++x) {
if (!src[x])
dest[x] = dest[x] | mask;
}