Browse Source

testing with all resamplers

pull/386/head
Anton Firszov 9 years ago
parent
commit
aa150e6e57
  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 // ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{ {
using System;
using System.Reflection;
public class RotateTests : FileTestBase public class RotateTests : FileTestBase
{ {
public static readonly TheoryData<float> RotateFloatValues public static readonly TheoryData<float> RotateFloatValues
@ -26,6 +29,25 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
RotateType.Rotate270 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] [Theory]
[WithTestPatternImages(nameof(RotateFloatValues), 100, 50, DefaultPixelType)] [WithTestPatternImages(nameof(RotateFloatValues), 100, 50, DefaultPixelType)]
[WithTestPatternImages(nameof(RotateFloatValues), 50, 100, DefaultPixelType)] [WithTestPatternImages(nameof(RotateFloatValues), 50, 100, DefaultPixelType)]
@ -40,15 +62,17 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
} }
[Theory] [Theory]
[WithTestPatternImages(nameof(RotateFloatValues), 100, 50, DefaultPixelType)] [WithTestPatternImages(nameof(ResmplerNames), 100, 50, DefaultPixelType)]
[WithTestPatternImages(nameof(RotateFloatValues), 50, 100, DefaultPixelType)] [WithTestPatternImages(nameof(ResmplerNames), 50, 100, DefaultPixelType)]
public void RotateWithSampler<TPixel>(TestImageProvider<TPixel> provider, float value) public void RotateWithSampler<TPixel>(TestImageProvider<TPixel> provider, string resamplerName)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
IResampler resampler = GetResampler(resamplerName);
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
{ {
image.Mutate(x => x.Rotate(value, KnownResamplers.Triangle)); image.Mutate(x => x.Rotate(50, resampler));
image.DebugSave(provider, string.Join("_", value, "triangle")); image.DebugSave(provider, resamplerName);
} }
} }
@ -64,5 +88,17 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
image.DebugSave(provider, value); 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