Skip to content

Commit

Permalink
xbm image format: avoid uninitialized pixels for truncated data
Browse files Browse the repository at this point in the history
xbm bitmaps are conventionally accepted as valid even if there is not
enough data to fill the declared bitmap size: both ImageMagick and
GIMP do this. Qt did too, but the uncovered areas would be
uninitialized, and thus contain random junk bits. This commit adds
clearing of the full QImage data.

Task-number: QTBUG-54169
Change-Id: I84150d54d07dbd546a4947e7ec332f83f2d7ca41
Reviewed-by: Paul Olav Tvete <[email protected]>
  • Loading branch information
aavit committed Mar 22, 2017
1 parent 05a71c6 commit 901ed36
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/gui/image/qxbmhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage)
return false;
}

outImage->fill(Qt::color0); // in case the image data does not cover the full image

outImage->setColorCount(2);
outImage->setColor(0, qRgb(255,255,255)); // white
outImage->setColor(1, qRgb(0,0,0)); // black
Expand Down

0 comments on commit 901ed36

Please sign in to comment.