diff --git a/src/ImageSharp/ImageFrameCollection.cs b/src/ImageSharp/ImageFrameCollection.cs index 4b8f90e9b..3c1062df3 100644 --- a/src/ImageSharp/ImageFrameCollection.cs +++ b/src/ImageSharp/ImageFrameCollection.cs @@ -30,14 +30,14 @@ namespace SixLabors.ImageSharp this.frames.Add(new ImageFrame(parent.GetConfiguration(), width, height, backgroundColor)); } - internal ImageFrameCollection(Image parent, int width, int height, Memory consumedBuffer) + internal ImageFrameCollection(Image parent, int width, int height, Memory consumedMemory) { Guard.NotNull(parent, nameof(parent)); this.parent = parent; // Frames are already cloned within the caller - this.frames.Add(new ImageFrame(parent.GetConfiguration(), width, height, consumedBuffer)); + this.frames.Add(new ImageFrame(parent.GetConfiguration(), width, height, consumedMemory)); } internal ImageFrameCollection(Image parent, IEnumerable> frames) diff --git a/src/ImageSharp/ImageFrame{TPixel}.cs b/src/ImageSharp/ImageFrame{TPixel}.cs index 2fa35f1e5..370b3763c 100644 --- a/src/ImageSharp/ImageFrame{TPixel}.cs +++ b/src/ImageSharp/ImageFrame{TPixel}.cs @@ -95,8 +95,8 @@ namespace SixLabors.ImageSharp /// /// Initializes a new instance of the class wrapping an existing buffer. /// - internal ImageFrame(Configuration configuration, int width, int height, Memory consumedBuffer) - : this(configuration, width, height, consumedBuffer, new ImageFrameMetaData()) + internal ImageFrame(Configuration configuration, int width, int height, Memory consumedMemory) + : this(configuration, width, height, consumedMemory, new ImageFrameMetaData()) { } @@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp Configuration configuration, int width, int height, - Memory consumedBuffer, + Memory consumedMemory, ImageFrameMetaData metaData) { Guard.NotNull(configuration, nameof(configuration)); @@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp this.configuration = configuration; this.MemoryAllocator = configuration.MemoryAllocator; - this.PixelBuffer = new Buffer2D(consumedBuffer, width, height); + this.PixelBuffer = new Buffer2D(consumedMemory, width, height); this.MetaData = metaData; } diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs index 9126812dd..316c381c4 100644 --- a/src/ImageSharp/Image{TPixel}.cs +++ b/src/ImageSharp/Image{TPixel}.cs @@ -86,8 +86,8 @@ namespace SixLabors.ImageSharp /// Initializes a new instance of the class /// consuming an external buffer instance. /// - internal Image(Configuration configuration, Memory consumedBuffer, int width, int height) - : this(configuration, consumedBuffer, width, height, new ImageMetaData()) + internal Image(Configuration configuration, Memory consumedMemory, int width, int height) + : this(configuration, consumedMemory, width, height, new ImageMetaData()) { } @@ -95,12 +95,12 @@ namespace SixLabors.ImageSharp /// Initializes a new instance of the class /// consuming an external buffer instance. /// - internal Image(Configuration configuration, Memory consumedBuffer, int width, int height, ImageMetaData metadata) + internal Image(Configuration configuration, Memory consumedMemory, int width, int height, ImageMetaData metadata) { this.configuration = configuration; this.PixelType = new PixelTypeInfo(Unsafe.SizeOf() * 8); this.MetaData = metadata; - this.frames = new ImageFrameCollection(this, width, height, consumedBuffer); + this.frames = new ImageFrameCollection(this, width, height, consumedMemory); } /// diff --git a/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs b/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs index 366266652..974099991 100644 --- a/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs @@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests.Advanced Memory externalMemory = managerOfExeternalMemory.Memory; - using (Image image1 = Image.WrapMemory(externalMemory, image0.Width, image0.Height)) + using (var image1 = Image.WrapMemory(externalMemory, image0.Width, image0.Height)) { Memory internalMemory = image1.GetPixelMemory(); Assert.Equal(targetBuffer.Length, internalMemory.Length); @@ -72,7 +72,6 @@ namespace SixLabors.ImageSharp.Tests.Advanced image0.ComparePixelBufferTo(externalMemory.Span); } } - } [Theory] diff --git a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs index 1f01d54f4..45f1340be 100644 --- a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs @@ -81,6 +81,23 @@ namespace SixLabors.ImageSharp.Tests.Drawing provider.RunValidatingProcessorTest(c => c.Fill(color, region), testDetails, ImageComparer.Exact); } + [Theory] + [WithSolidFilledImages(16, 16, "Red", PixelTypes.Rgba32, 5, 7, 3, 8)] + [WithSolidFilledImages(16, 16, "Red", PixelTypes.Rgba32, 8, 5, 6, 4)] + public void FillRegion_WorksOnWrappedMemoryImage(TestImageProvider provider, int x0, int y0, int w, int h) + where TPixel : struct, IPixel + { + FormattableString testDetails = $"(x{x0},y{y0},w{w},h{h})"; + var region = new RectangleF(x0, y0, w, h); + TPixel color = TestUtils.GetPixelOfNamedColor("Blue"); + + provider.RunValidatingProcessorTestOnWrappedMemoryImage( + c => c.Fill(color, region), + testDetails, + ImageComparer.Exact, + useReferenceOutputFrom: nameof(this.FillRegion)); + } + public static readonly TheoryData BlendData = new TheoryData() { diff --git a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs index 94d3d49ff..23acc1a44 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs @@ -38,6 +38,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing } } + [Theory] [WithBlankImages(500, 500, PixelTypes.Rgba32)] public void OverlayByFilledPolygonOpacity(TestImageProvider provider) diff --git a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs index a6ea76f2d..81310c1a0 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs @@ -228,6 +228,8 @@ namespace SixLabors.ImageSharp.Tests // TODO: Investigate the cause of pixel inaccuracies under Linux if (TestEnvironment.IsWindows) { + string testNameBackup = provider.Utility.TestName; + if (useReferenceOutputFrom != null) { provider.Utility.TestName = useReferenceOutputFrom; @@ -239,6 +241,8 @@ namespace SixLabors.ImageSharp.Tests testOutputDetails, appendPixelTypeToFileName: appendPixelTypeToFileName, appendSourceFileOrDescription: appendSourceFileOrDescription); + + provider.Utility.TestName = testNameBackup; } } }