mirror of https://github.com/SixLabors/ImageSharp
5 changed files with 82 additions and 88 deletions
@ -1,72 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Reflection; |
|||
|
|||
using SixLabors.ImageSharp.Processing; |
|||
using SixLabors.ImageSharp.Processing.Processors.Transforms; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using Xunit; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms |
|||
{ |
|||
public class SkewTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<float, float> SkewValues |
|||
= new TheoryData<float, float> |
|||
{ |
|||
{ 20, 10 }, |
|||
{ -20, -10 } |
|||
}; |
|||
|
|||
public static readonly List<string> ResamplerNames |
|||
= new List<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(SkewValues), 100, 50, DefaultPixelType)] |
|||
public void ImageShouldSkew<TPixel>(TestImageProvider<TPixel> provider, float x, float y) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Mutate(i => i.Skew(x, y)); |
|||
image.DebugSave(provider, string.Join("_", x, y)); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithTestPatternImages(nameof(SkewValues), 100, 50, DefaultPixelType)] |
|||
public void ImageShouldSkewWithSampler<TPixel>(TestImageProvider<TPixel> provider, float x, float y) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
foreach (string resamplerName in ResamplerNames) |
|||
{ |
|||
IResampler sampler = TestUtils.GetResampler(resamplerName); |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Mutate(i => i.Skew(x, y, sampler)); |
|||
image.DebugSave(provider, string.Join("_", x, y, resamplerName)); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using SixLabors.ImageSharp.Processing; |
|||
using SixLabors.ImageSharp.Processing.Processors.Transforms; |
|||
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; |
|||
|
|||
using Xunit; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms |
|||
{ |
|||
[GroupOutput("Transforms")] |
|||
public class SkewTests |
|||
{ |
|||
private const PixelTypes CommonPixelTypes = PixelTypes.Bgra32 | PixelTypes.Rgb24; |
|||
|
|||
public static readonly string[] ResamplerNames = new[] |
|||
{ |
|||
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), |
|||
}; |
|||
|
|||
public static readonly TheoryData<float, float> SkewValues = new TheoryData<float, float> |
|||
{ |
|||
{ 20, 10 }, |
|||
{ -20, -10 } |
|||
}; |
|||
|
|||
private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.01f); |
|||
|
|||
[Theory] |
|||
[WithTestPatternImages(nameof(SkewValues), 100, 50, CommonPixelTypes)] |
|||
public void Skew_IsNotBoundToSinglePixelType<TPixel>(TestImageProvider<TPixel> provider, float x, float y) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
provider.RunValidatingProcessorTest(ctx => ctx.Skew(x, y), $"{x}_{y}", ValidatorComparer); |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFile(TestImages.Png.Ducky, nameof(ResamplerNames), PixelTypes.Rgba32)] |
|||
public void Skew_WorksWithAllResamplers<TPixel>(TestImageProvider<TPixel> provider, string resamplerName) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
IResampler sampler = TestUtils.GetResampler(resamplerName); |
|||
|
|||
provider.RunValidatingProcessorTest( |
|||
x => x.Skew(21, 32, sampler), |
|||
resamplerName, |
|||
comparer: ValidatorComparer, |
|||
appendPixelTypeToFileName: false); |
|||
} |
|||
} |
|||
} |
|||
@ -1 +1 @@ |
|||
Subproject commit 497dda87179af1dc323064140765f72b892116a3 |
|||
Subproject commit 56ee5df145d9696e401e2bc53e615c553cfb32d5 |
|||
Loading…
Reference in new issue