aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2022-09-28 23:26:45 -0400
committerGravatar Chris Xiong <chirs241097@gmail.com> 2022-09-28 23:26:45 -0400
commit54b0bb3e4225a301188d8518bc6d26328a7a7aa2 (patch)
treecb0e9cd37a83c8406dc8df07dce671d249d4ae08
parentd120106237b4fce61f69dda28d577c1dadcbc7df (diff)
downloaddeduper-54b0bb3e4225a301188d8518bc6d26328a7a7aa2.tar.xz
Use QPixmap's downscaling when required.
-rw-r--r--qdeduper/imageitem.cpp8
1 files changed, 7 insertions, 1 deletions
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<QPixmap>();
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);