From 7f8da2179b7542375d9cf472b74bb8c2b83435f1 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 27 Apr 2015 14:12:34 +0200 Subject: [PATCH] Convert opaque indexed images over RGB32 There is no reason to use the more expensive ARGB32 conversions when there is no alpha channel involved. Change-Id: Ifcb325352b8c806ef755db385121a2939c5825b2 Reviewed-by: Gunnar Sletta --- src/gui/image/qimage.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 7b558bf4dd..1bbbc3e1f2 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1993,9 +1993,12 @@ QImage QImage::convertToFormat_helper(Format format, Qt::ImageConversionFlags fl return image; } - // Convert indexed formats over ARGB32 to the final format. - Q_ASSERT(format != QImage::Format_ARGB32); - Q_ASSERT(d->format != QImage::Format_ARGB32); + // Convert indexed formats over ARGB32 or RGB32 to the final format. + Q_ASSERT(format != QImage::Format_ARGB32 && format != QImage::Format_RGB32); + Q_ASSERT(d->format != QImage::Format_ARGB32 && d->format != QImage::Format_RGB32); + + if (!hasAlphaChannel()) + return convertToFormat(Format_RGB32, flags).convertToFormat(format, flags); return convertToFormat(Format_ARGB32, flags).convertToFormat(format, flags); } @@ -4612,8 +4615,7 @@ bool QImageData::convertInPlace(QImage::Format newFormat, Qt::ImageConversionFla if (ref.load() > 1 || ro_data) return false; - const InPlace_Image_Converter *const converterPtr = &qimage_inplace_converter_map[format][newFormat]; - InPlace_Image_Converter converter = *converterPtr; + InPlace_Image_Converter converter = qimage_inplace_converter_map[format][newFormat]; if (converter) return converter(this, flags); else if (format > QImage::Format_Indexed8 && newFormat > QImage::Format_Indexed8 && !qimage_converter_map[format][newFormat])