diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-06-12 15:15:50 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-06-20 11:00:52 +0000 |
commit | c4d8be28dbf96687a9651eb287637ff535bdebb6 (patch) | |
tree | fe07a9359a1893a3cb923ca70a9c8779ebfca3b4 /src | |
parent | c0f586c374d6efbac2b3a25a1cb37924c70286db (diff) | |
download | qtsvg-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>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/imageformats/svg/qsvgiohandler.cpp | 3 |
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); |