// // 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.Tests.TestUtilities.ImageComparison; using SixLabors.Primitives; using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution { [GroupOutput("Convolution")] public abstract class Basic1ParameterConvolutionTests { private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05F); public static readonly TheoryData Values = new TheoryData { 3, 5 }; public static readonly string[] InputImages = { TestImages.Bmp.Car, TestImages.Png.CalliphoraPartial }; [Theory] [WithFileCollection(nameof(InputImages), nameof(Values), PixelTypes.Rgba32)] public void OnFullImage(TestImageProvider provider, int value) where TPixel : struct, IPixel { provider.Utility.TestGroupName = this.GetType().Name; provider.RunValidatingProcessorTest( x => this.Apply(x, value), value, ValidatorComparer); } [Theory] [WithFileCollection(nameof(InputImages), nameof(Values), PixelTypes.Rgba32)] public void InBox(TestImageProvider provider, int value) where TPixel : struct, IPixel { provider.Utility.TestGroupName = this.GetType().Name; provider.RunRectangleConstrainedValidatingProcessorTest( (x, rect) => this.Apply(x, value, rect), value, ValidatorComparer); } protected abstract void Apply(IImageProcessingContext ctx, int value) where TPixel : struct, IPixel; protected abstract void Apply(IImageProcessingContext ctx, int value, Rectangle bounds) where TPixel : struct, IPixel; } }