diff options
Diffstat (limited to 'src/gui/image/qpixmap_mac.cpp')
-rw-r--r-- | src/gui/image/qpixmap_mac.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index afa6f83..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; @@ -965,6 +969,9 @@ Qt::HANDLE QPixmap::macQDAlphaHandle() const Qt::HANDLE QPixmap::macCGHandle() const { + if (isNull()) + return 0; + if (data->classId() == QPixmapData::MacClass) { QMacPixmapData *d = static_cast<QMacPixmapData *>(data.data()); if (!d->cg_data) |