Paste P243

Image smoothing refactoring
ActivePublic

Authored by rkflx on Jul 21 2018, 10:52 PM.
diff --git a/lib/documentview/rasterimageview.cpp b/lib/documentview/rasterimageview.cpp
index f4290f1c..53e56b3e 100644
--- a/lib/documentview/rasterimageview.cpp
+++ b/lib/documentview/rasterimageview.cpp
@@ -365,13 +365,7 @@ void RasterImageView::updateFromScaler(int zoomedImageLeft, int zoomedImageTop,
void RasterImageView::onZoomChanged()
{
- // If we zoom more than twice, then assume the user wants to see the real
- // pixels, for example to fine tune a crop operation
- if (zoom() < 4.) {
- d->mScaler->setTransformationMode(Qt::SmoothTransformation);
- } else {
- d->mScaler->setTransformationMode(Qt::FastTransformation);
- }
+ d->mScaler->setZoom(zoom());
if (!d->mUpdateTimer->isActive()) {
updateBuffer();
}
@@ -460,7 +454,6 @@ void RasterImageView::resizeEvent(QGraphicsSceneResizeEvent* event)
void RasterImageView::updateBuffer(const QRegion& region)
{
d->mUpdateTimer->stop();
- d->mScaler->setZoom(zoom());
if (region.isEmpty()) {
d->setScalerRegionToVisibleRect();
} else {
diff --git a/lib/imagescaler.cpp b/lib/imagescaler.cpp
index 833f6ccd..239eac38 100644
--- a/lib/imagescaler.cpp
+++ b/lib/imagescaler.cpp
@@ -82,12 +82,12 @@ void ImageScaler::setDocument(Document::Ptr document)
void ImageScaler::setZoom(qreal zoom)
{
- d->mZoom = zoom;
-}
+ // If we zoom more than twice, then assume the user wants to see the real
+ // pixels, for example to fine tune a crop operation
+ d->mTransformationMode = zoom < 4. ? Qt::SmoothTransformation
+ : Qt::FastTransformation;
-void ImageScaler::setTransformationMode(Qt::TransformationMode mode)
-{
- d->mTransformationMode = mode;
+ d->mZoom = zoom;
}
void ImageScaler::setDestinationRegion(const QRegion& region)
diff --git a/lib/imagescaler.h b/lib/imagescaler.h
index 8684e0d0..bf919987 100644
--- a/lib/imagescaler.h
+++ b/lib/imagescaler.h
@@ -49,8 +49,6 @@ public:
void setZoom(qreal);
void setDestinationRegion(const QRegion&);
- void setTransformationMode(Qt::TransformationMode);
-
Q_SIGNALS:
void scaledRect(int left, int top, const QImage&);
diff --git a/tests/auto/imagescalertest.cpp b/tests/auto/imagescalertest.cpp
index 033dcf30..fdcc9534 100644
--- a/tests/auto/imagescalertest.cpp
+++ b/tests/auto/imagescalertest.cpp
@@ -61,7 +61,8 @@ void ImageScalerTest::testScaleFullImage()
QImage scaledImage = client.createFullImage();
- QImage expectedImage = doc->image().scaled(doc->size() * zoom);
+ QImage expectedImage = doc->image().scaled(doc->size() * zoom,
+ Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
QVERIFY(TestUtils::imageCompare(scaledImage, expectedImage));
}
rkflx edited the content of this paste. (Show Details)Jul 21 2018, 10:52 PM
rkflx changed the title of this paste from untitled to Image smoothing refactoring.