summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2017-05-18 15:21:16 +0200
committerEirik Aavitsland <eirik.aavitsland@qt.io>2017-08-03 09:43:12 +0000
commit8ba373361d79402be877cbd5d6dd8ec7de7d0e27 (patch)
tree1b725de71d0ba480d89bcf13b18440e567b972a7 /src
parent4f515815efc318ddc909a0399b71b8a684962f38 (diff)
Support all QImage formats in native pixmap conversion
The conversion fallback did not catch all the more recently added QImage formats, leading to corrupt pixmaps or crashes. Also alpha channels were needlessly thrown away if present. Change-Id: I38588035aa9bf37b77398489981df65201cf0340 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp b/src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp
index e59ad57c27..f791c90346 100644
--- a/src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp
+++ b/src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp
@@ -529,8 +529,11 @@ void QX11PlatformPixmap::fromImage(const QImage &img, Qt::ImageConversionFlags f
}
}
- if (d == 1 || d == 16 || d == 24 || image.format() == QImage::Format_Grayscale8) {
- image = image.convertToFormat(QImage::Format_RGB32, flags);
+ if (d == 1 || image.format() > QImage::Format_ARGB32_Premultiplied) {
+ QImage::Format fmt = QImage::Format_RGB32;
+ if (alphaCheck.hasXRenderAndAlpha() && d > 1)
+ fmt = QImage::Format_ARGB32_Premultiplied;
+ image = image.convertToFormat(fmt, flags);
fromImage(image, Qt::AutoColor);
return;
}