From 3efa2cf9641d29a11fceac309fffbe6b47263f01 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 24 Jul 2014 16:29:40 +0200 Subject: [PATCH] ImageViewer: No interpolation when zooming in The imageViewer currently always renders the images smooth/interpolated. When loading an image in an IDE and zooming in, I usually do that in order to examine the details on pixel level. Therefore, I believe that smoothing/interpolation should be turned off with a scalefactor >= 1. This patch does that for images and movies. Svg files remain always smooth. Change-Id: I327583b1f46132d179a1e0425f146106d962377b Reviewed-by: Daniel Teske --- src/plugins/imageviewer/imageview.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/imageviewer/imageview.cpp b/src/plugins/imageviewer/imageview.cpp index 0767a68eb32..8659344133a 100644 --- a/src/plugins/imageviewer/imageview.cpp +++ b/src/plugins/imageviewer/imageview.cpp @@ -69,7 +69,8 @@ public: void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) { - painter->setRenderHint(QPainter::SmoothPixmapTransform, true); + const bool smoothTransform = painter->worldTransform().m11() < 1; + painter->setRenderHint(QPainter::SmoothPixmapTransform, smoothTransform); painter->drawPixmap(offset(), m_movie->currentPixmap()); } @@ -257,6 +258,9 @@ void ImageView::doScale(qreal factor) scale(actualFactor, actualFactor); emitScaleFactor(); + if (QGraphicsPixmapItem *pixmapItem = dynamic_cast(d->imageItem)) + pixmapItem->setTransformationMode( + transform().m11() < 1 ? Qt::SmoothTransformation : Qt::FastTransformation); } void ImageView::updatePixmap(const QRect &rect)