summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpixmap_mac.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2009-11-03 13:04:39 +0100
committerGunnar Sletta <gunnar@trolltech.com>2009-11-03 13:10:44 +0100
commit159350b766299fee1bfa44410c19500335267fd8 (patch)
tree59648184f1fc5a103dfabe7657426fc6e72e1524 /src/gui/image/qpixmap_mac.cpp
parent0e02c54e7e56ee091aeeb6342faa2df163fbbd74 (diff)
Fixed crash in QPixmap::fromImage with an Indexed8 without a colortable.
Reviewed-by: Trond
Diffstat (limited to 'src/gui/image/qpixmap_mac.cpp')
-rw-r--r--src/gui/image/qpixmap_mac.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp
index 15350e8ea4..9209d458aa 100644
--- a/src/gui/image/qpixmap_mac.cpp
+++ b/src/gui/image/qpixmap_mac.cpp
@@ -305,11 +305,15 @@ void QMacPixmapData::fromImage(const QImage &img,
}
break;
}
- case QImage::Format_Indexed8:
- for (int x = 0; x < w; ++x) {
- *(drow+x) = PREMUL(image.color(*(srow + x)));
+ case QImage::Format_Indexed8: {
+ int numColors = image.numColors();
+ if (numColors > 0) {
+ for (int x = 0; x < w; ++x) {
+ int index = *(srow + x);
+ *(drow+x) = PREMUL(image.color(qMin(index, numColors)));
+ }
}
- break;
+ } break;
case QImage::Format_RGB32:
for (int x = 0; x < w; ++x)
*(drow+x) = *(((quint32*)srow) + x) | 0xFF000000;