summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-09-13 11:07:58 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-09-14 08:13:46 +0000
commit590e71a69cc74b4e7da1ccb19a1304047dbaecb8 (patch)
tree126f11c43cc86ea01bbca345ebf43f70e08cf489 /src/gui
parentb6e99ec056387e8720ef5acff824089fe585e00a (diff)
Fix convertToFormat with color-tables
The function was only well defined from RGB32 and ARGB32PM formats, this patch fixes it so it behaves well from all formats. Task-number: QTBUG-63163 Change-Id: Id892531d9aaf997b707b430196c1166493792a2a Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qimage.cpp23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index b2e5ac93b1..43b77a862d 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -2096,8 +2096,8 @@ static QImage convertWithPalette(const QImage &src, QImage::Format format,
Returns a copy of the image converted to the given \a format,
using the specified \a colorTable.
- Conversion from 32 bit to 8 bit indexed is a slow operation and
- will use a straightforward nearest color approach, with no
+ Conversion from RGB formats to indexed formats is a slow operation
+ and will use a straightforward nearest color approach, with no
dithering.
*/
QImage QImage::convertToFormat(Format format, const QVector<QRgb> &colorTable, Qt::ImageConversionFlags flags) const
@@ -2105,23 +2105,12 @@ QImage QImage::convertToFormat(Format format, const QVector<QRgb> &colorTable, Q
if (!d || d->format == format)
return *this;
- if (format <= QImage::Format_Indexed8 && depth() == 32) {
- return convertWithPalette(*this, format, colorTable);
- }
-
- const Image_Converter *converterPtr = &qimage_converter_map[d->format][format];
- Image_Converter converter = *converterPtr;
- if (!converter)
+ if (format == QImage::Format_Invalid)
return QImage();
+ if (format <= QImage::Format_Indexed8)
+ return convertWithPalette(convertToFormat(QImage::Format_ARGB32, flags), format, colorTable);
- QImage image(d->width, d->height, format);
- QIMAGE_SANITYCHECK_MEMORY(image);
-
- image.d->offset = offset();
- copyMetadata(image.d, d);
-
- converter(image.d, d, flags);
- return image;
+ return convertToFormat(format, flags);
}
/*!