|
|
|
@ -46,11 +46,23 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization |
|
|
|
|
|
|
|
private static IErrorDiffuser DefaultErrorDiffuser => KnownDiffusers.Atkinson; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The output is visually correct old 32bit runtime,
|
|
|
|
/// but it is very different because of floating point inaccuracies.
|
|
|
|
/// </summary>
|
|
|
|
private static readonly bool SkipAllDitherTests = |
|
|
|
!TestEnvironment.Is64BitProcess && string.IsNullOrEmpty(TestEnvironment.NetCoreVersion); |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithFile(TestImages.Png.CalliphoraPartial, PixelTypes.Rgba32)] |
|
|
|
public void ApplyDiffusionFilterInBox<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
if (SkipAllDitherTests) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
provider.RunRectangleConstrainedValidatingProcessorTest( |
|
|
|
(x, rect) => x.Diffuse(DefaultErrorDiffuser, .5F, rect), |
|
|
|
comparer: ValidatorComparer); |
|
|
|
@ -61,6 +73,11 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization |
|
|
|
public void ApplyDitherFilterInBox<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
if (SkipAllDitherTests) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
provider.RunRectangleConstrainedValidatingProcessorTest( |
|
|
|
(x, rect) => x.Dither(DefaultDitherer, rect), |
|
|
|
comparer: ValidatorComparer); |
|
|
|
@ -71,6 +88,11 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization |
|
|
|
public void DiffusionFilter_ShouldNotDependOnSinglePixelType<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
if (SkipAllDitherTests) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// Increased tolerance because of compatibility issues on .NET 4.6.2:
|
|
|
|
var comparer = ImageComparer.TolerantPercentage(1f); |
|
|
|
provider.RunValidatingProcessorTest(x => x.Diffuse(DefaultErrorDiffuser, 0.5f), comparer: comparer); |
|
|
|
@ -83,6 +105,11 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization |
|
|
|
IErrorDiffuser diffuser) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
if (SkipAllDitherTests) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
provider.RunValidatingProcessorTest( |
|
|
|
x => x.Diffuse(diffuser, 0.5f), |
|
|
|
testOutputDetails: diffuser.GetType().Name, |
|
|
|
@ -95,6 +122,11 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization |
|
|
|
public void DitherFilter_ShouldNotDependOnSinglePixelType<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
if (SkipAllDitherTests) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
provider.RunValidatingProcessorTest( |
|
|
|
x => x.Dither(DefaultDitherer), |
|
|
|
comparer: ValidatorComparer); |
|
|
|
@ -107,6 +139,11 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization |
|
|
|
IOrderedDither ditherer) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
if (SkipAllDitherTests) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
provider.RunValidatingProcessorTest( |
|
|
|
x => x.Dither(ditherer), |
|
|
|
testOutputDetails: ditherer.GetType().Name, |
|
|
|
|