|
|
|
@ -18,8 +18,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms |
|
|
|
{ |
|
|
|
public static readonly string[] CommonTestImages = { TestImages.Png.CalliphoraPartial }; |
|
|
|
|
|
|
|
private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.069F); |
|
|
|
|
|
|
|
private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.07F); |
|
|
|
|
|
|
|
public static readonly TheoryData<string, IResampler> AllReSamplers = |
|
|
|
new TheoryData<string, IResampler> |
|
|
|
{ |
|
|
|
@ -65,20 +65,16 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms |
|
|
|
public void Resize_WorksWithAllParallelismLevels<TPixel>(TestImageProvider<TPixel> provider, int maxDegreeOfParallelism) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
if (maxDegreeOfParallelism >= 0) |
|
|
|
{ |
|
|
|
provider.Configuration.MaxDegreeOfParallelism = maxDegreeOfParallelism; |
|
|
|
} |
|
|
|
provider.Configuration.MaxDegreeOfParallelism = |
|
|
|
maxDegreeOfParallelism > 0 ? maxDegreeOfParallelism : Environment.ProcessorCount; |
|
|
|
|
|
|
|
using (Image<TPixel> image = provider.GetImage()) |
|
|
|
{ |
|
|
|
SizeF newSize = image.Size() * 0.5f; |
|
|
|
image.Mutate(x => x.Resize((Size)newSize, false)); |
|
|
|
FormattableString details = $"MDP{maxDegreeOfParallelism}"; |
|
|
|
FormattableString details = $"MDP{maxDegreeOfParallelism}"; |
|
|
|
|
|
|
|
image.DebugSave(provider, details); |
|
|
|
//image.CompareToReferenceOutput(ImageComparer.TolerantPercentage(0.005f), provider, details);
|
|
|
|
} |
|
|
|
provider.RunValidatingProcessorTest( |
|
|
|
x => x.Resize(x.GetCurrentSize() / 2), |
|
|
|
details, |
|
|
|
appendPixelTypeToFileName: false, |
|
|
|
appendSourceFileOrDescription: false); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -100,16 +96,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms |
|
|
|
public void Resize_IsNotBoundToSinglePixelType<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
using (Image<TPixel> image = provider.GetImage()) |
|
|
|
{ |
|
|
|
image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2, true)); |
|
|
|
|
|
|
|
image.DebugSave(provider); |
|
|
|
image.CompareToReferenceOutput(ValidatorComparer, provider); |
|
|
|
} |
|
|
|
provider.RunValidatingProcessorTest(x => x.Resize(x.GetCurrentSize() / 2), comparer: ValidatorComparer); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] |
|
|
|
public void Resize_ThrowsForWrappedMemoryImage<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
@ -130,32 +119,21 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithFile(TestImages.Png.Kaboom, DefaultPixelType)] |
|
|
|
public void Resize_DoesNotBleedAlphaPixels<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
[WithFile(TestImages.Png.Kaboom, DefaultPixelType, false)] |
|
|
|
[WithFile(TestImages.Png.Kaboom, DefaultPixelType, true)] |
|
|
|
public void Resize_DoesNotBleedAlphaPixels<TPixel>(TestImageProvider<TPixel> provider, bool compand) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
using (Image<TPixel> image = provider.GetImage()) |
|
|
|
{ |
|
|
|
image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2)); |
|
|
|
image.DebugSave(provider); |
|
|
|
image.CompareToReferenceOutput(ValidatorComparer, provider); |
|
|
|
} |
|
|
|
} |
|
|
|
string details = compand ? "Compand" : ""; |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithFile(TestImages.Png.Kaboom, DefaultPixelType)] |
|
|
|
public void Resize_Compand_DoesNotBleedAlphaPixels<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
using (Image<TPixel> image = provider.GetImage()) |
|
|
|
{ |
|
|
|
image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2, true)); |
|
|
|
image.DebugSave(provider); |
|
|
|
} |
|
|
|
provider.RunValidatingProcessorTest( |
|
|
|
x => x.Resize(x.GetCurrentSize() / 2, compand), |
|
|
|
details, |
|
|
|
appendPixelTypeToFileName: false, |
|
|
|
appendSourceFileOrDescription: false); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithFile(TestImages.Gif.Giphy, DefaultPixelType)] |
|
|
|
public void Resize_IsAppliedToAllFrames<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
|