summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qbmphandler.cpp
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2020-06-05 16:09:43 +0200
committerEirik Aavitsland <eirik.aavitsland@qt.io>2020-06-26 15:24:05 +0200
commit1a63409579ff0e9ce524c09701c1ef8bd2d99f25 (patch)
treed6a77e05c987fc6f6aef9f68e5a1a2f1e6731260 /src/gui/image/qbmphandler.cpp
parent5dea4fe956c452be5aae2c61dd0777fdf1efe5d0 (diff)
QImageIO: use the new allocation checker in the format handlers
Change-Id: I604d99ce476d4758a1e20b78257082911f1f1546 Task-number: QTBUG-85037 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/image/qbmphandler.cpp')
-rw-r--r--src/gui/image/qbmphandler.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp
index 625ed7c873..87f6ac2822 100644
--- a/src/gui/image/qbmphandler.cpp
+++ b/src/gui/image/qbmphandler.cpp
@@ -280,17 +280,8 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
if (bi.biHeight < 0)
h = -h; // support images with negative height
- if (image.size() != QSize(w, h) || image.format() != format) {
- image = QImage(w, h, format);
- if (image.isNull()) // could not create image
- return false;
- if (ncols)
- image.setColorCount(ncols); // Ensure valid QImage
- }
-
- image.setDotsPerMeterX(bi.biXPelsPerMeter);
- image.setDotsPerMeterY(bi.biYPelsPerMeter);
-
+ if (!QImageIOHandler::allocateImage(QSize(w, h), format, &image))
+ return false;
if (ncols > 0) { // read color table
image.setColorCount(ncols);
uchar rgb[4];
@@ -339,6 +330,9 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
blue_scale = 8;
}
+ image.setDotsPerMeterX(bi.biXPelsPerMeter);
+ image.setDotsPerMeterY(bi.biYPelsPerMeter);
+
#if 0
qDebug("Rmask: %08x Rshift: %08x Rscale:%08x", red_mask, red_shift, red_scale);
qDebug("Gmask: %08x Gshift: %08x Gscale:%08x", green_mask, green_shift, green_scale);