From a0526044efe9c774b12ef6923336754e207c7586 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Tue, 26 Apr 2022 16:46:25 +0200 Subject: [PATCH] Fix scaling of animated images in fullscreen image viewer --- src/ui/MxcAnimatedImage.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ui/MxcAnimatedImage.cpp b/src/ui/MxcAnimatedImage.cpp index b8e707bb..2f3af137 100644 --- a/src/ui/MxcAnimatedImage.cpp +++ b/src/ui/MxcAnimatedImage.cpp @@ -153,8 +153,11 @@ MxcAnimatedImage::geometryChanged(const QRectF &newGeometry, const QRectF &oldGe QQuickItem::geometryChanged(newGeometry, oldGeometry); if (newGeometry.size() != oldGeometry.size()) { - if (height() != 0 && width() != 0) - movie.setScaledSize(newGeometry.size().toSize()); + if (height() != 0 && width() != 0) { + QSizeF r = movie.scaledSize(); + r.scale(newGeometry.size(), Qt::KeepAspectRatio); + movie.setScaledSize(r.toSize()); + } } } @@ -184,7 +187,10 @@ MxcAnimatedImage::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeD return nullptr; } - n->setRect(0, 0, width(), height()); + QSizeF r = img.size(); + r.scale(size(), Qt::KeepAspectRatio); + + n->setRect((width() - r.width()) / 2, (height() - r.height()) / 2, r.width(), r.height()); n->setFiltering(QSGTexture::Linear); n->setMipmapFiltering(QSGTexture::None);