From 35f68bad87140e85a721de1f66b110bcceac5ca1 Mon Sep 17 00:00:00 2001 From: Michael Clayton Date: Wed, 31 Jul 2024 16:40:59 +0100 Subject: [PATCH] #46 - move test-specific code --- .../Helpers/LayoutHelperTests.cs | 2 +- src/FancyMouse.Common/Helpers/DrawingHelper.cs | 5 ----- src/FancyMouse.Common/Helpers/LayoutHelper.cs | 1 - .../Imaging/StaticImageRegionCopyService.cs | 6 ++++++ 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/FancyMouse.Common.UnitTests/Helpers/LayoutHelperTests.cs b/src/FancyMouse.Common.UnitTests/Helpers/LayoutHelperTests.cs index ba26c11..9a0fe03 100644 --- a/src/FancyMouse.Common.UnitTests/Helpers/LayoutHelperTests.cs +++ b/src/FancyMouse.Common.UnitTests/Helpers/LayoutHelperTests.cs @@ -238,7 +238,7 @@ public static IEnumerable GetTestCases() }); yield return new object[] { new TestCase(previewStyle, screens, activatedLocation, expectedResult) }; - // rounding error check - single screen with 50% scaling, + // rounding error check - single screen with 33% scaling, // no borders, check to make sure form scales to exactly // fill the canvas size with no rounding errors. // diff --git a/src/FancyMouse.Common/Helpers/DrawingHelper.cs b/src/FancyMouse.Common/Helpers/DrawingHelper.cs index 4396635..80b3f9e 100644 --- a/src/FancyMouse.Common/Helpers/DrawingHelper.cs +++ b/src/FancyMouse.Common/Helpers/DrawingHelper.cs @@ -50,11 +50,6 @@ public static Bitmap RenderPreview( previewGraphics, previewLayout.PreviewStyle.ScreenStyle, screenshotBounds); } - // prevent the background bleeding through into screen images - // (see https://github.com/mikeclayton/FancyMouse/issues/44) - previewGraphics.PixelOffsetMode = PixelOffsetMode.Half; - previewGraphics.InterpolationMode = InterpolationMode.NearestNeighbor; - var refreshRequired = false; var placeholdersDrawn = false; for (var i = 0; i < sourceScreens.Count; i++) diff --git a/src/FancyMouse.Common/Helpers/LayoutHelper.cs b/src/FancyMouse.Common/Helpers/LayoutHelper.cs index da457e5..724a1c4 100644 --- a/src/FancyMouse.Common/Helpers/LayoutHelper.cs +++ b/src/FancyMouse.Common/Helpers/LayoutHelper.cs @@ -70,7 +70,6 @@ public static PreviewLayout GetPreviewLayout( builder.FormBounds = formBounds; // now calculate the positions of each of the screenshot images on the preview - // scale the virtual screen to fit inside the content area builder.ScreenshotBounds = builder.Screens .Select( screen => LayoutHelper.GetBoxBoundsFromOuterBounds( diff --git a/src/FancyMouse.Common/Imaging/StaticImageRegionCopyService.cs b/src/FancyMouse.Common/Imaging/StaticImageRegionCopyService.cs index 31579b4..d21e49c 100644 --- a/src/FancyMouse.Common/Imaging/StaticImageRegionCopyService.cs +++ b/src/FancyMouse.Common/Imaging/StaticImageRegionCopyService.cs @@ -1,4 +1,5 @@ using System.Drawing; +using System.Drawing.Drawing2D; using FancyMouse.Common.Models.Drawing; namespace FancyMouse.Common.Imaging; @@ -28,6 +29,11 @@ public void CopyImageRegion( RectangleInfo sourceBounds, RectangleInfo targetBounds) { + // prevent the background bleeding through into screen images + // (see https://github.com/mikeclayton/FancyMouse/issues/44) + targetGraphics.PixelOffsetMode = PixelOffsetMode.Half; + targetGraphics.InterpolationMode = InterpolationMode.NearestNeighbor; + targetGraphics.DrawImage( image: this.SourceImage, destRect: targetBounds.ToRectangle(),