// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp.Tests.Processing.Convolution { using ImageSharp.PixelFormats; using Xunit; public class GaussianBlurTest : FileTestBase { public static readonly TheoryData GaussianBlurValues = new TheoryData { 3, 5 }; [Theory] [WithFileCollection(nameof(AllBmpFiles), nameof(GaussianBlurValues), StandardPixelType)] public void ImageShouldApplyGaussianBlurFilter(TestImageProvider provider, int value) where TPixel : struct, IPixel { using (Image image = provider.GetImage()) { image.GaussianBlur(value) .DebugSave(provider, value, Extensions.Bmp); } } [Theory] [WithFileCollection(nameof(AllBmpFiles), nameof(GaussianBlurValues), StandardPixelType)] public void ImageShouldApplyGaussianBlurFilterInBox(TestImageProvider provider, int value) where TPixel : struct, IPixel { using (Image source = provider.GetImage()) using (var image = new Image(source)) { var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); image.GaussianBlur(value, bounds) .DebugSave(provider, value, Extensions.Bmp); // Draw identical shapes over the bounded and compare to ensure changes are constrained. image.Fill(NamedColors.HotPink, bounds); source.Fill(NamedColors.HotPink, bounds); ImageComparer.CheckSimilarity(image, source); } } } }