diff --git a/tests/ImageSharp.Tests/Processing/ColorMatrix/SaturationTest.cs b/tests/ImageSharp.Tests/Processing/ColorMatrix/SaturationTest.cs new file mode 100644 index 0000000000..506f295039 --- /dev/null +++ b/tests/ImageSharp.Tests/Processing/ColorMatrix/SaturationTest.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp.Tests.Processing.ColorMatrix +{ + using ImageSharp.PixelFormats; + + using Xunit; + + public class SaturationTest : FileTestBase + { + public static readonly TheoryData SaturationValues + = new TheoryData + { + 50 , + -50 , + }; + + [Theory] + [WithFileCollection(nameof(AllBmpFiles), nameof(SaturationValues), StandardPixelTypes)] + public void ImageShouldApplySaturationFilter(TestImageProvider provider, int value) + where TPixel : struct, IPixel + { + using (Image image = provider.GetImage()) + { + image.Saturation(value) + .DebugSave(provider, value, Extensions.Bmp); + } + } + + [Theory] + [WithFileCollection(nameof(AllBmpFiles), nameof(SaturationValues), StandardPixelTypes)] + public void ImageShouldApplySaturationFilterInBox(TestImageProvider provider, int value) + where TPixel : struct, IPixel + { + using (Image source = provider.GetImage()) + using (var image = new Image(source)) + { + var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); + + image.Saturation(value, bounds) + .DebugSave(provider, value, Extensions.Bmp); + + // Draw identical shapes over the bounded and compare to ensure changes are constrained. + image.Fill(NamedColors.HotPink, bounds); + source.Fill(NamedColors.HotPink, bounds); + ImageComparer.CheckSimilarity(image, source); + } + } + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Processors/Filters/SaturationTest.cs b/tests/ImageSharp.Tests/Processors/Filters/SaturationTest.cs deleted file mode 100644 index e28847fa3b..0000000000 --- a/tests/ImageSharp.Tests/Processors/Filters/SaturationTest.cs +++ /dev/null @@ -1,57 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Tests -{ - using System.IO; - - using ImageSharp.PixelFormats; - - using Xunit; - - public class SaturationTest : FileTestBase - { - public static readonly TheoryData SaturationValues - = new TheoryData - { - 50 , - -50 , - }; - - [Theory] - [MemberData(nameof(SaturationValues))] - public void ImageShouldApplySaturationFilter(int value) - { - string path = CreateOutputDirectory("Saturation"); - - foreach (TestFile file in Files) - { - string filename = file.GetFileName(value); - using (Image image = file.CreateImage()) - using (FileStream output = File.OpenWrite($"{path}/{filename}")) - { - image.Saturation(value).Save(output); - } - } - } - - [Theory] - [MemberData(nameof(SaturationValues))] - public void ImageShouldApplySaturationFilterInBox(int value) - { - string path = this.CreateOutputDirectory("Saturation"); - - foreach (TestFile file in Files) - { - string filename = file.GetFileName(value + "-InBox"); - using (Image image = file.CreateImage()) - using (FileStream output = File.OpenWrite($"{path}/{filename}")) - { - image.Saturation(value, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); - } - } - } - } -} \ No newline at end of file