mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.7 KiB
67 lines
1.7 KiB
// Copyright (c) Six Labors.
|
|
// Licensed under the Six Labors Split License.
|
|
|
|
using SixLabors.ImageSharp.Processing;
|
|
using SixLabors.ImageSharp.Processing.Processors.Transforms;
|
|
|
|
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms;
|
|
|
|
[Trait("Category", "Processors")]
|
|
public class ResamplerTests
|
|
{
|
|
[Theory]
|
|
[InlineData(-2, 0)]
|
|
[InlineData(-1, 0)]
|
|
[InlineData(0, 1)]
|
|
[InlineData(1, 0)]
|
|
[InlineData(2, 0)]
|
|
public static void BicubicWindowOscillatesCorrectly(float x, float expected)
|
|
{
|
|
IResampler sampler = KnownResamplers.Bicubic;
|
|
float result = sampler.GetValue(x);
|
|
|
|
Assert.Equal(result, expected);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(-2, 0)]
|
|
[InlineData(-1, 0)]
|
|
[InlineData(0, 1)]
|
|
[InlineData(1, 0)]
|
|
[InlineData(2, 0)]
|
|
public static void Lanczos3WindowOscillatesCorrectly(float x, float expected)
|
|
{
|
|
IResampler sampler = KnownResamplers.Lanczos3;
|
|
float result = sampler.GetValue(x);
|
|
|
|
Assert.Equal(result, expected);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(-4, 0)]
|
|
[InlineData(-2, 0)]
|
|
[InlineData(0, 1)]
|
|
[InlineData(2, 0)]
|
|
[InlineData(4, 0)]
|
|
public static void Lanczos5WindowOscillatesCorrectly(float x, float expected)
|
|
{
|
|
IResampler sampler = KnownResamplers.Lanczos5;
|
|
float result = sampler.GetValue(x);
|
|
|
|
Assert.Equal(result, expected);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(-2, 0)]
|
|
[InlineData(-1, 0)]
|
|
[InlineData(0, 1)]
|
|
[InlineData(1, 0)]
|
|
[InlineData(2, 0)]
|
|
public static void TriangleWindowOscillatesCorrectly(float x, float expected)
|
|
{
|
|
IResampler sampler = KnownResamplers.Triangle;
|
|
float result = sampler.GetValue(x);
|
|
|
|
Assert.Equal(result, expected);
|
|
}
|
|
}
|
|
|