summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <mbrasser@ford.com>2020-01-10 14:52:31 -0600
committerMichael Brasser <mbrasser@ford.com>2020-01-20 15:39:06 -0600
commit3e6d52b5628178c0ee1acac562403a2de7833a53 (patch)
tree3fa33371b31cdf952708423739c3be15b31a47fc
parent31338f220f1ad1d0b8c050c48b04e733c4b62e1b (diff)
Fix rendering errors with animated webp files
* Respect blend_method. * Apply dispose_method when rending the *next* frame, and only for the given frame area. Change-Id: I60a8c7010a46a2a66339c87f74927a02aee7dcf3 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
-rw-r--r--src/plugins/imageformats/webp/qwebphandler.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/plugins/imageformats/webp/qwebphandler.cpp b/src/plugins/imageformats/webp/qwebphandler.cpp
index f0b8caf..aab7aad 100644
--- a/src/plugins/imageformats/webp/qwebphandler.cpp
+++ b/src/plugins/imageformats/webp/qwebphandler.cpp
@@ -162,6 +162,7 @@ bool QWebpHandler::read(QImage *image)
if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
return false;
+ QRect prevFrameRect;
if (m_iter.frame_num == 0) {
// Read global meta-data chunks first
WebPChunkIterator metaDataIter;
@@ -177,6 +178,9 @@ bool QWebpHandler::read(QImage *image)
if (!WebPDemuxGetFrame(m_demuxer, 1, &m_iter))
return false;
} else {
+ if (m_iter.has_alpha && m_iter.dispose_method == WEBP_MUX_DISPOSE_BACKGROUND)
+ prevFrameRect = currentImageRect();
+
// Go to next frame
if (!WebPDemuxNextFrame(&m_iter))
return false;
@@ -208,8 +212,16 @@ bool QWebpHandler::read(QImage *image)
} else {
// Animation
QPainter painter(m_composited);
- if (m_features.has_alpha && m_iter.dispose_method == WEBP_MUX_DISPOSE_BACKGROUND)
- m_composited->fill(Qt::transparent);
+ if (!prevFrameRect.isEmpty()) {
+ painter.setCompositionMode(QPainter::CompositionMode_Clear);
+ painter.fillRect(prevFrameRect, Qt::black);
+ }
+ if (m_features.has_alpha) {
+ if (m_iter.blend_method == WEBP_MUX_NO_BLEND)
+ painter.setCompositionMode(QPainter::CompositionMode_Source);
+ else
+ painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
+ }
painter.drawImage(currentImageRect(), frame);
*image = *m_composited;