Fix scaling of animated images in fullscreen image viewer

This commit is contained in:
Nicolas Werner 2022-04-26 16:46:25 +02:00
parent cbe2d784f6
commit a0526044ef
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -153,8 +153,11 @@ MxcAnimatedImage::geometryChanged(const QRectF &newGeometry, const QRectF &oldGe
QQuickItem::geometryChanged(newGeometry, oldGeometry); QQuickItem::geometryChanged(newGeometry, oldGeometry);
if (newGeometry.size() != oldGeometry.size()) { if (newGeometry.size() != oldGeometry.size()) {
if (height() != 0 && width() != 0) if (height() != 0 && width() != 0) {
movie.setScaledSize(newGeometry.size().toSize()); 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; 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->setFiltering(QSGTexture::Linear);
n->setMipmapFiltering(QSGTexture::None); n->setMipmapFiltering(QSGTexture::None);