OSDN Git Service

special-case QImage::Format_RGB16 with different bytes per line
authorIvailo Monev <xakepa10@gmail.com>
Fri, 18 Nov 2022 18:21:18 +0000 (20:21 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Fri, 18 Nov 2022 18:21:18 +0000 (20:21 +0200)
for some reason on Debian XImage with depth equal to 16 can have different
bytes per line (off by 2 bits), on Arch it was not a thing when I tested
it so it could be a bug in X

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/gui/kernel/qt_x11.cpp

index 56f5f23..9c0a2ec 100644 (file)
@@ -57,9 +57,19 @@ void QX11Data::copyQImageToXImage(const QImage &image, XImage *ximage, bool *fre
     const int w = image.width();
     const int h = image.height();
     // same bytes per line, same byte order
-    if (samebpl && samebyteorder) {
+    if (samedepth && samebyteorder) {
         switch(image.format()) {
-            case QImage::Format_RGB32: {
+            case QImage::Format_RGB16: {
+                quint16 *xidata = (quint16 *)ximage->data;
+                for (int y = 0; y < h; ++y) {
+                    const quint16 *p = (const quint16 *) image.constScanLine(y);
+                    for (int x = 0; x < w; ++x) {
+                        *xidata++ = p[x];
+                    }
+                }
+                return;
+            }
+           case QImage::Format_RGB32: {
                 uint *xidata = (uint *)ximage->data;
                 for (int y = 0; y < h; ++y) {
                     const QRgb *p = (const QRgb *) image.constScanLine(y);