Stay zoomed when image doesn't fit in client area

This commit is contained in:
Eric Tetz 2022-01-31 20:31:34 -07:00
parent 992e462383
commit 778eec1188

View file

@ -791,14 +791,14 @@ protected override void OnPaint(PaintEventArgs e)
Graphics g = e.Graphics; Graphics g = e.Graphics;
g.PixelOffsetMode = PixelOffsetMode.HighSpeed; if (IsEditorMode)
g.InterpolationMode = InterpolationMode.NearestNeighbor;
if (IsEditorMode && !CanvasRectangle.Contains(ClientArea))
{ {
g.ScaleTransform(ZoomFactor, ZoomFactor); g.ScaleTransform(ZoomFactor, ZoomFactor);
g.Clear(canvasBackgroundColor); if (!CanvasRectangle.Contains(ClientArea))
g.DrawRectangleProper(canvasBorderPen, CanvasRectangle.Offset(1)); {
g.Clear(canvasBackgroundColor);
g.DrawRectangleProper(canvasBorderPen, CanvasRectangle.Offset(1));
}
} }
DrawBackground(g); DrawBackground(g);
@ -820,8 +820,8 @@ protected override void OnPaint(PaintEventArgs e)
private void DrawBackground(Graphics g) private void DrawBackground(Graphics g)
{ {
// TODO: dynamically adjust scaling quality when zoom != 1 based on FPS // TODO: dynamically improved scaling quality when zoom != 1 if FPS is high
// Quality is more important when scaling down than up. // especially when scaling down
g.PixelOffsetMode = PixelOffsetMode.HighSpeed; g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
g.InterpolationMode = InterpolationMode.NearestNeighbor; g.InterpolationMode = InterpolationMode.NearestNeighbor;
g.SmoothingMode = SmoothingMode.HighSpeed; g.SmoothingMode = SmoothingMode.HighSpeed;