From 8ba373361d79402be877cbd5d6dd8ec7de7d0e27 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Thu, 18 May 2017 15:21:16 +0200 Subject: [PATCH] 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 Reviewed-by: Lars Knoll --- src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp | 7 +++++-- 1 file 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; }