[Development] Bug in qtimageformats WBMP plugin

Michał 'Khorne' Lowas-Rzechonek michalrz at socialbicycles.com
Wed Mar 15 10:04:36 CET 2017


Hi,

I know that WBMP is not a popular format since WAP is long dead, but in 
our application it's useful for transferring small bitmaps over a serial 
bus.

I've noticed there is a bug in the implementation when the bitmap 
dimensions are multiples of 128. In such cases, variable-length integer 
should be encoded as 2 bytes, not 1.

I've never contributed to Qt so I don't know where am I supposed to send 
the patch... It's actually very simple:


diff --git a/src/plugins/imageformats/wbmp/qwbmphandler.cpp 
b/src/plugins/imageformats/wbmp/qwbmphandler.cpp
index cd9b04a..d2dec87 100644
--- a/src/plugins/imageformats/wbmp/qwbmphandler.cpp
+++ b/src/plugins/imageformats/wbmp/qwbmphandler.cpp
@@ -81,6 +81,7 @@ static bool readMultiByteInt(QIODevice *iodev, quint32 
*num)

  static bool writeMultiByteInt(QIODevice *iodev, quint32 num)
  {
+    quint8 width = 1;
      quint64 tmp = num & 0x7F;
      num >>= 7;

@@ -88,13 +89,15 @@ static bool writeMultiByteInt(QIODevice *iodev, 
quint32 num)
          quint8 c = num & 0x7F;
          num = num >> 7;
          tmp = (tmp << 8) | (c | 0x80);
+        width += 1;
      }

-    while (tmp) {
+    while (width) {
          quint8 c = tmp & 0xFF;
          if (!iodev->putChar(c))
              return false;
          tmp >>= 8;
+        width -= 1;
      }
      return true;
  }

cheers
-- 
Michał 'Khorne' Lowas-Rzechonek
Social Bicycles Inc.



More information about the Development mailing list