@@ -305,7 +305,7 @@ void QVGraphicsView::zoomAbsolute(const qreal absoluteLevel, const QPoint &pos)
305
305
}
306
306
else
307
307
{
308
- setTransformScale (absoluteLevel / appliedDpiAdjustment);
308
+ setTransformScale (absoluteLevel * appliedDpiAdjustment);
309
309
}
310
310
zoomLevel = absoluteLevel;
311
311
@@ -349,7 +349,7 @@ void QVGraphicsView::applyExpensiveScaling()
349
349
350
350
// Calculate scaled resolution
351
351
const qreal dpiAdjustment = getDpiAdjustment ();
352
- const QSizeF mappedSize = QSizeF (getCurrentFileDetails ().loadedPixmapSize ) * zoomLevel * ( devicePixelRatioF () / dpiAdjustment );
352
+ const QSizeF mappedSize = QSizeF (getCurrentFileDetails ().loadedPixmapSize ) * zoomLevel * dpiAdjustment * devicePixelRatioF ( );
353
353
354
354
// Set image to scaled version
355
355
loadedPixmapItem->setPixmap (imageCore.scaleExpensively (mappedSize));
@@ -371,7 +371,7 @@ void QVGraphicsView::removeExpensiveScaling()
371
371
372
372
// Set appropriate scale factor
373
373
const qreal dpiAdjustment = getDpiAdjustment ();
374
- const qreal newTransformScale = zoomLevel / dpiAdjustment;
374
+ const qreal newTransformScale = zoomLevel * dpiAdjustment;
375
375
setTransformScale (newTransformScale);
376
376
appliedDpiAdjustment = dpiAdjustment;
377
377
appliedExpensiveScaleZoomLevel = 0.0 ;
@@ -580,7 +580,7 @@ void QVGraphicsView::goToFile(const GoToFileMode &mode, int index)
580
580
581
581
QSizeF QVGraphicsView::getEffectiveOriginalSize () const
582
582
{
583
- return getTransformWithNoScaling ().mapRect (QRectF (QPoint (), getCurrentFileDetails ().loadedPixmapSize )).size () / getDpiAdjustment ();
583
+ return getTransformWithNoScaling ().mapRect (QRectF (QPoint (), getCurrentFileDetails ().loadedPixmapSize )).size () * getDpiAdjustment ();
584
584
}
585
585
586
586
LogicalPixelFitter QVGraphicsView::getPixelFitter () const
@@ -596,7 +596,7 @@ QRect QVGraphicsView::getContentRect() const
596
596
// the process of zooming in and haven't re-applied the expensive scaling yet. If that's the case, callers need
597
597
// to know what the content rect will be once the dust settles rather than what's being temporarily displayed.
598
598
const QRectF loadedPixmapBoundingRect = QRectF (QPoint (), getCurrentFileDetails ().loadedPixmapSize );
599
- const qreal effectiveTransformScale = zoomLevel / appliedDpiAdjustment;
599
+ const qreal effectiveTransformScale = zoomLevel * appliedDpiAdjustment;
600
600
const QTransform effectiveTransform = getTransformWithNoScaling ().scale (effectiveTransformScale, effectiveTransformScale);
601
601
const QRectF contentRect = effectiveTransform.mapRect (loadedPixmapBoundingRect);
602
602
const QSize snappedSize = getPixelFitter ().snapSize (contentRect.size ());
@@ -636,7 +636,11 @@ QTransform QVGraphicsView::getTransformWithNoScaling() const
636
636
637
637
qreal QVGraphicsView::getDpiAdjustment () const
638
638
{
639
- return isOneToOnePixelSizingEnabled ? devicePixelRatioF () : 1.0 ;
639
+ // Although inverting this potentially introduces a rounding error, it is inevitable. For
640
+ // example with 1:1 pixel sizing @ 100% zoom, the transform's scale must be set to the
641
+ // inverted value. Pre-inverting it here helps keep things consistent, e.g. so that the
642
+ // content rect calculation has the same error that will happen during painting.
643
+ return isOneToOnePixelSizingEnabled ? 1.0 / devicePixelRatioF () : 1.0 ;
640
644
}
641
645
642
646
void QVGraphicsView::handleDpiAdjustmentChange ()
0 commit comments