From bac1ff4ba06e855239658688cf8e23002efb248c Mon Sep 17 00:00:00 2001 From: Killy Date: Thu, 30 Apr 2020 18:30:51 +0300 Subject: [PATCH] Fix for pixel jerk --- Greenshot/Drawing/Surface.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Greenshot/Drawing/Surface.cs b/Greenshot/Drawing/Surface.cs index 811466cf7..2ea5e0b00 100644 --- a/Greenshot/Drawing/Surface.cs +++ b/Greenshot/Drawing/Surface.cs @@ -1440,6 +1440,25 @@ namespace Greenshot.Drawing LOG.Debug("Empty cliprectangle??"); return; } + + // Correction to prevent rounding errors at certain zoom levels. + // When zooming to N/M, clip rectangle top and left coordinates should be multiples of N. + if (_zoomFactor.Numerator > 1 && _zoomFactor.Denominator > 1) + { + int horizontalCorrection = targetClipRectangle.Left % (int)_zoomFactor.Numerator; + int verticalCorrection = targetClipRectangle.Top % (int)_zoomFactor.Numerator; + if (horizontalCorrection != 0) + { + targetClipRectangle.X -= horizontalCorrection; + targetClipRectangle.Width += horizontalCorrection; + } + if (verticalCorrection != 0) + { + targetClipRectangle.Y -= verticalCorrection; + targetClipRectangle.Height += verticalCorrection; + } + } + Rectangle imageClipRectangle = ZoomClipRectangle(targetClipRectangle, _zoomFactor.Inverse(), 2); bool isZoomedIn = _zoomFactor > Fraction.Identity;