Fix regression in reading certain compressed bmp images
authorAndy Shaw <andy.shaw@digia.com>
Tue, 7 Apr 2015 13:06:20 +0000 (15:06 +0200)
committeraavit <eirik.aavitsland@theqtcompany.com>
Thu, 20 Aug 2015 11:25:19 +0000 (11:25 +0000)
For BITFIELDS compressed images, the image data may be preceded by
bitmask fields. The file positioning code that should make sure those
were read correctly was erroneously included in the block of code that
was moved in 6f1b82fccdaf202856dcc6510c16b0531680fe23.

Task-number: QTBUG-45559
Task-number: QTBUG-40890
Done-with: Eirik Aavitsland
Change-Id: Id2b3ce078f67ac6ebf75ab0cc463dc719af83393
Reviewed-by: aavit <eirik.aavitsland@theqtcompany.com>
src/gui/image/qbmphandler.cpp

index f124cede360f88ffed68f16cb0024be3ab67f3e5..ef12b23caa6e42064a11d7c1d44fbadd93e21306 100644 (file)
@@ -212,6 +212,9 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
     int blue_scale = 0;
     int alpha_scale = 0;
 
+    if (!d->isSequential())
+        d->seek(startpos + BMP_FILEHDR_SIZE + (bi.biSize >= BMP_WIN4 ? BMP_WIN : bi.biSize)); // goto start of colormap or masks
+
     if (bi.biSize >= BMP_WIN4 || (comp == BMP_BITFIELDS && (nbits == 16 || nbits == 32))) {
         if (d->read((char *)&red_mask, sizeof(red_mask)) != sizeof(red_mask))
             return false;
@@ -299,9 +302,6 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
     image.setDotsPerMeterX(bi.biXPelsPerMeter);
     image.setDotsPerMeterY(bi.biYPelsPerMeter);
 
-    if (!d->isSequential())
-        d->seek(startpos + BMP_FILEHDR_SIZE + (bi.biSize >= BMP_WIN4? BMP_WIN : bi.biSize)); // goto start of colormap
-
     if (ncols > 0) {                                // read color table
         uchar rgb[4];
         int   rgb_len = t == BMP_OLD ? 3 : 4;