Browse Source

testing with all resamplers

af/merge-core
Anton Firszov 9 years ago
parent
commit
4b56f23c7c
  1. 46
      tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs

46
tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs

@ -8,6 +8,9 @@ using Xunit;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
using System;
using System.Reflection;
public class RotateTests : FileTestBase
{
public static readonly TheoryData<float> RotateFloatValues
@ -26,6 +29,25 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
RotateType.Rotate270
};
public static readonly TheoryData<string> ResmplerNames = new TheoryData<string>
{
nameof(KnownResamplers.Bicubic),
nameof(KnownResamplers.Box),
nameof(KnownResamplers.CatmullRom),
nameof(KnownResamplers.Hermite),
nameof(KnownResamplers.Lanczos2),
nameof(KnownResamplers.Lanczos3),
nameof(KnownResamplers.Lanczos5),
nameof(KnownResamplers.Lanczos8),
nameof(KnownResamplers.MitchellNetravali),
nameof(KnownResamplers.NearestNeighbor),
nameof(KnownResamplers.Robidoux),
nameof(KnownResamplers.RobidouxSharp),
nameof(KnownResamplers.Spline),
nameof(KnownResamplers.Triangle),
nameof(KnownResamplers.Welch),
};
[Theory]
[WithTestPatternImages(nameof(RotateFloatValues), 100, 50, DefaultPixelType)]
[WithTestPatternImages(nameof(RotateFloatValues), 50, 100, DefaultPixelType)]
@ -40,15 +62,17 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
}
[Theory]
[WithTestPatternImages(nameof(RotateFloatValues), 100, 50, DefaultPixelType)]
[WithTestPatternImages(nameof(RotateFloatValues), 50, 100, DefaultPixelType)]
public void RotateWithSampler<TPixel>(TestImageProvider<TPixel> provider, float value)
[WithTestPatternImages(nameof(ResmplerNames), 100, 50, DefaultPixelType)]
[WithTestPatternImages(nameof(ResmplerNames), 50, 100, DefaultPixelType)]
public void RotateWithSampler<TPixel>(TestImageProvider<TPixel> provider, string resamplerName)
where TPixel : struct, IPixel<TPixel>
{
IResampler resampler = GetResampler(resamplerName);
using (Image<TPixel> image = provider.GetImage())
{
image.Mutate(x => x.Rotate(value, KnownResamplers.Triangle));
image.DebugSave(provider, string.Join("_", value, "triangle"));
image.Mutate(x => x.Rotate(50, resampler));
image.DebugSave(provider, resamplerName);
}
}
@ -64,5 +88,17 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
image.DebugSave(provider, value);
}
}
private static IResampler GetResampler(string name)
{
PropertyInfo property = typeof(KnownResamplers).GetTypeInfo().GetProperty(name);
if (property == null)
{
throw new Exception("Invalid property name!");
}
return (IResampler) property.GetValue(null);
}
}
}
Loading…
Cancel
Save