From cfbc148975d8b59e0cf69bb1b828a8665ca7a05b Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 27 Sep 2020 17:26:44 -0400 Subject: [PATCH] fix GB and SNES graphics viewers (and maybe others) due to incorrect (non-100%) windows DPI scaling setting --- src/BizHawk.Client.EmuHawk/config/GB/BmpView.cs | 17 ++++++++++++++++- .../tools/SNES/SNESGraphicsViewer.cs | 13 +++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/BizHawk.Client.EmuHawk/config/GB/BmpView.cs b/src/BizHawk.Client.EmuHawk/config/GB/BmpView.cs index fecbb9a35f..13e1babcb0 100644 --- a/src/BizHawk.Client.EmuHawk/config/GB/BmpView.cs +++ b/src/BizHawk.Client.EmuHawk/config/GB/BmpView.cs @@ -1,4 +1,6 @@ -using System; +//TODO - this is redundant with RetainedViewportPanel. Someone needs to reconcile the two. + +using System; using System.ComponentModel; using System.Drawing.Imaging; using System.Drawing; @@ -15,6 +17,19 @@ namespace BizHawk.Client.EmuHawk private bool _scaled; + protected override void ScaleControl(SizeF factor, BoundsSpecified specified) + { + int x = Location.X; + int y = Location.Y; + if (specified.HasFlag(BoundsSpecified.X)) + x = (int)(x * factor.Width); + if (specified.HasFlag(BoundsSpecified.Y)) + y = (int)(y * factor.Height); + var pt = new Point(x, y); + if (pt != Location) + Location = pt; + } + public BmpView() { if (DesignMode) diff --git a/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsViewer.cs b/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsViewer.cs index bdc4c4bb31..6468734641 100644 --- a/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsViewer.cs +++ b/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsViewer.cs @@ -5,6 +5,19 @@ namespace BizHawk.Client.EmuHawk { public class SNESGraphicsViewer : RetainedViewportPanel { + protected override void ScaleControl(SizeF factor, BoundsSpecified specified) + { + int x = Location.X; + int y = Location.Y; + if (specified.HasFlag(BoundsSpecified.X)) + x = (int)(x * factor.Width); + if (specified.HasFlag(BoundsSpecified.Y)) + y = (int)(y * factor.Height); + var pt = new Point(x, y); + if (pt != Location) + Location = pt; + } + public SNESGraphicsViewer() { SetStyle(ControlStyles.SupportsTransparentBackColor, true);