From fb173db2ca2a96874770f5d275166991da6d43ed Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 29 May 2017 23:30:30 +1000 Subject: [PATCH] Hue --- .../Processing/ColorMatrix/HueTest.cs | 53 +++++++++++++++++ .../Processors/Filters/HueTest.cs | 57 ------------------- 2 files changed, 53 insertions(+), 57 deletions(-) create mode 100644 tests/ImageSharp.Tests/Processing/ColorMatrix/HueTest.cs delete mode 100644 tests/ImageSharp.Tests/Processors/Filters/HueTest.cs diff --git a/tests/ImageSharp.Tests/Processing/ColorMatrix/HueTest.cs b/tests/ImageSharp.Tests/Processing/ColorMatrix/HueTest.cs new file mode 100644 index 000000000..1e0760194 --- /dev/null +++ b/tests/ImageSharp.Tests/Processing/ColorMatrix/HueTest.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 HueTest : FileTestBase + { + public static readonly TheoryData HueValues + = new TheoryData + { + 180, + -180 + }; + + [Theory] + [WithFileCollection(nameof(AllBmpFiles), nameof(HueValues), StandardPixelTypes)] + public void ImageShouldApplyHueFilter(TestImageProvider provider, int value) + where TPixel : struct, IPixel + { + using (Image image = provider.GetImage()) + { + image.Hue(value) + .DebugSave(provider, null, Extensions.Bmp); + } + } + + [Theory] + [WithFileCollection(nameof(AllBmpFiles), nameof(HueValues), StandardPixelTypes)] + public void ImageShouldApplyHueFilterInBox(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.Hue(value, bounds) + .DebugSave(provider, null, 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/HueTest.cs b/tests/ImageSharp.Tests/Processors/Filters/HueTest.cs deleted file mode 100644 index 488433931..000000000 --- a/tests/ImageSharp.Tests/Processors/Filters/HueTest.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 HueTest : FileTestBase - { - public static readonly TheoryData HueValues - = new TheoryData - { - 180 , - -180 , - }; - - [Theory] - [MemberData(nameof(HueValues))] - public void ImageShouldApplyHueFilter(int value) - { - string path = this.CreateOutputDirectory("Hue"); - - foreach (TestFile file in Files) - { - string filename = file.GetFileName(value); - using (Image image = file.CreateImage()) - using (FileStream output = File.OpenWrite($"{path}/{filename}")) - { - image.Hue(value).Save(output); - } - } - } - - [Theory] - [MemberData(nameof(HueValues))] - public void ImageShouldApplyHueFilterInBox(int value) - { - string path = this.CreateOutputDirectory("Hue"); - - foreach (TestFile file in Files) - { - string filename = file.GetFileName(value + "-InBox"); - using (Image image = file.CreateImage()) - using (FileStream output = File.OpenWrite($"{path}/{filename}")) - { - image.Hue(value, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); - } - } - } - } -} \ No newline at end of file