diff --git a/CoreBoy.Windows/WinFormsEmulatorSurface.Designer.cs b/CoreBoy.Windows/WinFormsEmulatorSurface.Designer.cs index a7ee4c8..a4879a0 100644 --- a/CoreBoy.Windows/WinFormsEmulatorSurface.Designer.cs +++ b/CoreBoy.Windows/WinFormsEmulatorSurface.Designer.cs @@ -29,7 +29,7 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.ClientSize = new System.Drawing.Size(1024, 768); this.Text = "CoreBoy"; } diff --git a/CoreBoy.Windows/WinFormsEmulatorSurface.cs b/CoreBoy.Windows/WinFormsEmulatorSurface.cs index 727e4a2..4d312d5 100644 --- a/CoreBoy.Windows/WinFormsEmulatorSurface.cs +++ b/CoreBoy.Windows/WinFormsEmulatorSurface.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Drawing.Drawing2D; using System.IO; using System.Threading; using System.Windows.Forms; @@ -52,7 +53,7 @@ public WinFormsEmulatorSurface() } }); - Controls.Add(_pictureBox = new PictureBox + Controls.Add(_pictureBox = new PixelBox { Top = _menu.Height, Width = BitmapDisplay.DisplayWidth * 5, @@ -207,4 +208,22 @@ protected override void OnFormClosed(FormClosedEventArgs e) _pictureBox.Dispose(); } } + + public class PixelBox : PictureBox + { + public InterpolationMode Interpolation { get => InterpolationMode.NearestNeighbor; } + + protected override void OnPaint(PaintEventArgs pe) + { + var graphics = pe.Graphics; + graphics.InterpolationMode = this.Interpolation; + + if(graphics.InterpolationMode == InterpolationMode.NearestNeighbor) + { + graphics.PixelOffsetMode = PixelOffsetMode.Half; + } + + base.OnPaint(pe); + } + } } \ No newline at end of file