From 566e2a8a42b736ce1a513e332f648701af3ff6ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Thu, 13 Feb 2014 04:26:34 +0100 Subject: [PATCH] Fix QPixmapItem::PreserveAspectCrop This case was broken and would scale the image, while what we want is a centered piece, from Qt::KeepAspectRatioByExpanding. --- src/declarativeimports/qtextracomponents/qpixmapitem.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/declarativeimports/qtextracomponents/qpixmapitem.cpp b/src/declarativeimports/qtextracomponents/qpixmapitem.cpp index 46d0756cf..fcc66b5c4 100644 --- a/src/declarativeimports/qtextracomponents/qpixmapitem.cpp +++ b/src/declarativeimports/qtextracomponents/qpixmapitem.cpp @@ -114,9 +114,11 @@ void QPixmapItem::paint(QPainter *painter) break; } case PreserveAspectCrop: { - destRect = boundingRect().toRect(); - sourceRect = destRect; - sourceRect.moveCenter(m_pixmap.rect().center()); + QSize scaled = m_pixmap.size(); + + scaled.scale(boundingRect().size().toSize(), Qt::KeepAspectRatioByExpanding); + destRect = QRect(QPoint(0, 0), scaled); + destRect.moveCenter(boundingRect().center().toPoint()); break; } case TileVertically: {