mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 05:23:24 -07:00
Fix rendering quality at small zoom levels when redrawing small parts
This commit is contained in:
parent
5fe700bc84
commit
d47271e7e1
1 changed files with 30 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
|
@ -1473,19 +1473,11 @@ namespace Greenshot.Drawing
|
|||
targetGraphics.ScaleTransform(_zoomFactor, _zoomFactor);
|
||||
if (isZoomedIn)
|
||||
{
|
||||
var state = targetGraphics.Save();
|
||||
targetGraphics.SmoothingMode = SmoothingMode.None;
|
||||
targetGraphics.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||
targetGraphics.CompositingQuality = CompositingQuality.HighQuality;
|
||||
targetGraphics.PixelOffsetMode = PixelOffsetMode.None;
|
||||
|
||||
targetGraphics.DrawImage(_buffer, imageClipRectangle, imageClipRectangle, GraphicsUnit.Pixel);
|
||||
|
||||
targetGraphics.Restore(state);
|
||||
DrawSharpImage(targetGraphics, _buffer, imageClipRectangle);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetGraphics.DrawImage(_buffer, imageClipRectangle, imageClipRectangle, GraphicsUnit.Pixel);
|
||||
DrawSmoothImage(targetGraphics, _buffer, imageClipRectangle);
|
||||
}
|
||||
targetGraphics.ResetTransform();
|
||||
}
|
||||
|
@ -1494,7 +1486,7 @@ namespace Greenshot.Drawing
|
|||
DrawBackground(targetGraphics, targetClipRectangle);
|
||||
|
||||
targetGraphics.ScaleTransform(_zoomFactor, _zoomFactor);
|
||||
targetGraphics.DrawImage(Image, imageClipRectangle, imageClipRectangle, GraphicsUnit.Pixel);
|
||||
DrawSmoothImage(targetGraphics, Image, imageClipRectangle);
|
||||
_elements.Draw(targetGraphics, null, RenderMode.EDIT, imageClipRectangle);
|
||||
targetGraphics.ResetTransform();
|
||||
}
|
||||
|
@ -1511,6 +1503,32 @@ namespace Greenshot.Drawing
|
|||
}
|
||||
}
|
||||
|
||||
private void DrawSmoothImage(Graphics targetGraphics, Image image, Rectangle imageClipRectangle)
|
||||
{
|
||||
var state = targetGraphics.Save();
|
||||
targetGraphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
targetGraphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
|
||||
targetGraphics.CompositingQuality = CompositingQuality.HighQuality;
|
||||
targetGraphics.PixelOffsetMode = PixelOffsetMode.None;
|
||||
|
||||
targetGraphics.DrawImage(image, imageClipRectangle, imageClipRectangle, GraphicsUnit.Pixel);
|
||||
|
||||
targetGraphics.Restore(state);
|
||||
}
|
||||
|
||||
private void DrawSharpImage(Graphics targetGraphics, Image image, Rectangle imageClipRectangle)
|
||||
{
|
||||
var state = targetGraphics.Save();
|
||||
targetGraphics.SmoothingMode = SmoothingMode.None;
|
||||
targetGraphics.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||
targetGraphics.CompositingQuality = CompositingQuality.HighQuality;
|
||||
targetGraphics.PixelOffsetMode = PixelOffsetMode.None;
|
||||
|
||||
targetGraphics.DrawImage(image, imageClipRectangle, imageClipRectangle, GraphicsUnit.Pixel);
|
||||
|
||||
targetGraphics.Restore(state);
|
||||
}
|
||||
|
||||
private void DrawBackground(Graphics targetGraphics, Rectangle clipRectangle)
|
||||
{
|
||||
// check if we need to draw the checkerboard
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue