diff options
-rw-r--r-- | src/gui/image/qbmphandler.cpp | 31 | ||||
-rw-r--r-- | src/gui/image/qimage.cpp | 22 | ||||
-rw-r--r-- | src/gui/image/qppmhandler.cpp | 30 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 26 |
4 files changed, 31 insertions, 78 deletions
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 5de2e7831f..21c1a2f813 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -784,28 +784,19 @@ bool QBmpHandler::write(const QImage &img) QImage image; switch (img.format()) { - case QImage::Format_ARGB8565_Premultiplied: - case QImage::Format_ARGB8555_Premultiplied: - case QImage::Format_ARGB6666_Premultiplied: - case QImage::Format_ARGB4444_Premultiplied: - case QImage::Format_RGBA8888: - case QImage::Format_RGBA8888_Premultiplied: - case QImage::Format_A2BGR30_Premultiplied: - case QImage::Format_A2RGB30_Premultiplied: - image = img.convertToFormat(QImage::Format_ARGB32); - break; - case QImage::Format_RGB16: - case QImage::Format_RGB888: - case QImage::Format_RGB666: - case QImage::Format_RGB555: - case QImage::Format_RGB444: - case QImage::Format_RGBX8888: - case QImage::Format_BGR30: - case QImage::Format_RGB30: - image = img.convertToFormat(QImage::Format_RGB32); + case QImage::Format_Mono: + case QImage::Format_MonoLSB: + case QImage::Format_Indexed8: + case QImage::Format_RGB32: + case QImage::Format_ARGB32: + image = img; break; default: - image = img; + if (img.hasAlphaChannel()) + image = img.convertToFormat(QImage::Format_ARGB32); + else + image = img.convertToFormat(QImage::Format_RGB32); + break; } QIODevice *d = device(); diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index df4bedc3cd..4e10b4cb4b 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4151,22 +4151,16 @@ QImage QImage::alphaChannel() const */ bool QImage::hasAlphaChannel() const { - return d && (d->format == Format_ARGB32_Premultiplied - || d->format == Format_ARGB32 - || d->format == Format_ARGB8565_Premultiplied - || d->format == Format_ARGB8555_Premultiplied - || d->format == Format_ARGB6666_Premultiplied - || d->format == Format_ARGB4444_Premultiplied - || d->format == Format_RGBA8888 - || d->format == Format_RGBA8888_Premultiplied - || d->format == Format_A2BGR30_Premultiplied - || d->format == Format_A2RGB30_Premultiplied - || (d->has_alpha_clut && (d->format == Format_Indexed8 - || d->format == Format_Mono - || d->format == Format_MonoLSB))); + if (!d) + return false; + const QPixelFormat format = pixelFormat(); + if (format.alphaUsage() == QPixelFormat::UsesAlpha) + return true; + if (format.colorModel() == QPixelFormat::Indexed) + return d->has_alpha_clut; + return false; } - /*! \since 4.7 Returns the number of bit planes in the image. diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp index a436d10800..314abca9f0 100644 --- a/src/gui/image/qppmhandler.cpp +++ b/src/gui/image/qppmhandler.cpp @@ -257,31 +257,21 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy if (format == "pbm") { image = image.convertToFormat(QImage::Format_Mono); - } else if (image.depth() == 1) { - image = image.convertToFormat(QImage::Format_Indexed8); } else { switch (image.format()) { - case QImage::Format_RGB16: - case QImage::Format_RGB666: - case QImage::Format_RGB555: - case QImage::Format_RGB888: - case QImage::Format_RGB444: - case QImage::Format_RGBX8888: - case QImage::Format_BGR30: - case QImage::Format_RGB30: - image = image.convertToFormat(QImage::Format_RGB32); + case QImage::Format_Mono: + case QImage::Format_MonoLSB: + image = image.convertToFormat(QImage::Format_Indexed8); break; - case QImage::Format_ARGB8565_Premultiplied: - case QImage::Format_ARGB6666_Premultiplied: - case QImage::Format_ARGB8555_Premultiplied: - case QImage::Format_ARGB4444_Premultiplied: - case QImage::Format_RGBA8888: - case QImage::Format_RGBA8888_Premultiplied: - case QImage::Format_A2BGR30_Premultiplied: - case QImage::Format_A2RGB30_Premultiplied: - image = image.convertToFormat(QImage::Format_ARGB32); + case QImage::Format_Indexed8: + case QImage::Format_RGB32: + case QImage::Format_ARGB32: break; default: + if (image.hasAlphaChannel()) + image = image.convertToFormat(QImage::Format_ARGB32); + else + image = image.convertToFormat(QImage::Format_RGB32); break; } } diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 97fde57106..322bff9b57 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -407,36 +407,14 @@ void QRasterPaintEngine::init() case QImage::Format_Mono: d->mono_surface = true; break; - case QImage::Format_ARGB8565_Premultiplied: - case QImage::Format_ARGB8555_Premultiplied: - case QImage::Format_ARGB6666_Premultiplied: - case QImage::Format_ARGB4444_Premultiplied: - case QImage::Format_ARGB32_Premultiplied: - case QImage::Format_ARGB32: - case QImage::Format_RGBA8888_Premultiplied: - case QImage::Format_RGBA8888: - case QImage::Format_A2BGR30_Premultiplied: - case QImage::Format_A2RGB30_Premultiplied: - gccaps |= PorterDuff; - break; - case QImage::Format_RGB32: - case QImage::Format_RGB444: - case QImage::Format_RGB555: - case QImage::Format_RGB666: - case QImage::Format_RGB888: - case QImage::Format_RGB16: - case QImage::Format_RGBX8888: - case QImage::Format_BGR30: - case QImage::Format_RGB30: - break; default: + if (QImage::toPixelFormat(format).alphaUsage() == QPixelFormat::UsesAlpha) + gccaps |= PorterDuff; break; } } - - /*! Destroys this paint engine. */ |