summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2016-10-09 17:21:51 (GMT)
committerPeter Wu <peter@lekensteyn.nl>2016-10-11 21:01:17 (GMT)
commit45751d7d8bc2a24abf75644d010018875c17daef (patch)
treed954d462c93e7b1c8fe772eb10736a5a3069edd8
parent45d3a0700aaa7564c5090398173a98828d38d2d4 (diff)
Fix broken previews for small selection
The use of QGraphicsDropShadowEffect in KSImageWidget enables opacity. When the previous format is RGB32, it can be converted directly to ARGB32 with no data changes (assuming that the pixel data really has the format 0xffRRGGBB). Apparently the data returned by XCB has varying values (including zero) for the alpha channel which violates the RGB32 format and results in fully transparant pictures. Explicitly set the bits to fix this. REVIEW: 129135 BUG: 362450 FIXED-IN: 16.12
-rw-r--r--src/PlatformBackends/X11ImageGrabber.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/PlatformBackends/X11ImageGrabber.cpp b/src/PlatformBackends/X11ImageGrabber.cpp
index ecc3e3a..060b68e 100644
--- a/src/PlatformBackends/X11ImageGrabber.cpp
+++ b/src/PlatformBackends/X11ImageGrabber.cpp
@@ -195,6 +195,14 @@ QPixmap X11ImageGrabber::convertFromNative(xcb_image_t *xcbImage)
return QPixmap(); // we don't know
}
+ // The RGB32 format requires data format 0xffRRGGBB, ensure that this fourth byte really is 0xff
+ if (format == QImage::Format_RGB32) {
+ quint32 *data = reinterpret_cast<quint32 *>(xcbImage->data);
+ for (int i = 0; i < xcbImage->width * xcbImage->height; i++) {
+ data[i] |= 0xff000000;
+ }
+ }
+
QImage image(xcbImage->data, xcbImage->width, xcbImage->height, format);
if (image.isNull()) {