diff options
Diffstat (limited to 'src/gui/image/qimage_p.h')
-rw-r--r-- | src/gui/image/qimage_p.h | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index eb44a0190d..b272377fb2 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -249,14 +249,38 @@ inline QImage::Format qt_opaqueVersion(QImage::Format format) return QImage::Format_RGBX64; case QImage::Format_ARGB32_Premultiplied: case QImage::Format_ARGB32: - default: return QImage::Format_RGB32; + case QImage::Format_RGB16: + case QImage::Format_RGB32: + case QImage::Format_RGB444: + case QImage::Format_RGB555: + case QImage::Format_RGB666: + case QImage::Format_RGB888: + case QImage::Format_BGR888: + case QImage::Format_RGBX8888: + case QImage::Format_BGR30: + case QImage::Format_RGB30: + case QImage::Format_RGBX64: + case QImage::Format_Grayscale8: + case QImage::Format_Grayscale16: + return format; + case QImage::Format_Mono: + case QImage::Format_MonoLSB: + case QImage::Format_Indexed8: + case QImage::Format_Alpha8: + case QImage::Format_Invalid: + case QImage::NImageFormats: + break; } + return QImage::Format_RGB32; } inline QImage::Format qt_alphaVersion(QImage::Format format) { switch (format) { + case QImage::Format_RGB32: + case QImage::Format_ARGB32: + return QImage::Format_ARGB32_Premultiplied; case QImage::Format_RGB16: return QImage::Format_ARGB8565_Premultiplied; case QImage::Format_RGB555: @@ -266,14 +290,35 @@ inline QImage::Format qt_alphaVersion(QImage::Format format) case QImage::Format_RGB444: return QImage::Format_ARGB4444_Premultiplied; case QImage::Format_RGBX8888: + case QImage::Format_RGBA8888: return QImage::Format_RGBA8888_Premultiplied; case QImage::Format_BGR30: return QImage::Format_A2BGR30_Premultiplied; case QImage::Format_RGB30: return QImage::Format_A2RGB30_Premultiplied; case QImage::Format_RGBX64: + case QImage::Format_RGBA64: + case QImage::Format_Grayscale16: return QImage::Format_RGBA64_Premultiplied; - default: + case QImage::Format_ARGB32_Premultiplied: + case QImage::Format_ARGB8565_Premultiplied: + case QImage::Format_ARGB8555_Premultiplied: + case QImage::Format_ARGB6666_Premultiplied: + case QImage::Format_ARGB4444_Premultiplied: + case QImage::Format_RGBA8888_Premultiplied: + case QImage::Format_A2BGR30_Premultiplied: + case QImage::Format_A2RGB30_Premultiplied: + case QImage::Format_RGBA64_Premultiplied: + return format; + case QImage::Format_Mono: + case QImage::Format_MonoLSB: + case QImage::Format_Indexed8: + case QImage::Format_RGB888: + case QImage::Format_BGR888: + case QImage::Format_Alpha8: + case QImage::Format_Grayscale8: + case QImage::Format_Invalid: + case QImage::NImageFormats: break; } return QImage::Format_ARGB32_Premultiplied; @@ -310,7 +355,11 @@ inline QImage::Format qt_maybeAlphaVersionWithSameDepth(QImage::Format format) inline QImage::Format qt_opaqueVersionForPainting(QImage::Format format) { - return qt_opaqueVersion(format); + QImage::Format toFormat = qt_opaqueVersion(format); + // If we are switching depth anyway upgrade to RGB32 + if (qt_depthForFormat(format) != qt_depthForFormat(toFormat) && qt_depthForFormat(toFormat) <= 32) + toFormat = QImage::Format_RGB32; + return toFormat; } inline QImage::Format qt_alphaVersionForPainting(QImage::Format format) @@ -318,7 +367,7 @@ inline QImage::Format qt_alphaVersionForPainting(QImage::Format format) QImage::Format toFormat = qt_alphaVersion(format); #if defined(__ARM_NEON__) || defined(__SSE2__) // If we are switching depth anyway and we have optimized ARGB32PM routines, upgrade to that. - if (qt_depthForFormat(format) != qt_depthForFormat(toFormat)) + if (qt_depthForFormat(format) != qt_depthForFormat(toFormat) && qt_depthForFormat(toFormat) <= 32) toFormat = QImage::Format_ARGB32_Premultiplied; #endif return toFormat; |