summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2009-11-03 12:04:39 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2009-11-03 12:10:44 (GMT)
commit159350b766299fee1bfa44410c19500335267fd8 (patch)
tree59648184f1fc5a103dfabe7657426fc6e72e1524 /src/gui/image
parent0e02c54e7e56ee091aeeb6342faa2df163fbbd74 (diff)
downloadQt-159350b766299fee1bfa44410c19500335267fd8.zip
Qt-159350b766299fee1bfa44410c19500335267fd8.tar.gz
Qt-159350b766299fee1bfa44410c19500335267fd8.tar.bz2
Fixed crash in QPixmap::fromImage with an Indexed8 without a colortable.
Reviewed-by: Trond
Diffstat (limited to 'src/gui/image')
-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 15350e8..9209d45 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;