Browse Source

Hue

af/merge-core
James Jackson-South 9 years ago
parent
commit
fb173db2ca
  1. 53
      tests/ImageSharp.Tests/Processing/ColorMatrix/HueTest.cs
  2. 57
      tests/ImageSharp.Tests/Processors/Filters/HueTest.cs

53
tests/ImageSharp.Tests/Processing/ColorMatrix/HueTest.cs

@ -0,0 +1,53 @@
// <copyright file="HueTest.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Tests.Processing.ColorMatrix
{
using ImageSharp.PixelFormats;
using Xunit;
public class HueTest : FileTestBase
{
public static readonly TheoryData<int> HueValues
= new TheoryData<int>
{
180,
-180
};
[Theory]
[WithFileCollection(nameof(AllBmpFiles), nameof(HueValues), StandardPixelTypes)]
public void ImageShouldApplyHueFilter<TPixel>(TestImageProvider<TPixel> provider, int value)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage())
{
image.Hue(value)
.DebugSave(provider, null, Extensions.Bmp);
}
}
[Theory]
[WithFileCollection(nameof(AllBmpFiles), nameof(HueValues), StandardPixelTypes)]
public void ImageShouldApplyHueFilterInBox<TPixel>(TestImageProvider<TPixel> provider, int value)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(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<TPixel>.HotPink, bounds);
source.Fill(NamedColors<TPixel>.HotPink, bounds);
ImageComparer.CheckSimilarity(image, source);
}
}
}
}

57
tests/ImageSharp.Tests/Processors/Filters/HueTest.cs

@ -1,57 +0,0 @@
// <copyright file="HueTest.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Tests
{
using System.IO;
using ImageSharp.PixelFormats;
using Xunit;
public class HueTest : FileTestBase
{
public static readonly TheoryData<int> HueValues
= new TheoryData<int>
{
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<Rgba32> 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<Rgba32> 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);
}
}
}
}
}
Loading…
Cancel
Save