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 <daniel.teske@digia.com>
This commit is contained in:
Alessandro Portale
2014-07-24 16:29:40 +02:00
parent 49707ff3f0
commit 3efa2cf964

View File

@@ -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<QGraphicsPixmapItem *>(d->imageItem))
pixmapItem->setTransformationMode(
transform().m11() < 1 ? Qt::SmoothTransformation : Qt::FastTransformation);
}
void ImageView::updatePixmap(const QRect &rect)