summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-06-12 15:15:50 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-06-20 11:00:52 +0000
commitc4d8be28dbf96687a9651eb287637ff535bdebb6 (patch)
treefe07a9359a1893a3cb923ca70a9c8779ebfca3b4
parentc0f586c374d6efbac2b3a25a1cb37924c70286db (diff)
downloadqtsvg-c4d8be28dbf96687a9651eb287637ff535bdebb6.tar.gz
Do not reallocate memory for QImage
If the QImage given to read() already has the right size and depth, we don't need to allocate a new image. This is consistent with other image decoders and why a QImage is provided to the method in the first place. Change-Id: I4944211d4a8d4f19d000cace4a48df505d375f52 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
-rw-r--r--src/plugins/imageformats/svg/qsvgiohandler.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/plugins/imageformats/svg/qsvgiohandler.cpp b/src/plugins/imageformats/svg/qsvgiohandler.cpp
index 0c26cb5..457c79e 100644
--- a/src/plugins/imageformats/svg/qsvgiohandler.cpp
+++ b/src/plugins/imageformats/svg/qsvgiohandler.cpp
@@ -176,7 +176,8 @@ bool QSvgIOHandler::read(QImage *image)
t.translate(tr1.x(), tr1.y());
bounds = t.mapRect(bounds);
}
- *image = QImage(finalSize, QImage::Format_ARGB32_Premultiplied);
+ if (image->size() != finalSize || !image->reinterpretAsFormat(QImage::Format_ARGB32_Premultiplied))
+ *image = QImage(finalSize, QImage::Format_ARGB32_Premultiplied);
if (!finalSize.isEmpty()) {
image->fill(d->backColor.rgba());
QPainter p(image);