From 54b0bb3e4225a301188d8518bc6d26328a7a7aa2 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Wed, 28 Sep 2022 23:26:45 -0400 Subject: Use QPixmap's downscaling when required. --- qdeduper/imageitem.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'qdeduper') diff --git a/qdeduper/imageitem.cpp b/qdeduper/imageitem.cpp index 896334b..ca470eb 100644 --- a/qdeduper/imageitem.cpp +++ b/qdeduper/imageitem.cpp @@ -76,7 +76,13 @@ void ImageItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt QPixmap pm = index.data(Qt::ItemDataRole::DecorationRole).value(); QSize imd = pm.size().scaled(imr.size(), Qt::AspectRatioMode::KeepAspectRatio); painter->setRenderHint(QPainter::RenderHint::SmoothPixmapTransform); - painter->drawPixmap(QRect(imr.topLeft(), imd), pm); + if (pm.size().width() > imd.width() * pm.devicePixelRatioF() || pm.size().height() > imd.height() * pm.devicePixelRatioF()) + { + QPixmap pms = pm.scaled(imd * pm.devicePixelRatioF(), Qt::AspectRatioMode::IgnoreAspectRatio, Qt::TransformationMode::SmoothTransformation); + painter->drawPixmap(QRect(imr.topLeft(), imd), pms); + } + else + painter->drawPixmap(QRect(imr.topLeft(), imd), pm); QPoint dtopright = QRect(imr.topLeft(),imd).bottomLeft(); QPoint hko = dtopright + QPoint(HKPADD, HKPADD + LINESP); -- cgit v1.2.3