From a8a4dc057ce04416b8d7e82515aa09e063e236a6 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 30 May 2017 16:09:53 +1000 Subject: [PATCH] BackgroundColor --- .../Processing/Effects/BackgroundColorTest.cs | 46 ++++++++++++++++++ .../Processors/Filters/BackgroundColorTest.cs | 47 ------------------- 2 files changed, 46 insertions(+), 47 deletions(-) create mode 100644 tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs delete mode 100644 tests/ImageSharp.Tests/Processors/Filters/BackgroundColorTest.cs diff --git a/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs b/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs new file mode 100644 index 000000000..fd56dd6e7 --- /dev/null +++ b/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs @@ -0,0 +1,46 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp.Tests.Processing.Effects +{ + using ImageSharp.PixelFormats; + + using Xunit; + + public class BackgroundColorTest : FileTestBase + { + [Theory] + [WithFileCollection(nameof(DefaultFiles), StandardPixelType)] + public void ImageShouldApplyBackgroundColorFilter(TestImageProvider provider) + where TPixel : struct, IPixel + { + using (Image image = provider.GetImage()) + { + image.BackgroundColor(NamedColors.HotPink) + .DebugSave(provider, null, Extensions.Bmp); + } + } + + [Theory] + [WithFileCollection(nameof(DefaultFiles), StandardPixelType)] + public void ImageShouldApplyBackgroundColorFilterInBox(TestImageProvider provider) + 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.BackgroundColor(NamedColors.HotPink, 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/BackgroundColorTest.cs b/tests/ImageSharp.Tests/Processors/Filters/BackgroundColorTest.cs deleted file mode 100644 index d7ca78d1b..000000000 --- a/tests/ImageSharp.Tests/Processors/Filters/BackgroundColorTest.cs +++ /dev/null @@ -1,47 +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 BackgroundColorTest : FileTestBase - { - [Fact] - public void ImageShouldApplyBackgroundColorFilter() - { - string path = this.CreateOutputDirectory("BackgroundColor"); - - foreach (TestFile file in Files) - { - using (Image image = file.CreateImage()) - using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) - { - image.BackgroundColor(Rgba32.HotPink).Save(output); - } - } - } - - [Fact] - public void ImageShouldApplyBackgroundColorFilterInBox() - { - string path = this.CreateOutputDirectory("BackgroundColor"); - - foreach (TestFile file in Files) - { - string filename = file.GetFileName("-InBox"); - using (Image image = file.CreateImage()) - using (FileStream output = File.OpenWrite($"{path}/{filename}")) - { - image.BackgroundColor(Rgba32.HotPink, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); - } - } - } - } -} \ No newline at end of file