diff --git a/ImageSharp.ruleset b/ImageSharp.ruleset index 2149364b1b..3567dc4b9e 100644 --- a/ImageSharp.ruleset +++ b/ImageSharp.ruleset @@ -7,5 +7,7 @@ temp remove the header requirement as stylecop is currently failing to read the stylecop.json file from 'dotnet build' --> + + \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs index 632b4d449d..46e27be78f 100644 --- a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Drawing.Processors public Point Location { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { Image targetImage = this.Image; PixelBlender blender = this.Blender; diff --git a/src/ImageSharp.Drawing/Processors/FillProcessor.cs b/src/ImageSharp.Drawing/Processors/FillProcessor.cs index 3bf18a37ba..b8cbddcba0 100644 --- a/src/ImageSharp.Drawing/Processors/FillProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/FillProcessor.cs @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Drawing.Processors } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { int startX = sourceRectangle.X; int endX = sourceRectangle.Right; diff --git a/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs b/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs index 076785526c..66a35f1517 100644 --- a/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Drawing.Processors public GraphicsOptions Options { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { Region region = this.Region; Rectangle rect = region.Bounds; diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/KnownDiffusers.cs b/src/ImageSharp/Dithering/ErrorDiffusion/Diffusers.cs similarity index 98% rename from src/ImageSharp/Dithering/ErrorDiffusion/KnownDiffusers.cs rename to src/ImageSharp/Dithering/ErrorDiffusion/Diffusers.cs index c75530b8e7..6e2055e34f 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/KnownDiffusers.cs +++ b/src/ImageSharp/Dithering/ErrorDiffusion/Diffusers.cs @@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Dithering /// /// Contains reusable static instances of known error diffusion algorithms /// - public static class KnownDiffusers + public static class Diffusers { /// /// Gets the error diffuser that implements the Atkinson algorithm. diff --git a/src/ImageSharp/Dithering/Ordered/KnownDitherers.cs b/src/ImageSharp/Dithering/Ordered/Ditherers.cs similarity index 97% rename from src/ImageSharp/Dithering/Ordered/KnownDitherers.cs rename to src/ImageSharp/Dithering/Ordered/Ditherers.cs index e58cbad8ab..53e94dca49 100644 --- a/src/ImageSharp/Dithering/Ordered/KnownDitherers.cs +++ b/src/ImageSharp/Dithering/Ordered/Ditherers.cs @@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Dithering /// /// Contains reusable static instances of known ordered dither matrices /// - public class KnownDitherers + public class Ditherers { /// /// Gets the order ditherer using the 2x2 Bayer dithering matrix diff --git a/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs b/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs index 5c720e61c3..4769bef1d7 100644 --- a/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs +++ b/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs @@ -8,10 +8,10 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder.ColorConverters { internal abstract partial class JpegColorConverter { - internal class FromGrayScale : ColorConverters.JpegColorConverter + internal class FromGrayscale : ColorConverters.JpegColorConverter { - public FromGrayScale() - : base(JpegColorSpace.GrayScale) + public FromGrayscale() + : base(JpegColorSpace.Grayscale) { } diff --git a/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.cs b/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.cs index 187b65f72b..4391be5484 100644 --- a/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.cs +++ b/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.cs @@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder.ColorConverters /// private static readonly JpegColorConverter[] Converters = { - GetYCbCrConverter(), new FromYccK(), new FromCmyk(), new FromGrayScale(), new FromRgb() + GetYCbCrConverter(), new FromYccK(), new FromCmyk(), new FromGrayscale(), new FromRgb() }; /// diff --git a/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegColorSpace.cs b/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegColorSpace.cs index da353d2795..abc93727e1 100644 --- a/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegColorSpace.cs +++ b/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegColorSpace.cs @@ -7,7 +7,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder { Undefined = 0, - GrayScale, + Grayscale, Ycck, diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs index 6cc275d49d..d3d1efe7fd 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs @@ -640,7 +640,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort switch (remaining) { - case 6 + (3 * 1): // Grayscale image. + case 6 + (3 * 1): // grayscale image. this.ComponentCount = 1; break; case 6 + (3 * 3): // YCbCr or RGB image. @@ -767,7 +767,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort switch (this.ComponentCount) { case 1: - return JpegColorSpace.GrayScale; + return JpegColorSpace.Grayscale; case 3: if (!this.isAdobe || this.adobe.ColorTransform == OrigJpegConstants.Adobe.ColorTransformYCbCr) { @@ -790,7 +790,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort } throw new ImageFormatException($"Unsupported color mode. Max components 4; found {this.ComponentCount}." - + "JpegDecoder only supports YCbCr, RGB, YccK, CMYK and Grayscale color spaces."); + + "JpegDecoder only supports YCbCr, RGB, YccK, CMYK and grayscale color spaces."); } private Image PostProcessIntoImage() diff --git a/src/ImageSharp/Formats/Png/PngDecoder.cs b/src/ImageSharp/Formats/Png/PngDecoder.cs index 9bde4f8cc3..57d45ecddb 100644 --- a/src/ImageSharp/Formats/Png/PngDecoder.cs +++ b/src/ImageSharp/Formats/Png/PngDecoder.cs @@ -20,8 +20,8 @@ namespace SixLabors.ImageSharp.Formats.Png /// /// RGBA (True color) with alpha (8 bit). /// RGB (True color) without alpha (8 bit). - /// Grayscale with alpha (8 bit). - /// Grayscale without alpha (8 bit). + /// grayscale with alpha (8 bit). + /// grayscale without alpha (8 bit). /// Palette Index with alpha (8 bit). /// Palette Index without alpha (8 bit). /// diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 1d1db2787a..dba4eaa15c 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -170,7 +170,7 @@ namespace SixLabors.ImageSharp.Formats.Png private Rgb24 rgb24Trans; /// - /// Represents any color in a Grayscale encoded png that should be transparent + /// Represents any color in a grayscale encoded png that should be transparent /// private byte intensityTrans; diff --git a/src/ImageSharp/IImageProcessor.cs b/src/ImageSharp/IImageProcessor.cs index bd6df8d835..c7fb565cac 100644 --- a/src/ImageSharp/IImageProcessor.cs +++ b/src/ImageSharp/IImageProcessor.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp /// is null. /// /// - /// doesnt fit the dimension of the image. + /// doesn't fit the dimension of the image. /// void Apply(Image source, Rectangle sourceRectangle); } diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 86a0ab7ea5..4433836793 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -37,7 +37,7 @@ - + All @@ -126,7 +126,4 @@ PorterDuffFunctions.Generated.tt - - - \ No newline at end of file diff --git a/src/ImageSharp/Numerics/ValueSize.cs b/src/ImageSharp/Numerics/ValueSize.cs index fcf61a586d..02573816d9 100644 --- a/src/ImageSharp/Numerics/ValueSize.cs +++ b/src/ImageSharp/Numerics/ValueSize.cs @@ -61,9 +61,9 @@ namespace SixLabors.ImageSharp /// /// Implicitly converts a float into an absolute value /// - /// the vlaue to use as the absolute figure. - public static implicit operator ValueSize(float d) - => Absolute(d); + /// the value to use as the absolute figure. + public static implicit operator ValueSize(float f) + => Absolute(f); /// /// Create a new ValueSize with as a PercentageOfWidth type with value set to percentage. @@ -99,7 +99,7 @@ namespace SixLabors.ImageSharp /// Calculates the specified size. /// /// The size. - /// The calucalted value + /// The calculated value public float Calculate(Size size) { switch (this.Type) @@ -123,7 +123,7 @@ namespace SixLabors.ImageSharp /// public bool Equals(ValueSize other) { - return this.Type == other.Type && this.Value == other.Value; + return this.Type == other.Type && this.Value.Equals(other.Value); } } } diff --git a/src/ImageSharp/Processing/Binarization/BinaryDiffuse.cs b/src/ImageSharp/Processing/Binarization/BinaryDiffuseExtensions.cs similarity index 82% rename from src/ImageSharp/Processing/Binarization/BinaryDiffuse.cs rename to src/ImageSharp/Processing/Binarization/BinaryDiffuseExtensions.cs index eb50087570..d06a9b75be 100644 --- a/src/ImageSharp/Processing/Binarization/BinaryDiffuse.cs +++ b/src/ImageSharp/Processing/Binarization/BinaryDiffuseExtensions.cs @@ -3,15 +3,15 @@ using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Binarization.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Binarization { /// - /// Extension methods for the type. + /// Adds binary diffusion extensions to the type. /// - public static partial class ImageExtensions + public static class BinaryDiffuseExtensions { /// /// Dithers the image reducing it to two colors using error diffusion. @@ -23,10 +23,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDiffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold)); - return source; - } + => source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold)); /// /// Dithers the image reducing it to two colors using error diffusion. @@ -41,10 +38,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDiffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold), rectangle); - return source; - } + => source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold), rectangle); /// /// Dithers the image reducing it to two colors using error diffusion. @@ -58,10 +52,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDiffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold, TPixel upperColor, TPixel lowerColor) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold, upperColor, lowerColor)); - return source; - } + => source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold, upperColor, lowerColor)); /// /// Dithers the image reducing it to two colors using error diffusion. @@ -78,9 +69,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDiffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold, TPixel upperColor, TPixel lowerColor, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold, upperColor, lowerColor), rectangle); - return source; - } + => source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold, upperColor, lowerColor), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Binarization/BinaryDither.cs b/src/ImageSharp/Processing/Binarization/BinaryDitherExtensions.cs similarity index 81% rename from src/ImageSharp/Processing/Binarization/BinaryDither.cs rename to src/ImageSharp/Processing/Binarization/BinaryDitherExtensions.cs index 715dff472d..039fc57b7e 100644 --- a/src/ImageSharp/Processing/Binarization/BinaryDither.cs +++ b/src/ImageSharp/Processing/Binarization/BinaryDitherExtensions.cs @@ -3,15 +3,15 @@ using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Binarization.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Binarization { /// - /// Extension methods for the type. + /// Adds binary dithering extensions to the type. /// - public static partial class ImageExtensions + public static class BinaryDitherExtensions { /// /// Dithers the image reducing it to two colors using ordered dithering. @@ -22,10 +22,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDither(this IImageProcessingContext source, IOrderedDither dither) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither)); - return source; - } + => source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither)); /// /// Dithers the image reducing it to two colors using ordered dithering. @@ -38,10 +35,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDither(this IImageProcessingContext source, IOrderedDither dither, TPixel upperColor, TPixel lowerColor) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither, upperColor, lowerColor)); - return source; - } + => source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither, upperColor, lowerColor)); /// /// Dithers the image reducing it to two colors using ordered dithering. @@ -55,10 +49,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDither(this IImageProcessingContext source, IOrderedDither dither, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither), rectangle); - return source; - } + => source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither), rectangle); /// /// Dithers the image reducing it to two colors using ordered dithering. @@ -74,9 +65,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDither(this IImageProcessingContext source, IOrderedDither dither, TPixel upperColor, TPixel lowerColor, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither, upperColor, lowerColor), rectangle); - return source; - } + => source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither, upperColor, lowerColor), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Binarization/BinaryThreshold.cs b/src/ImageSharp/Processing/Binarization/BinaryThresholdExtensions.cs similarity index 82% rename from src/ImageSharp/Processing/Binarization/BinaryThreshold.cs rename to src/ImageSharp/Processing/Binarization/BinaryThresholdExtensions.cs index 3f86528f51..0050613948 100644 --- a/src/ImageSharp/Processing/Binarization/BinaryThreshold.cs +++ b/src/ImageSharp/Processing/Binarization/BinaryThresholdExtensions.cs @@ -2,15 +2,15 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Binarization.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Binarization { /// - /// Extension methods for the type. + /// Adds binary thresholding extensions to the type. /// - public static partial class ImageExtensions + public static class BinaryThresholdExtensions { /// /// Applies binarization to the image splitting the pixels at the given threshold. @@ -21,10 +21,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryThresholdProcessor(threshold)); - return source; - } + => source.ApplyProcessor(new BinaryThresholdProcessor(threshold)); /// /// Applies binarization to the image splitting the pixels at the given threshold. @@ -38,10 +35,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryThresholdProcessor(threshold), rectangle); - return source; - } + => source.ApplyProcessor(new BinaryThresholdProcessor(threshold), rectangle); /// /// Applies binarization to the image splitting the pixels at the given threshold. @@ -54,10 +48,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold, TPixel upperColor, TPixel lowerColor) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor)); - return source; - } + => source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor)); /// /// Applies binarization to the image splitting the pixels at the given threshold. @@ -73,9 +64,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold, TPixel upperColor, TPixel lowerColor, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor), rectangle); - return source; - } + => source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor), rectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs similarity index 96% rename from src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor.cs rename to src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs index 80a4236452..9e96ddcde6 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs @@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Binarization.Processors { /// /// Performs binary threshold filtering against an image using error diffusion. @@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public TPixel LowerColor { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { float threshold = this.Threshold * 255F; var rgba = default(Rgba32); diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs similarity index 95% rename from src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs rename to src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs index baa8df8cca..8d72ba66fa 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs @@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Binarization.Processors { /// /// Performs binary threshold filtering against an image using ordered dithering. @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public TPixel LowerColor { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { var rgba = default(Rgba32); bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8); diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs similarity index 94% rename from src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs rename to src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs index 609b090923..39d829c73a 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs @@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Binarization.Processors { /// /// Performs simple binary threshold filtering against an image. @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public TPixel LowerColor { get; set; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { float threshold = this.Threshold * 255F; TPixel upper = this.UpperColor; diff --git a/src/ImageSharp/Processing/ColorMatrix/Lomograph.cs b/src/ImageSharp/Processing/ColorMatrix/Lomograph.cs deleted file mode 100644 index ca79841c76..0000000000 --- a/src/ImageSharp/Processing/ColorMatrix/Lomograph.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; -using SixLabors.Primitives; - -namespace SixLabors.ImageSharp -{ - /// - /// Extension methods for the type. - /// - public static partial class ImageExtensions - { - /// - /// Alters the colors of the image recreating an old Lomograph camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// The . - public static IImageProcessingContext Lomograph(this IImageProcessingContext source) - where TPixel : struct, IPixel - { - return Lomograph(source, GraphicsOptions.Default); - } - - /// - /// Alters the colors of the image recreating an old Lomograph camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// - /// The structure that specifies the portion of the image object to alter. - /// - /// The . - public static IImageProcessingContext Lomograph(this IImageProcessingContext source, Rectangle rectangle) - where TPixel : struct, IPixel - { - return Lomograph(source, rectangle, GraphicsOptions.Default); - } - - /// - /// Alters the colors of the image recreating an old Lomograph camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// The options effecting pixel blending. - /// The . - public static IImageProcessingContext Lomograph(this IImageProcessingContext source, GraphicsOptions options) - where TPixel : struct, IPixel - { - source.ApplyProcessor(new LomographProcessor(source.MemoryManager, options)); - return source; - } - - /// - /// Alters the colors of the image recreating an old Lomograph camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// - /// The structure that specifies the portion of the image object to alter. - /// - /// The options effecting pixel blending. - /// The . - public static IImageProcessingContext Lomograph(this IImageProcessingContext source, Rectangle rectangle, GraphicsOptions options) - where TPixel : struct, IPixel - { - source.ApplyProcessor(new LomographProcessor(source.MemoryManager, options), rectangle); - return source; - } - } -} diff --git a/src/ImageSharp/Processing/ColorMatrix/Polaroid.cs b/src/ImageSharp/Processing/ColorMatrix/Polaroid.cs deleted file mode 100644 index d12cc76122..0000000000 --- a/src/ImageSharp/Processing/ColorMatrix/Polaroid.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; -using SixLabors.Primitives; - -namespace SixLabors.ImageSharp -{ - /// - /// Extension methods for the type. - /// - public static partial class ImageExtensions - { - /// - /// Alters the colors of the image recreating an old Polaroid camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// The . - public static IImageProcessingContext Polaroid(this IImageProcessingContext source) - where TPixel : struct, IPixel - { - return Polaroid(source, GraphicsOptions.Default); - } - - /// - /// Alters the colors of the image recreating an old Polaroid camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// - /// The structure that specifies the portion of the image object to alter. - /// - /// The . - public static IImageProcessingContext Polaroid(this IImageProcessingContext source, Rectangle rectangle) - where TPixel : struct, IPixel - { - return Polaroid(source, rectangle, GraphicsOptions.Default); - } - - /// - /// Alters the colors of the image recreating an old Polaroid camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// The options effecting pixel blending. - /// The . - public static IImageProcessingContext Polaroid(this IImageProcessingContext source, GraphicsOptions options) - where TPixel : struct, IPixel - { - source.ApplyProcessor(new PolaroidProcessor(source.MemoryManager, options)); - return source; - } - - /// - /// Alters the colors of the image recreating an old Polaroid camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// - /// The structure that specifies the portion of the image object to alter. - /// - /// The options effecting pixel blending. - /// The . - public static IImageProcessingContext Polaroid(this IImageProcessingContext source, Rectangle rectangle, GraphicsOptions options) - where TPixel : struct, IPixel - { - source.ApplyProcessor(new PolaroidProcessor(source.MemoryManager, options), rectangle); - return source; - } - } -} diff --git a/src/ImageSharp/Processing/Convolution/BoxBlur.cs b/src/ImageSharp/Processing/Convolution/BoxBlurExtensions.cs similarity index 90% rename from src/ImageSharp/Processing/Convolution/BoxBlur.cs rename to src/ImageSharp/Processing/Convolution/BoxBlurExtensions.cs index b0c6ffc8d2..edb798fb41 100644 --- a/src/ImageSharp/Processing/Convolution/BoxBlur.cs +++ b/src/ImageSharp/Processing/Convolution/BoxBlurExtensions.cs @@ -1,17 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Convolution.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Convolution { /// - /// Extension methods for the type. + /// Adds box blurring extensions to the type. /// - public static partial class ImageExtensions + public static class BoxBlurExtensions { /// /// Applies a box blur to the image. @@ -21,7 +20,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BoxBlur(this IImageProcessingContext source) where TPixel : struct, IPixel - => source.ApplyProcessor(new BoxBlurProcessor(7)); + => source.ApplyProcessor(new BoxBlurProcessor()); /// /// Applies a box blur to the image. @@ -48,4 +47,4 @@ namespace SixLabors.ImageSharp where TPixel : struct, IPixel => source.ApplyProcessor(new BoxBlurProcessor(radius), rectangle); } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/DetectEdges.cs b/src/ImageSharp/Processing/Convolution/DetectEdgesExtensions.cs similarity index 74% rename from src/ImageSharp/Processing/Convolution/DetectEdges.cs rename to src/ImageSharp/Processing/Convolution/DetectEdgesExtensions.cs index 79e7ac6cf4..a2b2b244bd 100644 --- a/src/ImageSharp/Processing/Convolution/DetectEdges.cs +++ b/src/ImageSharp/Processing/Convolution/DetectEdgesExtensions.cs @@ -1,35 +1,31 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Convolution.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Convolution { /// - /// Extension methods for the type. + /// Adds edge detection extensions to the type. /// - public static partial class ImageExtensions + public static class DetectEdgesExtensions { /// /// Detects any edges within the image. Uses the filter - /// operating in Grayscale mode. + /// operating in grayscale mode. /// /// The pixel format. /// The image this method extends. /// The . public static IImageProcessingContext DetectEdges(this IImageProcessingContext source) where TPixel : struct, IPixel - { - return DetectEdges(source, new SobelProcessor { Grayscale = true }); - } + => DetectEdges(source, new SobelProcessor(true)); /// /// Detects any edges within the image. Uses the filter - /// operating in Grayscale mode. + /// operating in grayscale mode. /// /// The pixel format. /// The image this method extends. @@ -39,9 +35,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, Rectangle rectangle) where TPixel : struct, IPixel - { - return DetectEdges(source, rectangle, new SobelProcessor { Grayscale = true }); - } + => DetectEdges(source, rectangle, new SobelProcessor(true)); /// /// Detects any edges within the image. @@ -50,7 +44,7 @@ namespace SixLabors.ImageSharp /// The image this method extends. /// The filter for detecting edges. /// The . - public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, EdgeDetection filter) + public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, EdgeDetectionOperators filter) where TPixel : struct, IPixel => DetectEdges(source, GetProcessor(filter, true)); @@ -60,9 +54,9 @@ namespace SixLabors.ImageSharp /// The pixel format. /// The image this method extends. /// The filter for detecting edges. - /// Whether to convert the image to Grayscale first. Defaults to true. + /// Whether to convert the image to grayscale first. Defaults to true. /// The . - public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, EdgeDetection filter, bool grayscale) + public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, EdgeDetectionOperators filter, bool grayscale) where TPixel : struct, IPixel => DetectEdges(source, GetProcessor(filter, grayscale)); @@ -75,9 +69,9 @@ namespace SixLabors.ImageSharp /// /// The structure that specifies the portion of the image object to alter. /// - /// Whether to convert the image to Grayscale first. Defaults to true. + /// Whether to convert the image to grayscale first. Defaults to true. /// The . - public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, EdgeDetection filter, Rectangle rectangle, bool grayscale = true) + public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, EdgeDetectionOperators filter, Rectangle rectangle, bool grayscale = true) where TPixel : struct, IPixel => DetectEdges(source, rectangle, GetProcessor(filter, grayscale)); @@ -111,51 +105,51 @@ namespace SixLabors.ImageSharp return source; } - private static IEdgeDetectorProcessor GetProcessor(EdgeDetection filter, bool grayscale) + private static IEdgeDetectorProcessor GetProcessor(EdgeDetectionOperators filter, bool grayscale) where TPixel : struct, IPixel { IEdgeDetectorProcessor processor; switch (filter) { - case EdgeDetection.Kayyali: - processor = new KayyaliProcessor { Grayscale = grayscale }; + case EdgeDetectionOperators.Kayyali: + processor = new KayyaliProcessor(grayscale); break; - case EdgeDetection.Kirsch: - processor = new KirschProcessor { Grayscale = grayscale }; + case EdgeDetectionOperators.Kirsch: + processor = new KirschProcessor(grayscale); break; - case EdgeDetection.Lapacian3X3: - processor = new Laplacian3X3Processor { Grayscale = grayscale }; + case EdgeDetectionOperators.Laplacian3x3: + processor = new Laplacian3x3Processor(grayscale); break; - case EdgeDetection.Lapacian5X5: - processor = new Laplacian5X5Processor { Grayscale = grayscale }; + case EdgeDetectionOperators.Laplacian5x5: + processor = new Laplacian5x5Processor(grayscale); break; - case EdgeDetection.LaplacianOfGaussian: - processor = new LaplacianOfGaussianProcessor { Grayscale = grayscale }; + case EdgeDetectionOperators.LaplacianOfGaussian: + processor = new LaplacianOfGaussianProcessor(grayscale); break; - case EdgeDetection.Prewitt: - processor = new PrewittProcessor { Grayscale = grayscale }; + case EdgeDetectionOperators.Prewitt: + processor = new PrewittProcessor(grayscale); break; - case EdgeDetection.RobertsCross: - processor = new RobertsCrossProcessor { Grayscale = grayscale }; + case EdgeDetectionOperators.RobertsCross: + processor = new RobertsCrossProcessor(grayscale); break; - case EdgeDetection.Robinson: - processor = new RobinsonProcessor { Grayscale = grayscale }; + case EdgeDetectionOperators.Robinson: + processor = new RobinsonProcessor(grayscale); break; - case EdgeDetection.Scharr: - processor = new ScharrProcessor { Grayscale = grayscale }; + case EdgeDetectionOperators.Scharr: + processor = new ScharrProcessor(grayscale); break; default: - processor = new SobelProcessor { Grayscale = grayscale }; + processor = new SobelProcessor(grayscale); break; } diff --git a/src/ImageSharp/Processing/Convolution/Options/EdgeDetection.cs b/src/ImageSharp/Processing/Convolution/EdgeDetectionOperators.cs similarity index 83% rename from src/ImageSharp/Processing/Convolution/Options/EdgeDetection.cs rename to src/ImageSharp/Processing/Convolution/EdgeDetectionOperators.cs index b01bb945cf..55cbbeaf7d 100644 --- a/src/ImageSharp/Processing/Convolution/Options/EdgeDetection.cs +++ b/src/ImageSharp/Processing/Convolution/EdgeDetectionOperators.cs @@ -1,12 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Convolution { /// /// Enumerates the various types of defined edge detection filters. /// - public enum EdgeDetection + public enum EdgeDetectionOperators { /// /// The Kayyali operator filter. @@ -19,14 +19,14 @@ namespace SixLabors.ImageSharp.Processing Kirsch, /// - /// The Lapacian3X3 operator filter. + /// The Laplacian3X3 operator filter. /// - Lapacian3X3, + Laplacian3x3, /// - /// The Lapacian5X5 operator filter. + /// The Laplacian5X5 operator filter. /// - Lapacian5X5, + Laplacian5x5, /// /// The LaplacianOfGaussian operator filter. @@ -58,4 +58,4 @@ namespace SixLabors.ImageSharp.Processing /// Sobel } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/GaussianBlur.cs b/src/ImageSharp/Processing/Convolution/GaussianBlurExtensions.cs similarity index 89% rename from src/ImageSharp/Processing/Convolution/GaussianBlur.cs rename to src/ImageSharp/Processing/Convolution/GaussianBlurExtensions.cs index 9bca97242c..ae3eace640 100644 --- a/src/ImageSharp/Processing/Convolution/GaussianBlur.cs +++ b/src/ImageSharp/Processing/Convolution/GaussianBlurExtensions.cs @@ -1,18 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Convolution.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Convolution { /// - /// Extension methods for the type. + /// Adds Gaussian blurring extensions to the type. /// - public static partial class ImageExtensions + public static class GaussianBlurExtensions { /// /// Applies a Gaussian blur to the image. @@ -22,7 +20,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext GaussianBlur(this IImageProcessingContext source) where TPixel : struct, IPixel - => source.ApplyProcessor(new GaussianBlurProcessor(3f)); + => source.ApplyProcessor(new GaussianBlurProcessor()); /// /// Applies a Gaussian blur to the image. diff --git a/src/ImageSharp/Processing/Convolution/GaussianSharpen.cs b/src/ImageSharp/Processing/Convolution/GaussianSharpenExtensions.cs similarity index 89% rename from src/ImageSharp/Processing/Convolution/GaussianSharpen.cs rename to src/ImageSharp/Processing/Convolution/GaussianSharpenExtensions.cs index 1cea2dae9b..334a02b79b 100644 --- a/src/ImageSharp/Processing/Convolution/GaussianSharpen.cs +++ b/src/ImageSharp/Processing/Convolution/GaussianSharpenExtensions.cs @@ -1,18 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Convolution.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Convolution { /// - /// Extension methods for the type. + /// Adds Gaussian sharpening extensions to the type. /// - public static partial class ImageExtensions + public static class GaussianSharpenExtensions { /// /// Applies a Gaussian sharpening filter to the image. @@ -22,7 +20,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext GaussianSharpen(this IImageProcessingContext source) where TPixel : struct, IPixel - => source.ApplyProcessor(new GaussianSharpenProcessor(3f)); + => source.ApplyProcessor(new GaussianSharpenProcessor()); /// /// Applies a Gaussian sharpening filter to the image. diff --git a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/BoxBlurProcessor.cs similarity index 91% rename from src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/BoxBlurProcessor.cs index 8056141a09..df3d56bdae 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/BoxBlurProcessor.cs @@ -1,15 +1,15 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// - /// Applies a Box blur sampler to the image. + /// Applies box blur processing to the image. /// /// The pixel format. internal class BoxBlurProcessor : ImageProcessor @@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Fast2DArray KernelY { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { new Convolution2PassProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle, configuration); } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs similarity index 95% rename from src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs index 2c13ead162..4e46984677 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs @@ -12,7 +12,7 @@ using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Processors { /// - /// Defines a sampler that uses two one-dimensional matrices to perform convolution against an image. + /// Defines a processor that uses two one-dimensional matrices to perform convolution against an image. /// /// The pixel format. internal class Convolution2DProcessor : ImageProcessor @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Fast2DArray KernelY { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { int kernelYHeight = this.KernelY.Height; int kernelYWidth = this.KernelY.Width; diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs similarity index 95% rename from src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs index 0d87aa1dc4..3ea025512c 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs @@ -13,7 +13,7 @@ using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Processors { /// - /// Defines a sampler that uses two one-dimensional matrices to perform two-pass convolution against an image. + /// Defines a processor that uses two one-dimensional matrices to perform two-pass convolution against an image. /// /// The pixel format. internal class Convolution2PassProcessor : ImageProcessor @@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Fast2DArray KernelY { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { ParallelOptions parallelOptions = configuration.ParallelOptions; diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs similarity index 94% rename from src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs index 2f369113d9..2eff3bf213 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs @@ -13,7 +13,7 @@ using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Processors { /// - /// Defines a sampler that uses a 2 dimensional matrix to perform convolution against an image. + /// Defines a processor that uses a 2 dimensional matrix to perform convolution against an image. /// /// The pixel format. internal class ConvolutionProcessor : ImageProcessor @@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Fast2DArray KernelXY { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { int kernelLength = this.KernelXY.Height; int radius = kernelLength >> 1; diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetector2DProcessor.cs similarity index 69% rename from src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/EdgeDetector2DProcessor.cs index 741a6e308c..74a0194452 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetector2DProcessor.cs @@ -1,15 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Filters.Processors; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// - /// Defines a sampler that detects edges within an image using two one-dimensional matrices. + /// Defines a processor that detects edges within an image using two one-dimensional matrices. /// /// The pixel format. internal abstract class EdgeDetector2DProcessor : ImageProcessor, IEdgeDetectorProcessor @@ -20,10 +21,12 @@ namespace SixLabors.ImageSharp.Processing.Processors /// /// The horizontal gradient operator. /// The vertical gradient operator. - protected EdgeDetector2DProcessor(Fast2DArray kernelX, Fast2DArray kernelY) + /// Whether to convert the image to grayscale before performing edge detection. + protected EdgeDetector2DProcessor(Fast2DArray kernelX, Fast2DArray kernelY, bool grayscale) { this.KernelX = kernelX; this.KernelY = kernelY; + this.Grayscale = grayscale; } /// @@ -40,13 +43,13 @@ namespace SixLabors.ImageSharp.Processing.Processors public bool Grayscale { get; set; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { new Convolution2DProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle, configuration); } /// - protected override void BeforeApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void BeforeFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { if (this.Grayscale) { diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorCompassProcessor.cs similarity index 83% rename from src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorCompassProcessor.cs index 0ffd7d48f5..df26c23b82 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorCompassProcessor.cs @@ -4,20 +4,30 @@ using System; using System.Numerics; using System.Threading.Tasks; -using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Filters.Processors; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// - /// Defines a sampler that detects edges within an image using a eight two dimensional matrices. + /// Defines a processor that detects edges within an image using a eight two dimensional matrices. /// /// The pixel format. internal abstract class EdgeDetectorCompassProcessor : ImageProcessor, IEdgeDetectorProcessor where TPixel : struct, IPixel { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + protected EdgeDetectorCompassProcessor(bool grayscale) + { + this.Grayscale = grayscale; + } + /// /// Gets the North gradient operator /// @@ -59,10 +69,10 @@ namespace SixLabors.ImageSharp.Processing.Processors public abstract Fast2DArray NorthEast { get; } /// - public bool Grayscale { get; set; } + public bool Grayscale { get; } /// - protected override void BeforeApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void BeforeFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { if (this.Grayscale) { @@ -71,7 +81,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { Fast2DArray[] kernels = { this.North, this.NorthWest, this.West, this.SouthWest, this.South, this.SouthEast, this.East, this.NorthEast }; diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorProcessor.cs similarity index 64% rename from src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorProcessor.cs index e5c5179716..cd2e7d76ca 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorProcessor.cs @@ -1,15 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Filters.Processors; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// - /// Defines a sampler that detects edges within an image using a single two dimensional matrix. + /// Defines a processor that detects edges within an image using a single two dimensional matrix. /// /// The pixel format. internal abstract class EdgeDetectorProcessor : ImageProcessor, IEdgeDetectorProcessor @@ -19,13 +20,15 @@ namespace SixLabors.ImageSharp.Processing.Processors /// Initializes a new instance of the class. /// /// The 2d gradient operator. - protected EdgeDetectorProcessor(Fast2DArray kernelXY) + /// Whether to convert the image to grayscale before performing edge detection. + protected EdgeDetectorProcessor(Fast2DArray kernelXY, bool grayscale) { this.KernelXY = kernelXY; + this.Grayscale = grayscale; } /// - public bool Grayscale { get; set; } + public bool Grayscale { get; } /// /// Gets the 2d gradient operator. @@ -33,7 +36,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Fast2DArray KernelXY { get; } /// - protected override void BeforeApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void BeforeFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { if (this.Grayscale) { @@ -42,7 +45,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { new ConvolutionProcessor(this.KernelXY).Apply(source, sourceRectangle, configuration); } diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs similarity index 88% rename from src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs index c897efeed8..3ce321cd39 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs @@ -4,12 +4,13 @@ using System; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// - /// Applies a Gaussian blur sampler to the image. + /// Applies Gaussian blur processing to the image. /// /// The pixel format. internal class GaussianBlurProcessor : ImageProcessor @@ -20,11 +21,6 @@ namespace SixLabors.ImageSharp.Processing.Processors /// private readonly int kernelSize; - /// - /// The spread of the blur. - /// - private readonly float sigma; - /// /// Initializes a new instance of the class. /// @@ -32,7 +28,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public GaussianBlurProcessor(float sigma = 3f) { this.kernelSize = ((int)Math.Ceiling(sigma) * 2) + 1; - this.sigma = sigma; + this.Sigma = sigma; this.KernelX = this.CreateGaussianKernel(true); this.KernelY = this.CreateGaussianKernel(false); } @@ -46,7 +42,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public GaussianBlurProcessor(int radius) { this.kernelSize = (radius * 2) + 1; - this.sigma = radius; + this.Sigma = radius; this.KernelX = this.CreateGaussianKernel(true); this.KernelY = this.CreateGaussianKernel(false); } @@ -64,15 +60,15 @@ namespace SixLabors.ImageSharp.Processing.Processors public GaussianBlurProcessor(float sigma, int radius) { this.kernelSize = (radius * 2) + 1; - this.sigma = sigma; + this.Sigma = sigma; this.KernelX = this.CreateGaussianKernel(true); this.KernelY = this.CreateGaussianKernel(false); } /// - /// Gets the sigma + /// Gets the sigma value representing the weight of the blur /// - public float Sigma => this.sigma; + public float Sigma { get; } /// /// Gets the horizontal gradient operator. @@ -85,7 +81,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Fast2DArray KernelY { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { new Convolution2PassProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle, configuration); } @@ -98,7 +94,7 @@ namespace SixLabors.ImageSharp.Processing.Processors private Fast2DArray CreateGaussianKernel(bool horizontal) { int size = this.kernelSize; - float weight = this.sigma; + float weight = this.Sigma; Fast2DArray kernel = horizontal ? new Fast2DArray(size, 1) : new Fast2DArray(1, size); diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs similarity index 89% rename from src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs index b960e9075f..cff0767b1d 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs @@ -4,12 +4,13 @@ using System; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// - /// Applies a Gaussian sharpening sampler to the image. + /// Applies Gaussian sharpening processing to the image. /// /// The pixel format. internal class GaussianSharpenProcessor : ImageProcessor @@ -20,11 +21,6 @@ namespace SixLabors.ImageSharp.Processing.Processors /// private readonly int kernelSize; - /// - /// The spread of the blur. - /// - private readonly float sigma; - /// /// Initializes a new instance of the class. /// @@ -34,7 +30,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public GaussianSharpenProcessor(float sigma = 3f) { this.kernelSize = ((int)Math.Ceiling(sigma) * 2) + 1; - this.sigma = sigma; + this.Sigma = sigma; this.KernelX = this.CreateGaussianKernel(true); this.KernelY = this.CreateGaussianKernel(false); } @@ -48,7 +44,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public GaussianSharpenProcessor(int radius) { this.kernelSize = (radius * 2) + 1; - this.sigma = radius; + this.Sigma = radius; this.KernelX = this.CreateGaussianKernel(true); this.KernelY = this.CreateGaussianKernel(false); } @@ -66,15 +62,15 @@ namespace SixLabors.ImageSharp.Processing.Processors public GaussianSharpenProcessor(float sigma, int radius) { this.kernelSize = (radius * 2) + 1; - this.sigma = sigma; + this.Sigma = sigma; this.KernelX = this.CreateGaussianKernel(true); this.KernelY = this.CreateGaussianKernel(false); } /// - /// Gets the sigma + /// Gets the sigma value representing the weight of the blur /// - public float Sigma => this.sigma; + public float Sigma { get; } /// /// Gets the horizontal gradient operator. @@ -87,7 +83,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Fast2DArray KernelY { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { new Convolution2PassProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle, configuration); } @@ -100,7 +96,7 @@ namespace SixLabors.ImageSharp.Processing.Processors private Fast2DArray CreateGaussianKernel(bool horizontal) { int size = this.kernelSize; - float weight = this.sigma; + float weight = this.Sigma; Fast2DArray kernel = horizontal ? new Fast2DArray(size, 1) : new Fast2DArray(1, size); @@ -159,7 +155,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } } - // Normalise kernel so that the sum of all weights equals 1 + // Normalize kernel so that the sum of all weights equals 1 if (horizontal) { for (int i = 0; i < size; i++) diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/IEdgeDetectorProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/IEdgeDetectorProcessor.cs similarity index 77% rename from src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/IEdgeDetectorProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/IEdgeDetectorProcessor.cs index 6208a24a46..e43aff70b8 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/IEdgeDetectorProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/IEdgeDetectorProcessor.cs @@ -1,10 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// /// Provides properties and methods allowing the detection of edges within an image. @@ -21,8 +20,8 @@ namespace SixLabors.ImageSharp.Processing public interface IEdgeDetectorProcessor { /// - /// Gets or sets a value indicating whether to convert the image to grayscale before performing edge detection. + /// Gets a value indicating whether to convert the image to grayscale before performing edge detection. /// - bool Grayscale { get; set; } + bool Grayscale { get; } } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/KayyaliKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/KayyaliKernels.cs new file mode 100644 index 0000000000..b18bd52af2 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/KayyaliKernels.cs @@ -0,0 +1,35 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains the kernels used for Kayyali edge detection + /// + internal static class KayyaliKernels + { + /// + /// Gets the horizontal gradient operator. + /// + public static Fast2DArray KayyaliX => + new float[,] + { + { 6, 0, -6 }, + { 0, 0, 0 }, + { -6, 0, 6 } + }; + + /// + /// Gets the vertical gradient operator. + /// + public static Fast2DArray KayyaliY => + new float[,] + { + { -6, 0, 6 }, + { 0, 0, 0 }, + { 6, 0, -6 } + }; + } +} diff --git a/src/ImageSharp/Processing/Convolution/Processors/KayyaliProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/KayyaliProcessor.cs new file mode 100644 index 0000000000..357c6c3970 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/KayyaliProcessor.cs @@ -0,0 +1,24 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Kayyali operator filter. + /// + /// The pixel format. + internal class KayyaliProcessor : EdgeDetector2DProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public KayyaliProcessor(bool grayscale) + : base(KayyaliKernels.KayyaliX, KayyaliKernels.KayyaliY, grayscale) + { + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/KirschProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/KirschProcessor.cs new file mode 100644 index 0000000000..3ae333e18e --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/KirschProcessor.cs @@ -0,0 +1,49 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Kirsch operator filter. + /// + /// The pixel format. + internal class KirschProcessor : EdgeDetectorCompassProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public KirschProcessor(bool grayscale) + : base(grayscale) + { + } + + /// + public override Fast2DArray North => KirshKernels.KirschNorth; + + /// + public override Fast2DArray NorthWest => KirshKernels.KirschNorthWest; + + /// + public override Fast2DArray West => KirshKernels.KirschWest; + + /// + public override Fast2DArray SouthWest => KirshKernels.KirschSouthWest; + + /// + public override Fast2DArray South => KirshKernels.KirschSouth; + + /// + public override Fast2DArray SouthEast => KirshKernels.KirschSouthEast; + + /// + public override Fast2DArray East => KirshKernels.KirschEast; + + /// + public override Fast2DArray NorthEast => KirshKernels.KirschNorthEast; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/KirshKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/KirshKernels.cs new file mode 100644 index 0000000000..99c327055f --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/KirshKernels.cs @@ -0,0 +1,101 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains the eight matrices used for Kirsh edge detection + /// + internal static class KirshKernels + { + /// + /// Gets the North gradient operator + /// + public static Fast2DArray KirschNorth => + new float[,] + { + { 5, 5, 5 }, + { -3, 0, -3 }, + { -3, -3, -3 } + }; + + /// + /// Gets the NorthWest gradient operator + /// + public static Fast2DArray KirschNorthWest => + new float[,] + { + { 5, 5, -3 }, + { 5, 0, -3 }, + { -3, -3, -3 } + }; + + /// + /// Gets the West gradient operator + /// + public static Fast2DArray KirschWest => + new float[,] + { + { 5, -3, -3 }, + { 5, 0, -3 }, + { 5, -3, -3 } + }; + + /// + /// Gets the SouthWest gradient operator + /// + public static Fast2DArray KirschSouthWest => + new float[,] + { + { -3, -3, -3 }, + { 5, 0, -3 }, + { 5, 5, -3 } + }; + + /// + /// Gets the South gradient operator + /// + public static Fast2DArray KirschSouth => + new float[,] + { + { -3, -3, -3 }, + { -3, 0, -3 }, + { 5, 5, 5 } + }; + + /// + /// Gets the SouthEast gradient operator + /// + public static Fast2DArray KirschSouthEast => + new float[,] + { + { -3, -3, -3 }, + { -3, 0, 5 }, + { -3, 5, 5 } + }; + + /// + /// Gets the East gradient operator + /// + public static Fast2DArray KirschEast => + new float[,] + { + { -3, -3, 5 }, + { -3, 0, 5 }, + { -3, -3, 5 } + }; + + /// + /// Gets the NorthEast gradient operator + /// + public static Fast2DArray KirschNorthEast => + new float[,] + { + { -3, 5, 5 }, + { -3, 0, 5 }, + { -3, -3, -3 } + }; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/Laplacian3x3Processor.cs b/src/ImageSharp/Processing/Convolution/Processors/Laplacian3x3Processor.cs new file mode 100644 index 0000000000..657a93c816 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/Laplacian3x3Processor.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Laplacian 3x3 operator filter. + /// + /// + /// The pixel format. + internal class Laplacian3x3Processor : EdgeDetectorProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public Laplacian3x3Processor(bool grayscale) + : base(LaplacianKernels.Laplacian3x3, grayscale) + { + } + } +} diff --git a/src/ImageSharp/Processing/Convolution/Processors/Laplacian5x5Processor.cs b/src/ImageSharp/Processing/Convolution/Processors/Laplacian5x5Processor.cs new file mode 100644 index 0000000000..5b44773add --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/Laplacian5x5Processor.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Laplacian 5x5 operator filter. + /// + /// + /// The pixel format. + internal class Laplacian5x5Processor : EdgeDetectorProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public Laplacian5x5Processor(bool grayscale) + : base(LaplacianKernels.Laplacian5x5, grayscale) + { + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernelFactory.cs b/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernelFactory.cs new file mode 100644 index 0000000000..e28da14b55 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernelFactory.cs @@ -0,0 +1,40 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// A factory for creating Laplacian kernel matrices. + /// + internal static class LaplacianKernelFactory + { + /// + /// Creates a Laplacian matrix, 2nd derivative, of an arbitrary length. + /// + /// + /// The length of the matrix sides + /// The + public static Fast2DArray CreateKernel(uint length) + { + Guard.MustBeGreaterThanOrEqualTo(length, 3u, nameof(length)); + Guard.IsFalse(length % 2 == 0, nameof(length), "The kernel length must be an odd number."); + + var kernel = new Fast2DArray((int)length); + + for (int y = 0; y < kernel.Height; y++) + { + for (int x = 0; x < kernel.Width; x++) + { + kernel[x, y] = -1; + } + } + + int mid = (int)(length / 2); + kernel[mid, mid] = (length * length) - 1; + + return kernel; + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernels.cs new file mode 100644 index 0000000000..611982b9a5 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernels.cs @@ -0,0 +1,36 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains Laplacian kernels of different sizes + /// + internal static class LaplacianKernels + { + /// + /// Gets the 3x3 Laplacian kernel + /// + public static Fast2DArray Laplacian3x3 => LaplacianKernelFactory.CreateKernel(3); + + /// + /// Gets the 5x5 Laplacian kernel + /// + public static Fast2DArray Laplacian5x5 => LaplacianKernelFactory.CreateKernel(5); + + /// + /// Gets the Laplacian of Gaussian kernel. + /// + public static Fast2DArray LaplacianOfGaussianXY => + new float[,] + { + { 0, 0, -1, 0, 0 }, + { 0, -1, -2, -1, 0 }, + { -1, -2, 16, -2, -1 }, + { 0, -1, -2, -1, 0 }, + { 0, 0, -1, 0, 0 } + }; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/LaplacianOfGaussianProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/LaplacianOfGaussianProcessor.cs new file mode 100644 index 0000000000..e65e0d2152 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/LaplacianOfGaussianProcessor.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Laplacian of Gaussian operator filter. + /// + /// + /// The pixel format. + internal class LaplacianOfGaussianProcessor : EdgeDetectorProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public LaplacianOfGaussianProcessor(bool grayscale) + : base(LaplacianKernels.LaplacianOfGaussianXY, grayscale) + { + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/PrewittKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/PrewittKernels.cs new file mode 100644 index 0000000000..64bce4f8cc --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/PrewittKernels.cs @@ -0,0 +1,35 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains the kernels used for Prewitt edge detection + /// + internal static class PrewittKernels + { + /// + /// Gets the horizontal gradient operator. + /// + public static Fast2DArray PrewittX => + new float[,] + { + { -1, 0, 1 }, + { -1, 0, 1 }, + { -1, 0, 1 } + }; + + /// + /// Gets the vertical gradient operator. + /// + public static Fast2DArray PrewittY => + new float[,] + { + { 1, 1, 1 }, + { 0, 0, 0 }, + { -1, -1, -1 } + }; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/PrewittProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/PrewittProcessor.cs new file mode 100644 index 0000000000..5683d6f609 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/PrewittProcessor.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Prewitt operator filter. + /// + /// + /// The pixel format. + internal class PrewittProcessor : EdgeDetector2DProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public PrewittProcessor(bool grayscale) + : base(PrewittKernels.PrewittX, PrewittKernels.PrewittY, grayscale) + { + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossKernels.cs new file mode 100644 index 0000000000..63d96c79bd --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossKernels.cs @@ -0,0 +1,33 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains the kernels used for RobertsCross edge detection + /// + internal static class RobertsCrossKernels + { + /// + /// Gets the horizontal gradient operator. + /// + public static Fast2DArray RobertsCrossX => + new float[,] + { + { 1, 0 }, + { 0, -1 } + }; + + /// + /// Gets the vertical gradient operator. + /// + public static Fast2DArray RobertsCrossY => + new float[,] + { + { 0, 1 }, + { -1, 0 } + }; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossProcessor.cs new file mode 100644 index 0000000000..38d1fffc9a --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossProcessor.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Roberts Cross operator filter. + /// + /// + /// The pixel format. + internal class RobertsCrossProcessor : EdgeDetector2DProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public RobertsCrossProcessor(bool grayscale) + : base(RobertsCrossKernels.RobertsCrossX, RobertsCrossKernels.RobertsCrossY, grayscale) + { + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/RobinsonKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/RobinsonKernels.cs new file mode 100644 index 0000000000..e102023290 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/RobinsonKernels.cs @@ -0,0 +1,101 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains the kernels used for Robinson edge detection + /// + internal static class RobinsonKernels + { + /// + /// Gets the North gradient operator + /// + public static Fast2DArray RobinsonNorth => + new float[,] + { + { 1, 2, 1 }, + { 0, 0, 0 }, + { -1, -2, -1 } + }; + + /// + /// Gets the NorthWest gradient operator + /// + public static Fast2DArray RobinsonNorthWest => + new float[,] + { + { 2, 1, 0 }, + { 1, 0, -1 }, + { 0, -1, -2 } + }; + + /// + /// Gets the West gradient operator + /// + public static Fast2DArray RobinsonWest => + new float[,] + { + { 1, 0, -1 }, + { 2, 0, -2 }, + { 1, 0, -1 } + }; + + /// + /// Gets the SouthWest gradient operator + /// + public static Fast2DArray RobinsonSouthWest => + new float[,] + { + { 0, -1, -2 }, + { 1, 0, -1 }, + { 2, 1, 0 } + }; + + /// + /// Gets the South gradient operator + /// + public static Fast2DArray RobinsonSouth => + new float[,] + { + { -1, -2, -1 }, + { 0, 0, 0 }, + { 1, 2, 1 } + }; + + /// + /// Gets the SouthEast gradient operator + /// + public static Fast2DArray RobinsonSouthEast => + new float[,] + { + { -2, -1, 0 }, + { -1, 0, 1 }, + { 0, 1, 2 } + }; + + /// + /// Gets the East gradient operator + /// + public static Fast2DArray RobinsonEast => + new float[,] + { + { -1, 0, 1 }, + { -2, 0, 2 }, + { -1, 0, 1 } + }; + + /// + /// Gets the NorthEast gradient operator + /// + public static Fast2DArray RobinsonNorthEast => + new float[,] + { + { 0, 1, 2 }, + { -1, 0, 1 }, + { -2, -1, 0 } + }; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/RobinsonProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/RobinsonProcessor.cs new file mode 100644 index 0000000000..fac0c52e5a --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/RobinsonProcessor.cs @@ -0,0 +1,50 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Robinson operator filter. + /// + /// + /// The pixel format. + internal class RobinsonProcessor : EdgeDetectorCompassProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public RobinsonProcessor(bool grayscale) + : base(grayscale) + { + } + + /// + public override Fast2DArray North => RobinsonKernels.RobinsonNorth; + + /// + public override Fast2DArray NorthWest => RobinsonKernels.RobinsonNorthWest; + + /// + public override Fast2DArray West => RobinsonKernels.RobinsonWest; + + /// + public override Fast2DArray SouthWest => RobinsonKernels.RobinsonSouthWest; + + /// + public override Fast2DArray South => RobinsonKernels.RobinsonSouth; + + /// + public override Fast2DArray SouthEast => RobinsonKernels.RobinsonSouthEast; + + /// + public override Fast2DArray East => RobinsonKernels.RobinsonEast; + + /// + public override Fast2DArray NorthEast => RobinsonKernels.RobinsonNorthEast; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/ScharrKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/ScharrKernels.cs new file mode 100644 index 0000000000..cf8b9925ad --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/ScharrKernels.cs @@ -0,0 +1,35 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains the kernels used for Scharr edge detection + /// + internal static class ScharrKernels + { + /// + /// Gets the horizontal gradient operator. + /// + public static Fast2DArray ScharrX => + new float[,] + { + { -3, 0, 3 }, + { -10, 0, 10 }, + { -3, 0, 3 } + }; + + /// + /// Gets the vertical gradient operator. + /// + public static Fast2DArray ScharrY => + new float[,] + { + { 3, 10, 3 }, + { 0, 0, 0 }, + { -3, -10, -3 } + }; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/ScharrProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/ScharrProcessor.cs new file mode 100644 index 0000000000..c101d092de --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/ScharrProcessor.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Scharr operator filter. + /// + /// + /// The pixel format. + internal class ScharrProcessor : EdgeDetector2DProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public ScharrProcessor(bool grayscale) + : base(ScharrKernels.ScharrX, ScharrKernels.ScharrY, grayscale) + { + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/SobelKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/SobelKernels.cs new file mode 100644 index 0000000000..691bd66149 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/SobelKernels.cs @@ -0,0 +1,35 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains the kernels used for Sobel edge detection + /// + internal static class SobelKernels + { + /// + /// Gets the horizontal gradient operator. + /// + public static Fast2DArray SobelX => + new float[,] + { + { -1, 0, 1 }, + { -2, 0, 2 }, + { -1, 0, 1 } + }; + + /// + /// Gets the vertical gradient operator. + /// + public static Fast2DArray SobelY => + new float[,] + { + { -1, -2, -1 }, + { 0, 0, 0 }, + { 1, 2, 1 } + }; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/SobelProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/SobelProcessor.cs new file mode 100644 index 0000000000..bf97c67d7f --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/SobelProcessor.cs @@ -0,0 +1,26 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// The Sobel operator filter. + /// + /// + /// The pixel format. + internal class SobelProcessor : EdgeDetector2DProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public SobelProcessor(bool grayscale) + : base(SobelKernels.SobelX, SobelKernels.SobelY, grayscale) + { + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Dithering/Diffuse.cs b/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs similarity index 95% rename from src/ImageSharp/Processing/Dithering/Diffuse.cs rename to src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs index e6b82d3134..01f138b097 100644 --- a/src/ImageSharp/Processing/Dithering/Diffuse.cs +++ b/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs @@ -3,15 +3,15 @@ using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Dithering.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Dithering { /// - /// Extension methods for the type. + /// Adds diffusion extensions to the type. /// - public static partial class ImageExtensions + public static class DiffuseExtensions { /// /// Dithers the image reducing it to a web-safe palette using error diffusion. @@ -81,4 +81,4 @@ namespace SixLabors.ImageSharp return source; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Dithering/Dither.cs b/src/ImageSharp/Processing/Dithering/DitherExtensions.cs similarity index 94% rename from src/ImageSharp/Processing/Dithering/Dither.cs rename to src/ImageSharp/Processing/Dithering/DitherExtensions.cs index 85fdef24b5..f3debe8cbf 100644 --- a/src/ImageSharp/Processing/Dithering/Dither.cs +++ b/src/ImageSharp/Processing/Dithering/DitherExtensions.cs @@ -3,15 +3,15 @@ using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Dithering.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Dithering { /// - /// Extension methods for the type. + /// Adds dithering extensions to the type. /// - public static partial class ImageExtensions + public static class DitherExtensions { /// /// Dithers the image reducing it to a web-safe palette using ordered dithering. @@ -77,4 +77,4 @@ namespace SixLabors.ImageSharp return source; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Dithering/ErrorDiffusionPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs similarity index 96% rename from src/ImageSharp/Processing/Processors/Dithering/ErrorDiffusionPaletteProcessor.cs rename to src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs index 152959cb73..4e2a2cb790 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/ErrorDiffusionPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs @@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Dithering.Processors { /// /// An that dithers an image using error diffusion. @@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public float Threshold { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { float threshold = this.Threshold * 255F; var rgba = default(Rgba32); diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs similarity index 95% rename from src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs rename to src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs index 4fc59585a9..213f7ca908 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs @@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Dithering.Processors { /// /// An that dithers an image using error diffusion. @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public IOrderedDither Dither { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { var rgba = default(Rgba32); bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8); diff --git a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs b/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs similarity index 95% rename from src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs rename to src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs index 4e6b7bec0e..782d33b533 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs @@ -6,7 +6,7 @@ using System.Numerics; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Dithering.Processors { /// /// The base class for dither and diffusion processors that consume a palette. @@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// Initializes a new instance of the class. /// /// The palette to select substitute colors from. - public PaletteDitherProcessorBase(TPixel[] palette) + protected PaletteDitherProcessorBase(TPixel[] palette) { Guard.NotNull(palette, nameof(palette)); this.Palette = palette; diff --git a/src/ImageSharp/Processing/Processors/Dithering/PixelPair.cs b/src/ImageSharp/Processing/Dithering/Processors/PixelPair.cs similarity index 96% rename from src/ImageSharp/Processing/Processors/Dithering/PixelPair.cs rename to src/ImageSharp/Processing/Dithering/Processors/PixelPair.cs index 07045bb5ab..127c0be6d0 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/PixelPair.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/PixelPair.cs @@ -4,7 +4,7 @@ using System; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Dithering.Processors { /// /// Represents a composite pair of pixels. Used for caching color distance lookups. diff --git a/src/ImageSharp/Processing/Effects/OilPainting.cs b/src/ImageSharp/Processing/Effects/OilPaintExtensions.cs similarity index 86% rename from src/ImageSharp/Processing/Effects/OilPainting.cs rename to src/ImageSharp/Processing/Effects/OilPaintExtensions.cs index 0494c9a8b9..a04bbec4e5 100644 --- a/src/ImageSharp/Processing/Effects/OilPainting.cs +++ b/src/ImageSharp/Processing/Effects/OilPaintExtensions.cs @@ -1,17 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Effects.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Effects { /// - /// Extension methods for the type. + /// Adds oil painting effect extensions to the type. /// - public static partial class ImageExtensions + public static class OilPaintExtensions { /// /// Alters the colors of the image recreating an oil painting effect with levels and brushSize @@ -22,9 +21,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext OilPaint(this IImageProcessingContext source) where TPixel : struct, IPixel - { - return OilPaint(source, 10, 15); - } + => OilPaint(source, 10, 15); /// /// Alters the colors of the image recreating an oil painting effect with levels and brushSize @@ -38,9 +35,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext OilPaint(this IImageProcessingContext source, Rectangle rectangle) where TPixel : struct, IPixel - { - return OilPaint(source, 10, 15, rectangle); - } + => OilPaint(source, 10, 15, rectangle); /// /// Alters the colors of the image recreating an oil painting effect. @@ -52,7 +47,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext OilPaint(this IImageProcessingContext source, int levels, int brushSize) where TPixel : struct, IPixel - => source.ApplyProcessor(new OilPaintingProcessor(levels, brushSize)); + => source.ApplyProcessor(new OilPaintingProcessor(levels, brushSize)); /// /// Alters the colors of the image recreating an oil painting effect. @@ -67,6 +62,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext OilPaint(this IImageProcessingContext source, int levels, int brushSize, Rectangle rectangle) where TPixel : struct, IPixel - => source.ApplyProcessor(new OilPaintingProcessor(levels, brushSize), rectangle); + => source.ApplyProcessor(new OilPaintingProcessor(levels, brushSize), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Effects/Pixelate.cs b/src/ImageSharp/Processing/Effects/PixelateExtensions.cs similarity index 81% rename from src/ImageSharp/Processing/Effects/Pixelate.cs rename to src/ImageSharp/Processing/Effects/PixelateExtensions.cs index 29e348f6e6..d6fcfe6f15 100644 --- a/src/ImageSharp/Processing/Effects/Pixelate.cs +++ b/src/ImageSharp/Processing/Effects/PixelateExtensions.cs @@ -1,17 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Effects.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Effects { /// - /// Extension methods for the type. + /// Adds pixelation effect extensions to the type. /// - public static partial class ImageExtensions + public static class PixelateExtensions { /// /// Pixelates an image with the given pixel size. @@ -21,7 +20,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Pixelate(this IImageProcessingContext source) where TPixel : struct, IPixel - => source.ApplyProcessor(new PixelateProcessor(4)); + => Pixelate(source, 4); /// /// Pixelates an image with the given pixel size. @@ -32,7 +31,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Pixelate(this IImageProcessingContext source, int size) where TPixel : struct, IPixel - => source.ApplyProcessor(new PixelateProcessor(size)); + => source.ApplyProcessor(new PixelateProcessor(size)); /// /// Pixelates an image with the given pixel size. @@ -46,6 +45,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Pixelate(this IImageProcessingContext source, int size, Rectangle rectangle) where TPixel : struct, IPixel - => source.ApplyProcessor(new PixelateProcessor(size), rectangle); + => source.ApplyProcessor(new PixelateProcessor(size), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs b/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs similarity index 95% rename from src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs rename to src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs index c199a32c8a..aafc2df888 100644 --- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs +++ b/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs @@ -10,10 +10,10 @@ using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Effects.Processors { /// - /// An to apply an oil painting effect to an . + /// Applies oil painting effect processing to the image. /// /// Adapted from by Dewald Esterhuizen. /// The pixel format. @@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public int BrushSize { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { if (this.BrushSize <= 0 || this.BrushSize > source.Height || this.BrushSize > source.Width) { diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs b/src/ImageSharp/Processing/Effects/Processors/PixelateProcessor.cs similarity index 93% rename from src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs rename to src/ImageSharp/Processing/Effects/Processors/PixelateProcessor.cs index 0ab21f65ac..23f81e05e4 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs +++ b/src/ImageSharp/Processing/Effects/Processors/PixelateProcessor.cs @@ -9,10 +9,10 @@ using SixLabors.ImageSharp.Common; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Effects.Processors { /// - /// An to pixelate the colors of an . + /// Applies a pixelation effect processing to the image. /// /// The pixel format. internal class PixelateProcessor : ImageProcessor @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public int Size { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { if (this.Size <= 0 || this.Size > source.Height || this.Size > source.Width) { diff --git a/src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs b/src/ImageSharp/Processing/Filters/BlackWhiteExtensions.cs similarity index 75% rename from src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs rename to src/ImageSharp/Processing/Filters/BlackWhiteExtensions.cs index d64db34bad..f30cefb860 100644 --- a/src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs +++ b/src/ImageSharp/Processing/Filters/BlackWhiteExtensions.cs @@ -2,15 +2,15 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of black and white toning to the type. /// - public static partial class ImageExtensions + public static class BlackWhiteExtensions { /// /// Applies black and white toning to the image. @@ -20,10 +20,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BlackWhite(this IImageProcessingContext source) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BlackWhiteProcessor()); - return source; - } + => source.ApplyProcessor(new BlackWhiteProcessor()); /// /// Applies black and white toning to the image. @@ -36,9 +33,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BlackWhite(this IImageProcessingContext source, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BlackWhiteProcessor(), rectangle); - return source; - } + => source.ApplyProcessor(new BlackWhiteProcessor(), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/ColorMatrix/Brightness.cs b/src/ImageSharp/Processing/Filters/BrightnessExtensions.cs similarity index 83% rename from src/ImageSharp/Processing/ColorMatrix/Brightness.cs rename to src/ImageSharp/Processing/Filters/BrightnessExtensions.cs index 34b5347841..a36d588d5d 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Brightness.cs +++ b/src/ImageSharp/Processing/Filters/BrightnessExtensions.cs @@ -1,17 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the alteration of the brightness component to the type. /// - public static partial class ImageExtensions + public static class BrightnessExtensions { /// /// Alters the brightness component of the image. @@ -26,7 +25,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Brightness(this IImageProcessingContext source, float amount) where TPixel : struct, IPixel - => source.ApplyProcessor(new BrightnessProcessor(amount)); + => source.ApplyProcessor(new BrightnessProcessor(amount)); /// /// Alters the brightness component of the image. @@ -44,6 +43,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Brightness(this IImageProcessingContext source, float amount, Rectangle rectangle) where TPixel : struct, IPixel - => source.ApplyProcessor(new BrightnessProcessor(amount), rectangle); + => source.ApplyProcessor(new BrightnessProcessor(amount), rectangle); } } diff --git a/src/ImageSharp/Processing/ColorMatrix/Options/ColorBlindness.cs b/src/ImageSharp/Processing/Filters/ColorBlindness.cs similarity index 95% rename from src/ImageSharp/Processing/ColorMatrix/Options/ColorBlindness.cs rename to src/ImageSharp/Processing/Filters/ColorBlindness.cs index 1b92029f6b..41d468f340 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Options/ColorBlindness.cs +++ b/src/ImageSharp/Processing/Filters/ColorBlindness.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Filters { /// /// Enumerates the various types of defined color blindness filters. diff --git a/src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs b/src/ImageSharp/Processing/Filters/ColorBlindnessExtensions.cs similarity index 77% rename from src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs rename to src/ImageSharp/Processing/Filters/ColorBlindnessExtensions.cs index ebfa9ffdcd..6a0caf3b45 100644 --- a/src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs +++ b/src/ImageSharp/Processing/Filters/ColorBlindnessExtensions.cs @@ -1,18 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that simulate the effects of various color blindness disorders to the type. /// - public static partial class ImageExtensions + public static class ColorBlindnessExtensions { /// /// Applies the given colorblindness simulator to the image. @@ -50,19 +48,19 @@ namespace SixLabors.ImageSharp { switch (colorBlindness) { - case ImageSharp.Processing.ColorBlindness.Achromatomaly: + case Filters.ColorBlindness.Achromatomaly: return new AchromatomalyProcessor(); - case ImageSharp.Processing.ColorBlindness.Achromatopsia: + case Filters.ColorBlindness.Achromatopsia: return new AchromatopsiaProcessor(); - case ImageSharp.Processing.ColorBlindness.Deuteranomaly: + case Filters.ColorBlindness.Deuteranomaly: return new DeuteranomalyProcessor(); - case ImageSharp.Processing.ColorBlindness.Deuteranopia: + case Filters.ColorBlindness.Deuteranopia: return new DeuteranopiaProcessor(); - case ImageSharp.Processing.ColorBlindness.Protanomaly: + case Filters.ColorBlindness.Protanomaly: return new ProtanomalyProcessor(); - case ImageSharp.Processing.ColorBlindness.Protanopia: + case Filters.ColorBlindness.Protanopia: return new ProtanopiaProcessor(); - case ImageSharp.Processing.ColorBlindness.Tritanomaly: + case Filters.ColorBlindness.Tritanomaly: return new TritanomalyProcessor(); default: return new TritanopiaProcessor(); diff --git a/src/ImageSharp/Processing/ColorMatrix/Contrast.cs b/src/ImageSharp/Processing/Filters/ContrastExtensions.cs similarity index 83% rename from src/ImageSharp/Processing/ColorMatrix/Contrast.cs rename to src/ImageSharp/Processing/Filters/ContrastExtensions.cs index e0f388e287..16225039c3 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Contrast.cs +++ b/src/ImageSharp/Processing/Filters/ContrastExtensions.cs @@ -2,15 +2,15 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the alteration of the contrast component to the type. /// - public static partial class ImageExtensions + public static class ContrastExtensions { /// /// Alters the contrast component of the image. @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Contrast(this IImageProcessingContext source, float amount) where TPixel : struct, IPixel - => source.ApplyProcessor(new ContrastProcessor(amount)); + => source.ApplyProcessor(new ContrastProcessor(amount)); /// /// Alters the contrast component of the image. @@ -43,6 +43,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Contrast(this IImageProcessingContext source, float amount, Rectangle rectangle) where TPixel : struct, IPixel - => source.ApplyProcessor(new ContrastProcessor(amount), rectangle); + => source.ApplyProcessor(new ContrastProcessor(amount), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/ColorMatrix/Filter.cs b/src/ImageSharp/Processing/Filters/FilterExtensions.cs similarity index 77% rename from src/ImageSharp/Processing/ColorMatrix/Filter.cs rename to src/ImageSharp/Processing/Filters/FilterExtensions.cs index 7eb684978a..ae8bbda030 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Filter.cs +++ b/src/ImageSharp/Processing/Filters/FilterExtensions.cs @@ -3,15 +3,15 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of composable filters to the type. /// - public static partial class ImageExtensions + public static class FilterExtensions { /// /// Filters an image but the given color matrix @@ -22,10 +22,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Filter(this IImageProcessingContext source, Matrix4x4 matrix) where TPixel : struct, IPixel - { - source.ApplyProcessor(new FilterProcessor(matrix)); - return source; - } + => source.ApplyProcessor(new FilterProcessor(matrix)); /// /// Filters an image but the given color matrix @@ -39,9 +36,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Filter(this IImageProcessingContext source, Matrix4x4 matrix, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new FilterProcessor(matrix), rectangle); - return source; - } + => source.ApplyProcessor(new FilterProcessor(matrix), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/ColorMatrix/Grayscale.cs b/src/ImageSharp/Processing/Filters/GrayscaleExtensions.cs similarity index 86% rename from src/ImageSharp/Processing/ColorMatrix/Grayscale.cs rename to src/ImageSharp/Processing/Filters/GrayscaleExtensions.cs index ee43d5b016..be5b69eed9 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Grayscale.cs +++ b/src/ImageSharp/Processing/Filters/GrayscaleExtensions.cs @@ -2,29 +2,28 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of grayscale toning to the type. /// - public static partial class ImageExtensions + public static class GrayscaleExtensions { /// - /// Applies Grayscale toning to the image. + /// Applies grayscale toning to the image. /// /// The pixel format. /// The image this method extends. /// The . public static IImageProcessingContext Grayscale(this IImageProcessingContext source) where TPixel : struct, IPixel - => Grayscale(source, GrayscaleMode.Bt709); + => Grayscale(source, GrayscaleMode.Bt709); /// - /// Applies Grayscale toning to the image using the given amount. + /// Applies grayscale toning to the image using the given amount. /// /// The pixel format. /// The image this method extends. @@ -32,7 +31,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Grayscale(this IImageProcessingContext source, float amount) where TPixel : struct, IPixel - => Grayscale(source, GrayscaleMode.Bt709, amount); + => Grayscale(source, GrayscaleMode.Bt709, amount); /// /// Applies grayscale toning to the image with the given . @@ -43,7 +42,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Grayscale(this IImageProcessingContext source, GrayscaleMode mode) where TPixel : struct, IPixel - => Grayscale(source, mode, 1F); + => Grayscale(source, mode, 1F); /// /// Applies grayscale toning to the image with the given using the given amount. @@ -65,7 +64,7 @@ namespace SixLabors.ImageSharp } /// - /// Applies Grayscale toning to the image. + /// Applies grayscale toning to the image. /// /// The pixel format. /// The image this method extends. @@ -75,10 +74,10 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Grayscale(this IImageProcessingContext source, Rectangle rectangle) where TPixel : struct, IPixel - => Grayscale(source, 1F, rectangle); + => Grayscale(source, 1F, rectangle); /// - /// Applies Grayscale toning to the image using the given amount. + /// Applies grayscale toning to the image using the given amount. /// /// The pixel format. /// The image this method extends. @@ -89,10 +88,10 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Grayscale(this IImageProcessingContext source, float amount, Rectangle rectangle) where TPixel : struct, IPixel - => Grayscale(source, GrayscaleMode.Bt709, amount, rectangle); + => Grayscale(source, GrayscaleMode.Bt709, amount, rectangle); /// - /// Applies Grayscale toning to the image. + /// Applies grayscale toning to the image. /// /// The pixel format. /// The image this method extends. @@ -103,10 +102,10 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Grayscale(this IImageProcessingContext source, GrayscaleMode mode, Rectangle rectangle) where TPixel : struct, IPixel - => Grayscale(source, mode, 1F, rectangle); + => Grayscale(source, mode, 1F, rectangle); /// - /// Applies Grayscale toning to the image using the given amount. + /// Applies grayscale toning to the image using the given amount. /// /// The pixel format. /// The image this method extends. diff --git a/src/ImageSharp/Processing/ColorMatrix/Options/GrayscaleMode.cs b/src/ImageSharp/Processing/Filters/GrayscaleMode.cs similarity index 77% rename from src/ImageSharp/Processing/ColorMatrix/Options/GrayscaleMode.cs rename to src/ImageSharp/Processing/Filters/GrayscaleMode.cs index 370071b7ab..db30e67ff4 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Options/GrayscaleMode.cs +++ b/src/ImageSharp/Processing/Filters/GrayscaleMode.cs @@ -1,10 +1,10 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Enumerates the various types of defined Grayscale filters. + /// Enumerates the various types of defined grayscale filters. /// public enum GrayscaleMode { @@ -18,4 +18,4 @@ namespace SixLabors.ImageSharp.Processing /// Bt601 } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/ColorMatrix/Hue.cs b/src/ImageSharp/Processing/Filters/HueExtensions.cs similarity index 75% rename from src/ImageSharp/Processing/ColorMatrix/Hue.cs rename to src/ImageSharp/Processing/Filters/HueExtensions.cs index 76af10c369..1b730d7f02 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Hue.cs +++ b/src/ImageSharp/Processing/Filters/HueExtensions.cs @@ -1,18 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the alteration of the hue component to the type. /// - public static partial class ImageExtensions + public static class HueExtensions { /// /// Alters the hue component of the image. @@ -23,10 +21,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Hue(this IImageProcessingContext source, float degrees) where TPixel : struct, IPixel - { - source.ApplyProcessor(new HueProcessor(degrees)); - return source; - } + => source.ApplyProcessor(new HueProcessor(degrees)); /// /// Alters the hue component of the image. @@ -40,9 +35,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Hue(this IImageProcessingContext source, float degrees, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new HueProcessor(degrees), rectangle); - return source; - } + => source.ApplyProcessor(new HueProcessor(degrees), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Effects/Invert.cs b/src/ImageSharp/Processing/Filters/InvertExtensions.cs similarity index 76% rename from src/ImageSharp/Processing/Effects/Invert.cs rename to src/ImageSharp/Processing/Filters/InvertExtensions.cs index 7dd9ed3dd7..784b37c56e 100644 --- a/src/ImageSharp/Processing/Effects/Invert.cs +++ b/src/ImageSharp/Processing/Filters/InvertExtensions.cs @@ -1,17 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the inversion of colors to the type. /// - public static partial class ImageExtensions + public static class InvertExtensions { /// /// Inverts the colors of the image. @@ -21,7 +20,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Invert(this IImageProcessingContext source) where TPixel : struct, IPixel - => source.ApplyProcessor(new InvertProcessor(1F)); + => source.ApplyProcessor(new InvertProcessor(1F)); /// /// Inverts the colors of the image. @@ -34,6 +33,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Invert(this IImageProcessingContext source, Rectangle rectangle) where TPixel : struct, IPixel - => source.ApplyProcessor(new InvertProcessor(1F), rectangle); + => source.ApplyProcessor(new InvertProcessor(1F), rectangle); } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs b/src/ImageSharp/Processing/Filters/KodachromeExtensions.cs similarity index 74% rename from src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs rename to src/ImageSharp/Processing/Filters/KodachromeExtensions.cs index d7845320ad..94f1acc0c0 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs +++ b/src/ImageSharp/Processing/Filters/KodachromeExtensions.cs @@ -1,18 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the recreation of an old Kodachrome camera effect to the type. /// - public static partial class ImageExtensions + public static class KodachromeExtensions { /// /// Alters the colors of the image recreating an old Kodachrome camera effect. @@ -22,10 +20,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Kodachrome(this IImageProcessingContext source) where TPixel : struct, IPixel - { - source.ApplyProcessor(new KodachromeProcessor()); - return source; - } + => source.ApplyProcessor(new KodachromeProcessor()); /// /// Alters the colors of the image recreating an old Kodachrome camera effect. @@ -38,9 +33,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Kodachrome(this IImageProcessingContext source, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new KodachromeProcessor(), rectangle); - return source; - } + => source.ApplyProcessor(new KodachromeProcessor(), rectangle); } } diff --git a/src/ImageSharp/Processing/Filters/LomographExtensions.cs b/src/ImageSharp/Processing/Filters/LomographExtensions.cs new file mode 100644 index 0000000000..ed9e1cc297 --- /dev/null +++ b/src/ImageSharp/Processing/Filters/LomographExtensions.cs @@ -0,0 +1,38 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Filters.Processors; +using SixLabors.Primitives; + +namespace SixLabors.ImageSharp.Processing.Filters +{ + /// + /// Adds extensions that allow the recreation of an old Lomograph camera effect to the type. + /// + public static class LomographExtensions + { + /// + /// Alters the colors of the image recreating an old Lomograph camera effect. + /// + /// The pixel format. + /// The image this method extends. + /// The . + public static IImageProcessingContext Lomograph(this IImageProcessingContext source) + where TPixel : struct, IPixel + => source.ApplyProcessor(new LomographProcessor()); + + /// + /// Alters the colors of the image recreating an old Lomograph camera effect. + /// + /// The pixel format. + /// The image this method extends. + /// + /// The structure that specifies the portion of the image object to alter. + /// + /// The . + public static IImageProcessingContext Lomograph(this IImageProcessingContext source, Rectangle rectangle) + where TPixel : struct, IPixel + => source.ApplyProcessor(new LomographProcessor(), rectangle); + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/ColorMatrix/MatrixFilters.cs b/src/ImageSharp/Processing/Filters/MatrixFilters.cs similarity index 98% rename from src/ImageSharp/Processing/ColorMatrix/MatrixFilters.cs rename to src/ImageSharp/Processing/Filters/MatrixFilters.cs index 8cbc21b2a6..2f5883fc9c 100644 --- a/src/ImageSharp/Processing/ColorMatrix/MatrixFilters.cs +++ b/src/ImageSharp/Processing/Filters/MatrixFilters.cs @@ -4,10 +4,10 @@ using System; using System.Numerics; -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Provides extensions methods for the struct + /// A collection of known values for composing filters /// public static class MatrixFilters { @@ -253,7 +253,7 @@ namespace SixLabors.ImageSharp.Processing } /// - /// Create a greyscale filter matrix using the given amount using the formula as specified by ITU-R Recommendation BT.601. + /// Create a grayscale filter matrix using the given amount using the formula as specified by ITU-R Recommendation BT.601. /// /// /// The proportion of the conversion. Must be between 0 and 1. @@ -280,7 +280,7 @@ namespace SixLabors.ImageSharp.Processing } /// - /// Create a greyscale filter matrix using the given amount using the formula as specified by ITU-R Recommendation BT.709. + /// Create a grayscale filter matrix using the given amount using the formula as specified by ITU-R Recommendation BT.709. /// /// /// The proportion of the conversion. Must be between 0 and 1. diff --git a/src/ImageSharp/Processing/ColorMatrix/Opacity.cs b/src/ImageSharp/Processing/Filters/OpacityExtensions.cs similarity index 78% rename from src/ImageSharp/Processing/ColorMatrix/Opacity.cs rename to src/ImageSharp/Processing/Filters/OpacityExtensions.cs index b59c068905..e263fef4ee 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Opacity.cs +++ b/src/ImageSharp/Processing/Filters/OpacityExtensions.cs @@ -1,17 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the alteration of the opacity component to the type. /// - public static partial class ImageExtensions + public static class OpacityExtensions { /// /// Multiplies the alpha component of the image. @@ -22,7 +21,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Opacity(this IImageProcessingContext source, float amount) where TPixel : struct, IPixel - => source.ApplyProcessor(new OpacityProcessor(amount)); + => source.ApplyProcessor(new OpacityProcessor(amount)); /// /// Multiplies the alpha component of the image. @@ -36,6 +35,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Opacity(this IImageProcessingContext source, float amount, Rectangle rectangle) where TPixel : struct, IPixel - => source.ApplyProcessor(new OpacityProcessor(amount), rectangle); + => source.ApplyProcessor(new OpacityProcessor(amount), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Filters/PolaroidExtensions.cs b/src/ImageSharp/Processing/Filters/PolaroidExtensions.cs new file mode 100644 index 0000000000..37f06f9cf0 --- /dev/null +++ b/src/ImageSharp/Processing/Filters/PolaroidExtensions.cs @@ -0,0 +1,38 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Filters.Processors; +using SixLabors.Primitives; + +namespace SixLabors.ImageSharp.Processing.Filters +{ + /// + /// Adds extensions that allow the recreation of an old Polaroid camera effect to the type. + /// + public static class PolaroidExtensions + { + /// + /// Alters the colors of the image recreating an old Polaroid camera effect. + /// + /// The pixel format. + /// The image this method extends. + /// The . + public static IImageProcessingContext Polaroid(this IImageProcessingContext source) + where TPixel : struct, IPixel + => source.ApplyProcessor(new PolaroidProcessor()); + + /// + /// Alters the colors of the image recreating an old Polaroid camera effect. + /// + /// The pixel format. + /// The image this method extends. + /// + /// The structure that specifies the portion of the image object to alter. + /// + /// The . + public static IImageProcessingContext Polaroid(this IImageProcessingContext source, Rectangle rectangle) + where TPixel : struct, IPixel + => source.ApplyProcessor(new PolaroidProcessor(), rectangle); + } +} diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/AchromatomalyProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/AchromatomalyProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/AchromatomalyProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/AchromatomalyProcessor.cs index 8d9bf98579..55c6220308 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/AchromatomalyProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/AchromatomalyProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Achromatomaly (Color desensitivity) color blindness. diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/AchromatopsiaProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/AchromatopsiaProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/AchromatopsiaProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/AchromatopsiaProcessor.cs index f19c55933d..95f9e893be 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/AchromatopsiaProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/AchromatopsiaProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Achromatopsia (Monochrome) color blindness. diff --git a/src/ImageSharp/Processing/Processors/Filters/BlackWhiteProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/BlackWhiteProcessor.cs similarity index 91% rename from src/ImageSharp/Processing/Processors/Filters/BlackWhiteProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/BlackWhiteProcessor.cs index 30fcfab4fd..f6a420257e 100644 --- a/src/ImageSharp/Processing/Processors/Filters/BlackWhiteProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/BlackWhiteProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a black and white filter matrix to the image diff --git a/src/ImageSharp/Processing/Processors/Filters/BrightnessProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/BrightnessProcessor.cs similarity index 85% rename from src/ImageSharp/Processing/Processors/Filters/BrightnessProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/BrightnessProcessor.cs index b1a68a9c91..c6f758634d 100644 --- a/src/ImageSharp/Processing/Processors/Filters/BrightnessProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/BrightnessProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a brightness filter matrix using the given amount. @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// Initializes a new instance of the class. /// /// - /// A value of 0 will create an image that is completely black. A value of 1 leaves the input unchanged. + /// A value of 0 will create an image that is completely black. A value of 1 leaves the input unchanged. /// Other values are linear multipliers on the effect. Values of an amount over 1 are allowed, providing brighter results. /// /// The proportion of the conversion. Must be greater than or equal to 0. diff --git a/src/ImageSharp/Processing/Processors/Filters/ContrastProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/ContrastProcessor.cs similarity index 85% rename from src/ImageSharp/Processing/Processors/Filters/ContrastProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/ContrastProcessor.cs index 8ebeb939fb..3a8022703c 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ContrastProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/ContrastProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a contrast filter matrix using the given amount. @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// Initializes a new instance of the class. /// /// - /// A value of 0 will create an image that is completely gray. A value of 1 leaves the input unchanged. + /// A value of 0 will create an image that is completely gray. A value of 1 leaves the input unchanged. /// Other values are linear multipliers on the effect. Values of an amount over 1 are allowed, providing results with more contrast. /// /// The proportion of the conversion. Must be greater than or equal to 0. diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/DeuteranomalyProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/DeuteranomalyProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/DeuteranomalyProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/DeuteranomalyProcessor.cs index 20a1d4ab46..31ea79afe2 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/DeuteranomalyProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/DeuteranomalyProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Deuteranomaly (Green-Weak) color blindness. diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/DeuteranopiaProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/DeuteranopiaProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/DeuteranopiaProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/DeuteranopiaProcessor.cs index e5e0225718..5ed7e85408 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/DeuteranopiaProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/DeuteranopiaProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Deuteranopia (Green-Blind) color blindness. diff --git a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/FilterProcessor.cs similarity index 91% rename from src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/FilterProcessor.cs index 30fe8c6b6f..fb094d7bd0 100644 --- a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/FilterProcessor.cs @@ -9,7 +9,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Provides methods that accept a matrix to apply freeform filters to images. @@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Matrix4x4 Matrix { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { var interest = Rectangle.Intersect(sourceRectangle, source.Bounds()); int startY = interest.Y; diff --git a/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt601Processor.cs b/src/ImageSharp/Processing/Filters/Processors/GrayscaleBt601Processor.cs similarity index 88% rename from src/ImageSharp/Processing/Processors/Filters/GrayscaleBt601Processor.cs rename to src/ImageSharp/Processing/Filters/Processors/GrayscaleBt601Processor.cs index 7ea52dcb92..fa483752c5 100644 --- a/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt601Processor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/GrayscaleBt601Processor.cs @@ -3,10 +3,10 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// - /// Applies a greyscale filter matrix using the given amount and the formula as specified by ITU-R Recommendation BT.601 + /// Applies a grayscale filter matrix using the given amount and the formula as specified by ITU-R Recommendation BT.601 /// /// The pixel format. internal class GrayscaleBt601Processor : FilterProcessor diff --git a/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt709Processor.cs b/src/ImageSharp/Processing/Filters/Processors/GrayscaleBt709Processor.cs similarity index 94% rename from src/ImageSharp/Processing/Processors/Filters/GrayscaleBt709Processor.cs rename to src/ImageSharp/Processing/Filters/Processors/GrayscaleBt709Processor.cs index fcd7b2e8f5..396ad7d903 100644 --- a/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt709Processor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/GrayscaleBt709Processor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a grayscale filter matrix using the given amount and the formula as specified by ITU-R Recommendation BT.709 diff --git a/src/ImageSharp/Processing/Processors/Filters/HueProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/HueProcessor.cs similarity index 93% rename from src/ImageSharp/Processing/Processors/Filters/HueProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/HueProcessor.cs index 302314db40..31adf21259 100644 --- a/src/ImageSharp/Processing/Processors/Filters/HueProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/HueProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a hue filter matrix using the given angle of rotation in degrees diff --git a/src/ImageSharp/Processing/Processors/Filters/InvertProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/InvertProcessor.cs similarity index 93% rename from src/ImageSharp/Processing/Processors/Filters/InvertProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/InvertProcessor.cs index e258e9d96e..e5175ca69b 100644 --- a/src/ImageSharp/Processing/Processors/Filters/InvertProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/InvertProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a filter matrix that inverts the colors of an image diff --git a/src/ImageSharp/Processing/Processors/Filters/KodachromeProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/KodachromeProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/KodachromeProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/KodachromeProcessor.cs index 6f27a04538..19f55507c4 100644 --- a/src/ImageSharp/Processing/Processors/Filters/KodachromeProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/KodachromeProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a filter matrix recreating an old Kodachrome camera effect matrix to the image diff --git a/src/ImageSharp/Processing/Filters/Processors/LomographProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/LomographProcessor.cs new file mode 100644 index 0000000000..5ee6b4bc1a --- /dev/null +++ b/src/ImageSharp/Processing/Filters/Processors/LomographProcessor.cs @@ -0,0 +1,33 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors.Overlays; +using SixLabors.Primitives; + +namespace SixLabors.ImageSharp.Processing.Filters.Processors +{ + /// + /// Converts the colors of the image recreating an old Lomograph effect. + /// + /// The pixel format. + internal class LomographProcessor : FilterProcessor + where TPixel : struct, IPixel + { + private static readonly TPixel VeryDarkGreen = ColorBuilder.FromRGBA(0, 10, 0, 255); + + /// + /// Initializes a new instance of the class. + /// + public LomographProcessor() + : base(MatrixFilters.LomographFilter) + { + } + + /// + protected override void AfterFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + { + new VignetteProcessor(VeryDarkGreen).Apply(source, sourceRectangle, configuration); + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Filters/OpacityProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/OpacityProcessor.cs similarity index 93% rename from src/ImageSharp/Processing/Processors/Filters/OpacityProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/OpacityProcessor.cs index 1c0d2600ea..db9af9546c 100644 --- a/src/ImageSharp/Processing/Processors/Filters/OpacityProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/OpacityProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies an opacity filter matrix using the given amount. diff --git a/src/ImageSharp/Processing/Filters/Processors/PolaroidProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/PolaroidProcessor.cs new file mode 100644 index 0000000000..0a84eab8ba --- /dev/null +++ b/src/ImageSharp/Processing/Filters/Processors/PolaroidProcessor.cs @@ -0,0 +1,35 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors.Overlays; +using SixLabors.Primitives; + +namespace SixLabors.ImageSharp.Processing.Filters.Processors +{ + /// + /// Converts the colors of the image recreating an old Polaroid effect. + /// + /// The pixel format. + internal class PolaroidProcessor : FilterProcessor + where TPixel : struct, IPixel + { + private static readonly TPixel VeryDarkOrange = ColorBuilder.FromRGB(102, 34, 0); + private static readonly TPixel LightOrange = ColorBuilder.FromRGBA(255, 153, 102, 128); + + /// + /// Initializes a new instance of the class. + /// + public PolaroidProcessor() + : base(MatrixFilters.PolaroidFilter) + { + } + + /// + protected override void AfterFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + { + new VignetteProcessor(VeryDarkOrange).Apply(source, sourceRectangle, configuration); + new GlowProcessor(LightOrange, source.Width / 4F).Apply(source, sourceRectangle, configuration); + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/ProtanomalyProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/ProtanomalyProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/ProtanomalyProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/ProtanomalyProcessor.cs index b7b61d5e59..4801391227 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/ProtanomalyProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/ProtanomalyProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Protanomaly (Red-Weak) color blindness. diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/ProtanopiaProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/ProtanopiaProcessor.cs similarity index 90% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/ProtanopiaProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/ProtanopiaProcessor.cs index 54753f5b57..43f1c14ea8 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/ProtanopiaProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/ProtanopiaProcessor.cs @@ -1,10 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Numerics; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Protanopia (Red-Blind) color blindness. diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/README.md b/src/ImageSharp/Processing/Filters/Processors/README.md similarity index 100% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/README.md rename to src/ImageSharp/Processing/Filters/Processors/README.md diff --git a/src/ImageSharp/Processing/Processors/Filters/SaturateProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/SaturateProcessor.cs similarity index 86% rename from src/ImageSharp/Processing/Processors/Filters/SaturateProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/SaturateProcessor.cs index 44b3fe3ced..9a48cb2b51 100644 --- a/src/ImageSharp/Processing/Processors/Filters/SaturateProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/SaturateProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a saturation filter matrix using the given amount. @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// Initializes a new instance of the class. /// /// - /// A value of 0 is completely un-saturated. A value of 1 leaves the input unchanged. + /// A value of 0 is completely un-saturated. A value of 1 leaves the input unchanged. /// Other values are linear multipliers on the effect. Values of amount over 1 are allowed, providing super-saturated results /// /// The proportion of the conversion. Must be greater than or equal to 0. diff --git a/src/ImageSharp/Processing/Processors/Filters/SepiaProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/SepiaProcessor.cs similarity index 93% rename from src/ImageSharp/Processing/Processors/Filters/SepiaProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/SepiaProcessor.cs index b30d0fe052..2b3bf105bf 100644 --- a/src/ImageSharp/Processing/Processors/Filters/SepiaProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/SepiaProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a sepia filter matrix using the given amount. diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/TritanomalyProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/TritanomalyProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/TritanomalyProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/TritanomalyProcessor.cs index 57f4d4fa83..cd2e382178 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/TritanomalyProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/TritanomalyProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Tritanomaly (Blue-Weak) color blindness. diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/TritanopiaProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/TritanopiaProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/TritanopiaProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/TritanopiaProcessor.cs index b03a18cf76..ce4a079a27 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/TritanopiaProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/TritanopiaProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Tritanopia (Blue-Blind) color blindness. diff --git a/src/ImageSharp/Processing/ColorMatrix/Saturate.cs b/src/ImageSharp/Processing/Filters/SaturateExtensions.cs similarity index 82% rename from src/ImageSharp/Processing/ColorMatrix/Saturate.cs rename to src/ImageSharp/Processing/Filters/SaturateExtensions.cs index c7dd395aa3..282bdef64c 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Saturate.cs +++ b/src/ImageSharp/Processing/Filters/SaturateExtensions.cs @@ -2,15 +2,15 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the alteration of the saturation component to the type. /// - public static partial class ImageExtensions + public static class SaturateExtensions { /// /// Alters the saturation component of the image. @@ -25,10 +25,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Saturate(this IImageProcessingContext source, float amount) where TPixel : struct, IPixel - { - source.ApplyProcessor(new SaturateProcessor(amount)); - return source; - } + => source.ApplyProcessor(new SaturateProcessor(amount)); /// /// Alters the saturation component of the image. @@ -46,9 +43,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Saturate(this IImageProcessingContext source, float amount, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new SaturateProcessor(amount), rectangle); - return source; - } + => source.ApplyProcessor(new SaturateProcessor(amount), rectangle); } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/ColorMatrix/Sepia.cs b/src/ImageSharp/Processing/Filters/SepiaExtensions.cs similarity index 91% rename from src/ImageSharp/Processing/ColorMatrix/Sepia.cs rename to src/ImageSharp/Processing/Filters/SepiaExtensions.cs index 0d686f4dba..09d8c36843 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Sepia.cs +++ b/src/ImageSharp/Processing/Filters/SepiaExtensions.cs @@ -2,15 +2,15 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of sepia toning to the type. /// - public static partial class ImageExtensions + public static class SepiaExtensions { /// /// Applies sepia toning to the image. diff --git a/src/ImageSharp/Processing/Effects/BackgroundColor.cs b/src/ImageSharp/Processing/Overlays/BackgroundColor.cs similarity index 100% rename from src/ImageSharp/Processing/Effects/BackgroundColor.cs rename to src/ImageSharp/Processing/Overlays/BackgroundColor.cs diff --git a/src/ImageSharp/Processing/Overlays/Glow.cs b/src/ImageSharp/Processing/Overlays/Glow.cs index 0c3552b4d2..af80666d6f 100644 --- a/src/ImageSharp/Processing/Overlays/Glow.cs +++ b/src/ImageSharp/Processing/Overlays/Glow.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Processors.Overlays; using SixLabors.Primitives; namespace SixLabors.ImageSharp @@ -157,7 +158,7 @@ namespace SixLabors.ImageSharp /// The . private static IImageProcessingContext Glow(this IImageProcessingContext source, TPixel color, ValueSize radius, Rectangle rectangle, GraphicsOptions options) where TPixel : struct, IPixel - => source.ApplyProcessor(new GlowProcessor(source.MemoryManager, color, radius, options), rectangle); + => source.ApplyProcessor(new GlowProcessor(color, radius, options), rectangle); /// /// Applies a radial glow effect to an image. @@ -170,6 +171,6 @@ namespace SixLabors.ImageSharp /// The . private static IImageProcessingContext Glow(this IImageProcessingContext source, TPixel color, ValueSize radius, GraphicsOptions options) where TPixel : struct, IPixel - => source.ApplyProcessor(new GlowProcessor(source.MemoryManager, color, radius, options)); + => source.ApplyProcessor(new GlowProcessor(color, radius, options)); } } diff --git a/src/ImageSharp/Processing/Overlays/Vignette.cs b/src/ImageSharp/Processing/Overlays/Vignette.cs index 4b9f2f866c..ba2424d77a 100644 --- a/src/ImageSharp/Processing/Overlays/Vignette.cs +++ b/src/ImageSharp/Processing/Overlays/Vignette.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Processors.Overlays; using SixLabors.Primitives; namespace SixLabors.ImageSharp @@ -151,10 +152,10 @@ namespace SixLabors.ImageSharp private static IImageProcessingContext VignetteInternal(this IImageProcessingContext source, TPixel color, ValueSize radiusX, ValueSize radiusY, Rectangle rectangle, GraphicsOptions options) where TPixel : struct, IPixel - => source.ApplyProcessor(new VignetteProcessor(source.MemoryManager, color, radiusX, radiusY, options), rectangle); + => source.ApplyProcessor(new VignetteProcessor(color, radiusX, radiusY, options), rectangle); private static IImageProcessingContext VignetteInternal(this IImageProcessingContext source, TPixel color, ValueSize radiusX, ValueSize radiusY, GraphicsOptions options) where TPixel : struct, IPixel - => source.ApplyProcessor(new VignetteProcessor(source.MemoryManager, color, radiusX, radiusY, options)); + => source.ApplyProcessor(new VignetteProcessor(color, radiusX, radiusY, options)); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs b/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs index 7257bd6643..a089ffe1a1 100644 --- a/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs @@ -35,9 +35,9 @@ namespace SixLabors.ImageSharp.Processing ImageFrame sourceFrame = source.Frames[i]; ImageFrame clonedFrame = clone.Frames[i]; - this.BeforeApply(sourceFrame, clonedFrame, sourceRectangle, configuration); - this.OnApply(sourceFrame, clonedFrame, sourceRectangle, configuration); - this.AfterApply(sourceFrame, clonedFrame, sourceRectangle, configuration); + this.BeforeFrameApply(sourceFrame, clonedFrame, sourceRectangle, configuration); + this.OnFrameApply(sourceFrame, clonedFrame, sourceRectangle, configuration); + this.AfterFrameApply(sourceFrame, clonedFrame, sourceRectangle, configuration); } this.AfterImageApply(source, clone, sourceRectangle); @@ -96,36 +96,33 @@ namespace SixLabors.ImageSharp.Processing /// /// This method is called before the process is applied to prepare the processor. - /// TODO: We should probably name this 'BeforeFrameApply' /// /// The source image. Cannot be null. /// The cloned/destination image. Cannot be null. /// The structure that specifies the portion of the image object to draw. /// The configuration. - protected virtual void BeforeApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) + protected virtual void BeforeFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) { } /// /// Applies the process to the specified portion of the specified at the specified location /// and with the specified size. - /// TODO: We should probably name this 'ApplyToFrame' /// /// The source image. Cannot be null. /// The cloned/destination image. Cannot be null. /// The structure that specifies the portion of the image object to draw. /// The configuration. - protected abstract void OnApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration); + protected abstract void OnFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration); /// /// This method is called after the process is applied to prepare the processor. - /// TODO: We should probably name this 'AfterFrameApply' /// /// The source image. Cannot be null. /// The cloned/destination image. Cannot be null. /// The structure that specifies the portion of the image object to draw. /// The configuration. - protected virtual void AfterApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) + protected virtual void AfterFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) { } diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs deleted file mode 100644 index 8e4cdd6b5a..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Kayyali operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class KayyaliProcessor : EdgeDetector2DProcessor - where TPixel : struct, IPixel - { - /// - /// The horizontal gradient operator. - /// - private static readonly Fast2DArray KayyaliX = - new float[,] - { - { 6, 0, -6 }, - { 0, 0, 0 }, - { -6, 0, 6 } - }; - - /// - /// The vertical gradient operator. - /// - private static readonly Fast2DArray KayyaliY = - new float[,] - { - { -6, 0, 6 }, - { 0, 0, 0 }, - { 6, 0, -6 } - }; - - /// - /// Initializes a new instance of the class. - /// - public KayyaliProcessor() - : base(KayyaliX, KayyaliY) - { - } - } -} diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs deleted file mode 100644 index c0a3b35954..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Kirsch operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class KirschProcessor : EdgeDetectorCompassProcessor - where TPixel : struct, IPixel - { - /// - /// The North gradient operator - /// - private static readonly Fast2DArray KirschNorth = - new float[,] - { - { 5, 5, 5 }, - { -3, 0, -3 }, - { -3, -3, -3 } - }; - - /// - /// The NorthWest gradient operator - /// - private static readonly Fast2DArray KirschNorthWest = - new float[,] - { - { 5, 5, -3 }, - { 5, 0, -3 }, - { -3, -3, -3 } - }; - - /// - /// The West gradient operator - /// - private static readonly Fast2DArray KirschWest = - new float[,] - { - { 5, -3, -3 }, - { 5, 0, -3 }, - { 5, -3, -3 } - }; - - /// - /// The SouthWest gradient operator - /// - private static readonly Fast2DArray KirschSouthWest = - new float[,] - { - { -3, -3, -3 }, - { 5, 0, -3 }, - { 5, 5, -3 } - }; - - /// - /// The South gradient operator - /// - private static readonly Fast2DArray KirschSouth = - new float[,] - { - { -3, -3, -3 }, - { -3, 0, -3 }, - { 5, 5, 5 } - }; - - /// - /// The SouthEast gradient operator - /// - private static readonly Fast2DArray KirschSouthEast = - new float[,] - { - { -3, -3, -3 }, - { -3, 0, 5 }, - { -3, 5, 5 } - }; - - /// - /// The East gradient operator - /// - private static readonly Fast2DArray KirschEast = - new float[,] - { - { -3, -3, 5 }, - { -3, 0, 5 }, - { -3, -3, 5 } - }; - - /// - /// The NorthEast gradient operator - /// - private static readonly Fast2DArray KirschNorthEast = - new float[,] - { - { -3, 5, 5 }, - { -3, 0, 5 }, - { -3, -3, -3 } - }; - - /// - public override Fast2DArray North => KirschNorth; - - /// - public override Fast2DArray NorthWest => KirschNorthWest; - - /// - public override Fast2DArray West => KirschWest; - - /// - public override Fast2DArray SouthWest => KirschSouthWest; - - /// - public override Fast2DArray South => KirschSouth; - - /// - public override Fast2DArray SouthEast => KirschSouthEast; - - /// - public override Fast2DArray East => KirschEast; - - /// - public override Fast2DArray NorthEast => KirschNorthEast; - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs deleted file mode 100644 index 1b5c563187..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Laplacian 3 x 3 operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class Laplacian3X3Processor : EdgeDetectorProcessor - where TPixel : struct, IPixel - { - /// - /// The 2d gradient operator. - /// - private static readonly Fast2DArray Laplacian3X3XY = - new float[,] - { - { -1, -1, -1 }, - { -1, 8, -1 }, - { -1, -1, -1 } - }; - - /// - /// Initializes a new instance of the class. - /// - public Laplacian3X3Processor() - : base(Laplacian3X3XY) - { - } - } -} diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs deleted file mode 100644 index 11438fe8db..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Laplacian 5 x 5 operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class Laplacian5X5Processor : EdgeDetectorProcessor - where TPixel : struct, IPixel - { - /// - /// The 2d gradient operator. - /// - private static readonly Fast2DArray Laplacian5X5XY = - new float[,] - { - { -1, -1, -1, -1, -1 }, - { -1, -1, -1, -1, -1 }, - { -1, -1, 24, -1, -1 }, - { -1, -1, -1, -1, -1 }, - { -1, -1, -1, -1, -1 } - }; - - /// - /// Initializes a new instance of the class. - /// - public Laplacian5X5Processor() - : base(Laplacian5X5XY) - { - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs deleted file mode 100644 index 424c01137e..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Laplacian of Gaussian operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class LaplacianOfGaussianProcessor : EdgeDetectorProcessor - where TPixel : struct, IPixel - { - /// - /// The 2d gradient operator. - /// - private static readonly Fast2DArray LaplacianOfGaussianXY = - new float[,] - { - { 0, 0, -1, 0, 0 }, - { 0, -1, -2, -1, 0 }, - { -1, -2, 16, -2, -1 }, - { 0, -1, -2, -1, 0 }, - { 0, 0, -1, 0, 0 } - }; - - /// - /// Initializes a new instance of the class. - /// - public LaplacianOfGaussianProcessor() - : base(LaplacianOfGaussianXY) - { - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs deleted file mode 100644 index 0d2e9b2066..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Prewitt operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class PrewittProcessor : EdgeDetector2DProcessor - where TPixel : struct, IPixel - { - /// - /// The horizontal gradient operator. - /// - private static readonly Fast2DArray PrewittX = - new float[,] - { - { -1, 0, 1 }, - { -1, 0, 1 }, - { -1, 0, 1 } - }; - - /// - /// The vertical gradient operator. - /// - private static readonly Fast2DArray PrewittY = - new float[,] - { - { 1, 1, 1 }, - { 0, 0, 0 }, - { -1, -1, -1 } - }; - - /// - /// Initializes a new instance of the class. - /// - public PrewittProcessor() - : base(PrewittX, PrewittY) - { - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs deleted file mode 100644 index 09aa8ecb6c..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Roberts Cross operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class RobertsCrossProcessor : EdgeDetector2DProcessor - where TPixel : struct, IPixel - { - /// - /// The horizontal gradient operator. - /// - private static readonly Fast2DArray RobertsCrossX = - new float[,] - { - { 1, 0 }, - { 0, -1 } - }; - - /// - /// The vertical gradient operator. - /// - private static readonly Fast2DArray RobertsCrossY = - new float[,] - { - { 0, 1 }, - { -1, 0 } - }; - - /// - /// Initializes a new instance of the class. - /// - public RobertsCrossProcessor() - : base(RobertsCrossX, RobertsCrossY) - { - } - } -} diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs deleted file mode 100644 index 18f8cbf18c..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Kirsch operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class RobinsonProcessor : EdgeDetectorCompassProcessor - where TPixel : struct, IPixel - { - /// - /// The North gradient operator - /// - private static readonly Fast2DArray RobinsonNorth = - new float[,] - { - { 1, 2, 1 }, - { 0, 0, 0 }, - { -1, -2, -1 } - }; - - /// - /// The NorthWest gradient operator - /// - private static readonly Fast2DArray RobinsonNorthWest = - new float[,] - { - { 2, 1, 0 }, - { 1, 0, -1 }, - { 0, -1, -2 } - }; - - /// - /// The West gradient operator - /// - private static readonly Fast2DArray RobinsonWest = - new float[,] - { - { 1, 0, -1 }, - { 2, 0, -2 }, - { 1, 0, -1 } - }; - - /// - /// The SouthWest gradient operator - /// - private static readonly Fast2DArray RobinsonSouthWest = - new float[,] - { - { 0, -1, -2 }, - { 1, 0, -1 }, - { 2, 1, 0 } - }; - - /// - /// The South gradient operator - /// - private static readonly Fast2DArray RobinsonSouth = - new float[,] - { - { -1, -2, -1 }, - { 0, 0, 0 }, - { 1, 2, 1 } - }; - - /// - /// The SouthEast gradient operator - /// - private static readonly Fast2DArray RobinsonSouthEast = - new float[,] - { - { -2, -1, 0 }, - { -1, 0, 1 }, - { 0, 1, 2 } - }; - - /// - /// The East gradient operator - /// - private static readonly Fast2DArray RobinsonEast = - new float[,] - { - { -1, 0, 1 }, - { -2, 0, 2 }, - { -1, 0, 1 } - }; - - /// - /// The NorthEast gradient operator - /// - private static readonly Fast2DArray RobinsonNorthEast = - new float[,] - { - { 0, 1, 2 }, - { -1, 0, 1 }, - { -2, -1, 0 } - }; - - /// - public override Fast2DArray North => RobinsonNorth; - - /// - public override Fast2DArray NorthWest => RobinsonNorthWest; - - /// - public override Fast2DArray West => RobinsonWest; - - /// - public override Fast2DArray SouthWest => RobinsonSouthWest; - - /// - public override Fast2DArray South => RobinsonSouth; - - /// - public override Fast2DArray SouthEast => RobinsonSouthEast; - - /// - public override Fast2DArray East => RobinsonEast; - - /// - public override Fast2DArray NorthEast => RobinsonNorthEast; - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs deleted file mode 100644 index e299d3f807..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Scharr operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class ScharrProcessor : EdgeDetector2DProcessor - where TPixel : struct, IPixel - { - /// - /// The horizontal gradient operator. - /// - private static readonly Fast2DArray ScharrX = - new float[,] - { - { -3, 0, 3 }, - { -10, 0, 10 }, - { -3, 0, 3 } - }; - - /// - /// The vertical gradient operator. - /// - private static readonly Fast2DArray ScharrY = - new float[,] - { - { 3, 10, 3 }, - { 0, 0, 0 }, - { -3, -10, -3 } - }; - - /// - /// Initializes a new instance of the class. - /// - public ScharrProcessor() - : base(ScharrX, ScharrY) - { - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs deleted file mode 100644 index e975e4ff6c..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Sobel operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class SobelProcessor : EdgeDetector2DProcessor - where TPixel : struct, IPixel - { - /// - /// The horizontal gradient operator. - /// - private static readonly Fast2DArray SobelX = - new float[,] - { - { -1, 0, 1 }, - { -2, 0, 2 }, - { -1, 0, 1 } - }; - - /// - /// The vertical gradient operator. - /// - private static readonly Fast2DArray SobelY = - new float[,] - { - { -1, -2, -1 }, - { 0, 0, 0 }, - { 1, 2, 1 } - }; - - /// - /// Initializes a new instance of the class. - /// - public SobelProcessor() - : base(SobelX, SobelY) - { - } - } -} diff --git a/src/ImageSharp/Processing/Processors/DelegateProcessor.cs b/src/ImageSharp/Processing/Processors/DelegateProcessor.cs index f17c39681e..0bfc149772 100644 --- a/src/ImageSharp/Processing/Processors/DelegateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/DelegateProcessor.cs @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Processing } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { // NOP, we did all we wanted to do inside BeforeImageApply } diff --git a/src/ImageSharp/Processing/Processors/Filters/LomographProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/LomographProcessor.cs deleted file mode 100644 index 33c4338d58..0000000000 --- a/src/ImageSharp/Processing/Processors/Filters/LomographProcessor.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System.Numerics; - -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.Primitives; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// Converts the colors of the image recreating an old Lomograph effect. - /// - /// The pixel format. - internal class LomographProcessor : FilterProcessor - where TPixel : struct, IPixel - { - private static readonly TPixel VeryDarkGreen = ColorBuilder.FromRGBA(0, 10, 0, 255); - - private readonly MemoryManager memoryManager; - - private readonly GraphicsOptions options; - - /// - /// Initializes a new instance of the class. - /// - /// The to use for buffer allocations. - /// The options effecting blending and composition. - public LomographProcessor(MemoryManager memoryManager, GraphicsOptions options) - : base(MatrixFilters.LomographFilter) - { - this.memoryManager = memoryManager; - this.options = options; - } - - /// - protected override void AfterApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) - { - new VignetteProcessor(this.memoryManager, VeryDarkGreen, this.options).Apply(source, sourceRectangle, configuration); - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs deleted file mode 100644 index 152d586afe..0000000000 --- a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.Primitives; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// Converts the colors of the image recreating an old Polaroid effect. - /// - /// The pixel format. - internal class PolaroidProcessor : FilterProcessor - where TPixel : struct, IPixel - { - private static readonly TPixel VeryDarkOrange = ColorBuilder.FromRGB(102, 34, 0); - private static readonly TPixel LightOrange = ColorBuilder.FromRGBA(255, 153, 102, 128); - - private readonly MemoryManager memoryManager; - - private readonly GraphicsOptions options; - - /// - /// Initializes a new instance of the class. - /// - /// The to use for buffer allocations. - /// The options effecting blending and composition. - public PolaroidProcessor(MemoryManager memoryManager, GraphicsOptions options) - : base(MatrixFilters.PolaroidFilter) - { - this.memoryManager = memoryManager; - this.options = options; - } - - /// - protected override void AfterApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) - { - new VignetteProcessor(this.memoryManager, VeryDarkOrange, this.options).Apply(source, sourceRectangle, configuration); - new GlowProcessor(this.memoryManager, LightOrange, source.Width / 4F, this.options).Apply(source, sourceRectangle, configuration); - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/ImageProcessor.cs b/src/ImageSharp/Processing/Processors/ImageProcessor.cs index cab99112c1..124b345597 100644 --- a/src/ImageSharp/Processing/Processors/ImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ImageProcessor.cs @@ -52,9 +52,9 @@ namespace SixLabors.ImageSharp.Processing { try { - this.BeforeApply(source, sourceRectangle, configuration); - this.OnApply(source, sourceRectangle, configuration); - this.AfterApply(source, sourceRectangle, configuration); + this.BeforeFrameApply(source, sourceRectangle, configuration); + this.OnFrameApply(source, sourceRectangle, configuration); + this.AfterFrameApply(source, sourceRectangle, configuration); } #if DEBUG catch (Exception) @@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Processing /// The source image. Cannot be null. /// The structure that specifies the portion of the image object to draw. /// The configuration. - protected virtual void BeforeApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected virtual void BeforeFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { } @@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Processing /// The source image. Cannot be null. /// The structure that specifies the portion of the image object to draw. /// The configuration. - protected abstract void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration); + protected abstract void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration); /// /// This method is called after the process is applied to prepare the processor. @@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Processing /// The source image. Cannot be null. /// The structure that specifies the portion of the image object to draw. /// The configuration. - protected virtual void AfterApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected virtual void AfterFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { } diff --git a/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs similarity index 86% rename from src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs rename to src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs index 720b876913..d07dcbeed8 100644 --- a/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs @@ -19,25 +19,23 @@ namespace SixLabors.ImageSharp.Processing.Processors { private readonly MemoryManager memoryManager; - private readonly GraphicsOptions options; - /// /// Initializes a new instance of the class. /// /// The to use for buffer allocations. /// The to set the background color to. - /// The options defining blending algorithum and amount. + /// The options defining blending algorithm and amount. public BackgroundColorProcessor(MemoryManager memoryManager, TPixel color, GraphicsOptions options) { this.Value = color; this.memoryManager = memoryManager; - this.options = options; + this.GraphicsOptions = options; } /// /// Gets the Graphics options to alter how processor is applied. /// - public GraphicsOptions GraphicsOptions => this.options; + public GraphicsOptions GraphicsOptions { get; } /// /// Gets the background color value. @@ -45,7 +43,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public TPixel Value { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; @@ -81,10 +79,10 @@ namespace SixLabors.ImageSharp.Processing.Processors for (int i = 0; i < width; i++) { colorSpan[i] = this.Value; - amountSpan[i] = this.options.BlendPercentage; + amountSpan[i] = this.GraphicsOptions.BlendPercentage; } - PixelBlender blender = PixelOperations.Instance.GetPixelBlender(this.options.BlenderMode); + PixelBlender blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions.BlenderMode); Parallel.For( minY, maxY, @@ -93,7 +91,7 @@ namespace SixLabors.ImageSharp.Processing.Processors { Span destination = source.GetPixelRowSpan(y - startY).Slice(minX - startX, width); - // This switched color & destination in the 2nd and 3rd places because we are applying the target colour under the current one + // This switched color & destination in the 2nd and 3rd places because we are applying the target color under the current one blender.Blend(this.memoryManager, destination, colors.Span, destination, amount.Span); }); } diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs index 9ab301718c..d08283a0fe 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs @@ -10,7 +10,7 @@ using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Processors.Overlays { /// /// An that applies a radial glow effect an . @@ -19,31 +19,50 @@ namespace SixLabors.ImageSharp.Processing.Processors internal class GlowProcessor : ImageProcessor where TPixel : struct, IPixel { - private readonly MemoryManager memoryManager; - - private readonly GraphicsOptions options; private readonly PixelBlender blender; /// /// Initializes a new instance of the class. /// - /// The to use for buffer allocations. + /// The color or the glow. + public GlowProcessor(TPixel color) + { + this.GlowColor = color; + this.GraphicsOptions = GraphicsOptions.Default; + this.blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions.BlenderMode); + } + + /// + /// Initializes a new instance of the class. + /// + /// The color or the glow. + /// The radius of the glow. + public GlowProcessor(TPixel color, ValueSize radius) + { + this.GlowColor = color; + this.Radius = radius; + this.GraphicsOptions = GraphicsOptions.Default; + this.blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions.BlenderMode); + } + + /// + /// Initializes a new instance of the class. + /// /// The color or the glow. /// The radius of the glow. /// The options effecting blending and composition. - public GlowProcessor(MemoryManager memoryManager, TPixel color, ValueSize radius, GraphicsOptions options) + public GlowProcessor(TPixel color, ValueSize radius, GraphicsOptions options) { - this.memoryManager = memoryManager; - this.options = options; this.GlowColor = color; this.Radius = radius; - this.blender = PixelOperations.Instance.GetPixelBlender(this.options.BlenderMode); + this.blender = PixelOperations.Instance.GetPixelBlender(options.BlenderMode); + this.GraphicsOptions = options; } /// - /// Gets the Graphics options to alter how processor is applied. + /// Gets the options effecting blending and composition /// - public GraphicsOptions GraphicsOptions => this.options; + public GraphicsOptions GraphicsOptions { get; } /// /// Gets or sets the glow color to apply. @@ -56,7 +75,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public ValueSize Radius { get; set; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; @@ -87,7 +106,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } int width = maxX - minX; - using (IBuffer rowColors = this.memoryManager.Allocate(width)) + using (IBuffer rowColors = source.MemoryManager.Allocate(width)) { // Be careful! Do not capture rowColorsSpan in the lambda below! Span rowColorsSpan = rowColors.Span; @@ -103,7 +122,7 @@ namespace SixLabors.ImageSharp.Processing.Processors configuration.ParallelOptions, y => { - using (IBuffer amounts = this.memoryManager.Allocate(width)) + using (IBuffer amounts = source.MemoryManager.Allocate(width)) { Span amountsSpan = amounts.Span; int offsetY = y - startY; @@ -111,12 +130,12 @@ namespace SixLabors.ImageSharp.Processing.Processors for (int i = 0; i < width; i++) { float distance = Vector2.Distance(centre, new Vector2(i + offsetX, offsetY)); - amountsSpan[i] = (this.options.BlendPercentage * (1 - (.95F * (distance / maxDistance)))).Clamp(0, 1); + amountsSpan[i] = (this.GraphicsOptions.BlendPercentage * (1 - (.95F * (distance / maxDistance)))).Clamp(0, 1); } Span destination = source.GetPixelRowSpan(offsetY).Slice(offsetX, width); - this.blender.Blend(this.memoryManager, destination, destination, rowColors.Span, amountsSpan); + this.blender.Blend(source.MemoryManager, destination, destination, rowColors.Span, amountsSpan); } }); } diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs index d47211f0cb..3a2fc595c8 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs @@ -10,7 +10,7 @@ using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Processors.Overlays { /// /// An that applies a radial vignette effect to an . @@ -19,47 +19,51 @@ namespace SixLabors.ImageSharp.Processing.Processors internal class VignetteProcessor : ImageProcessor where TPixel : struct, IPixel { - private readonly MemoryManager memoryManager; - - private readonly GraphicsOptions options; private readonly PixelBlender blender; /// /// Initializes a new instance of the class. /// - /// The to use for buffer allocations. /// The color of the vignette. - /// The x-radius. - /// The y-radius. + public VignetteProcessor(TPixel color) + { + this.VignetteColor = color; + this.GraphicsOptions = GraphicsOptions.Default; + this.blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions.BlenderMode); + } + + /// + /// Initializes a new instance of the class. + /// + /// The color of the vignette. /// The options effecting blending and composition. - public VignetteProcessor(MemoryManager memoryManager, TPixel color, ValueSize radiusX, ValueSize radiusY, GraphicsOptions options) + public VignetteProcessor(TPixel color, GraphicsOptions options) { this.VignetteColor = color; - this.RadiusX = radiusX; - this.RadiusY = radiusY; - this.memoryManager = memoryManager; - this.options = options; - this.blender = PixelOperations.Instance.GetPixelBlender(this.options.BlenderMode); + this.GraphicsOptions = options; + this.blender = PixelOperations.Instance.GetPixelBlender(options.BlenderMode); } /// /// Initializes a new instance of the class. /// - /// The to use for buffer allocations. /// The color of the vignette. + /// The x-radius. + /// The y-radius. /// The options effecting blending and composition. - public VignetteProcessor(MemoryManager memoryManager, TPixel color, GraphicsOptions options) + public VignetteProcessor(TPixel color, ValueSize radiusX, ValueSize radiusY, GraphicsOptions options) { this.VignetteColor = color; - this.memoryManager = memoryManager; - this.options = options; - this.blender = PixelOperations.Instance.GetPixelBlender(this.options.BlenderMode); + this.RadiusX = radiusX; + this.RadiusY = radiusY; + this.blender = PixelOperations.Instance.GetPixelBlender(options.BlenderMode); + this.GraphicsOptions = options; } /// - /// Gets the Graphics options to alter how processor is applied. + /// Gets the options effecting blending and composition /// - public GraphicsOptions GraphicsOptions => this.options; + public GraphicsOptions GraphicsOptions { get; } /// /// Gets or sets the vignette color to apply. @@ -77,7 +81,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public ValueSize RadiusY { get; set; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; @@ -86,10 +90,10 @@ namespace SixLabors.ImageSharp.Processing.Processors TPixel vignetteColor = this.VignetteColor; Vector2 centre = Rectangle.Center(sourceRectangle); - float finalradiusX = this.RadiusX.Calculate(source.Size()); - float finalradiusY = this.RadiusY.Calculate(source.Size()); - float rX = finalradiusX > 0 ? MathF.Min(finalradiusX, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F; - float rY = finalradiusY > 0 ? MathF.Min(finalradiusY, sourceRectangle.Height * .5F) : sourceRectangle.Height * .5F; + float finalRadiusX = this.RadiusX.Calculate(source.Size()); + float finalRadiusY = this.RadiusY.Calculate(source.Size()); + float rX = finalRadiusX > 0 ? MathF.Min(finalRadiusX, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F; + float rY = finalRadiusY > 0 ? MathF.Min(finalRadiusY, sourceRectangle.Height * .5F) : sourceRectangle.Height * .5F; float maxDistance = MathF.Sqrt((rX * rX) + (rY * rY)); // Align start/end positions. @@ -110,7 +114,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } int width = maxX - minX; - using (IBuffer rowColors = this.memoryManager.Allocate(width)) + using (IBuffer rowColors = source.MemoryManager.Allocate(width)) { // Be careful! Do not capture rowColorsSpan in the lambda below! Span rowColorsSpan = rowColors.Span; @@ -126,7 +130,7 @@ namespace SixLabors.ImageSharp.Processing.Processors configuration.ParallelOptions, y => { - using (IBuffer amounts = this.memoryManager.Allocate(width)) + using (IBuffer amounts = source.MemoryManager.Allocate(width)) { Span amountsSpan = amounts.Span; int offsetY = y - startY; @@ -134,12 +138,12 @@ namespace SixLabors.ImageSharp.Processing.Processors for (int i = 0; i < width; i++) { float distance = Vector2.Distance(centre, new Vector2(i + offsetX, offsetY)); - amountsSpan[i] = (this.options.BlendPercentage * (.9F * (distance / maxDistance))).Clamp(0, 1); + amountsSpan[i] = (this.GraphicsOptions.BlendPercentage * (.9F * (distance / maxDistance))).Clamp(0, 1); } Span destination = source.GetPixelRowSpan(offsetY).Slice(offsetX, width); - this.blender.Blend(this.memoryManager, destination, destination, rowColors.Span, amountsSpan); + this.blender.Blend(source.MemoryManager, destination, destination, rowColors.Span, amountsSpan); } }); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor.cs index ac11e0dfb3..864001d075 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor.cs @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void OnApply( + protected override void OnFrameApply( ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, diff --git a/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs index 7f811eebc1..c118a7e866 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void OnApply(ImageFrame sourceBase, Rectangle sourceRectangle, Configuration config) + protected override void OnFrameApply(ImageFrame sourceBase, Rectangle sourceRectangle, Configuration config) { // all processing happens at the image level within BeforeImageApply(); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs index c04014ae35..ff5011bdbe 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs @@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Rectangle CropRectangle { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { if (this.CropRectangle == sourceRectangle) { diff --git a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs index d2a08daba6..f263209026 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs @@ -3,6 +3,8 @@ using System; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Binarization.Processors; +using SixLabors.ImageSharp.Processing.Convolution.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Processors @@ -34,12 +36,12 @@ namespace SixLabors.ImageSharp.Processing.Processors public float Threshold { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { using (ImageFrame temp = source.Clone()) { // Detect the edges. - new SobelProcessor().Apply(temp, sourceRectangle, configuration); + new SobelProcessor(false).Apply(temp, sourceRectangle, configuration); // Apply threshold binarization filter. new BinaryThresholdProcessor(this.Threshold).Apply(temp, sourceRectangle, configuration); diff --git a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs index 9b8b785b58..6c2705979d 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs @@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public FlipType FlipType { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { switch (this.FlipType) { diff --git a/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs index e16cd9ee84..dc0970a6cd 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void OnApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) { int height = this.TargetDimensions.Height; int width = this.TargetDimensions.Width; diff --git a/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs index 2e73920baa..dfb7b84b66 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs @@ -219,7 +219,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void BeforeApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) + protected override void BeforeFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) { if (!(this.Sampler is NearestNeighborResampler)) { @@ -237,7 +237,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void OnApply(ImageFrame source, ImageFrame cloned, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, ImageFrame cloned, Rectangle sourceRectangle, Configuration configuration) { // Jump out, we'll deal with that later. if (source.Width == cloned.Width && source.Height == cloned.Height && sourceRectangle == this.ResizeRectangle) @@ -366,9 +366,9 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void AfterApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) + protected override void AfterFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) { - base.AfterApply(source, destination, sourceRectangle, configuration); + base.AfterFrameApply(source, destination, sourceRectangle, configuration); // TODO: An exception in the processing chain can leave these buffers undisposed. We should consider making image processors IDisposable! this.horizontalWeights?.Dispose(); diff --git a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs index 824ae4310f..fabae88fd4 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// The angle of rotation in degrees. /// The source image size public RotateProcessor(float degrees, Size sourceSize) - : this(degrees, KnownResamplers.Bicubic, sourceSize) + : this(degrees, Resamplers.Bicubic, sourceSize) { } @@ -46,14 +46,14 @@ namespace SixLabors.ImageSharp.Processing.Processors public float Degrees { get; } /// - protected override void OnApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) { if (this.OptimizedApply(source, destination, configuration)) { return; } - base.OnApply(source, destination, sourceRectangle, configuration); + base.OnFrameApply(source, destination, sourceRectangle, configuration); } /// diff --git a/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs index 8e3ab7c34f..ad0aad7bbb 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs @@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// The angle in degrees to perform the skew along the y-axis. /// The source image size public SkewProcessor(float degreesX, float degreesY, Size sourceSize) - : this(degreesX, degreesY, KnownResamplers.Bicubic, sourceSize) + : this(degreesX, degreesY, Resamplers.Bicubic, sourceSize) { } diff --git a/src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs b/src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs index f13fa77c99..03adf58c34 100644 --- a/src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs +++ b/src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs @@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Processing /// /// Gets or sets the sampler to perform the resize operation. /// - public IResampler Sampler { get; set; } = KnownResamplers.Bicubic; + public IResampler Sampler { get; set; } = Resamplers.Bicubic; /// /// Gets or sets a value indicating whether to compress diff --git a/src/ImageSharp/Processing/Transforms/Pad.cs b/src/ImageSharp/Processing/Transforms/Pad.cs index 2f637aa162..1c990f82ea 100644 --- a/src/ImageSharp/Processing/Transforms/Pad.cs +++ b/src/ImageSharp/Processing/Transforms/Pad.cs @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp { Size = new Size(width, height), Mode = ResizeMode.BoxPad, - Sampler = KnownResamplers.NearestNeighbor + Sampler = Resamplers.NearestNeighbor }; return Resize(source, options); diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/KnownResamplers.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Resamplers.cs similarity index 99% rename from src/ImageSharp/Processing/Transforms/Resamplers/KnownResamplers.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/Resamplers.cs index 2da98497b5..599ae2dadb 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/KnownResamplers.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/Resamplers.cs @@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Processing /// /// Contains reusable static instances of known resampling algorithms /// - public static class KnownResamplers + public static class Resamplers { /// /// Gets the Bicubic sampler that implements the bicubic kernel algorithm W(x) diff --git a/src/ImageSharp/Processing/Transforms/Resize.cs b/src/ImageSharp/Processing/Transforms/Resize.cs index 285f3206dc..b94addb27b 100644 --- a/src/ImageSharp/Processing/Transforms/Resize.cs +++ b/src/ImageSharp/Processing/Transforms/Resize.cs @@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, Size size) where TPixel : struct, IPixel - => Resize(source, size.Width, size.Height, KnownResamplers.Bicubic, false); + => Resize(source, size.Width, size.Height, Resamplers.Bicubic, false); /// /// Resizes an image to the given . @@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, Size size, bool compand) where TPixel : struct, IPixel - => Resize(source, size.Width, size.Height, KnownResamplers.Bicubic, compand); + => Resize(source, size.Width, size.Height, Resamplers.Bicubic, compand); /// /// Resizes an image to the given width and height. @@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, int width, int height) where TPixel : struct, IPixel - => Resize(source, width, height, KnownResamplers.Bicubic, false); + => Resize(source, width, height, Resamplers.Bicubic, false); /// /// Resizes an image to the given width and height. @@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, int width, int height, bool compand) where TPixel : struct, IPixel - => Resize(source, width, height, KnownResamplers.Bicubic, compand); + => Resize(source, width, height, Resamplers.Bicubic, compand); /// /// Resizes an image to the given width and height with the given sampler. diff --git a/src/ImageSharp/Processing/Transforms/Rotate.cs b/src/ImageSharp/Processing/Transforms/Rotate.cs index faecdf91f9..bbaa762a22 100644 --- a/src/ImageSharp/Processing/Transforms/Rotate.cs +++ b/src/ImageSharp/Processing/Transforms/Rotate.cs @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp /// The public static IImageProcessingContext Rotate(this IImageProcessingContext source, float degrees) where TPixel : struct, IPixel - => Rotate(source, degrees, KnownResamplers.Bicubic); + => Rotate(source, degrees, Resamplers.Bicubic); /// /// Rotates an image by the given angle in degrees using the specified sampling algorithm. diff --git a/src/ImageSharp/Processing/Transforms/Skew.cs b/src/ImageSharp/Processing/Transforms/Skew.cs index fb054211a0..f4a92e0100 100644 --- a/src/ImageSharp/Processing/Transforms/Skew.cs +++ b/src/ImageSharp/Processing/Transforms/Skew.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp /// The public static IImageProcessingContext Skew(this IImageProcessingContext source, float degreesX, float degreesY) where TPixel : struct, IPixel - => Skew(source, degreesX, degreesY, KnownResamplers.Bicubic); + => Skew(source, degreesX, degreesY, Resamplers.Bicubic); /// /// Skews an image by the given angles in degrees using the specified sampling algorithm. diff --git a/src/ImageSharp/Processing/Transforms/Transform.cs b/src/ImageSharp/Processing/Transforms/Transform.cs index 66d5d5de7e..b82713ca94 100644 --- a/src/ImageSharp/Processing/Transforms/Transform.cs +++ b/src/ImageSharp/Processing/Transforms/Transform.cs @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp /// The public static IImageProcessingContext Transform(this IImageProcessingContext source, Matrix3x2 matrix) where TPixel : struct, IPixel - => Transform(source, matrix, KnownResamplers.Bicubic); + => Transform(source, matrix, Resamplers.Bicubic); /// /// Transforms an image by the given matrix using the specified sampling algorithm. @@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp /// The internal static IImageProcessingContext Transform(this IImageProcessingContext source, Matrix4x4 matrix) where TPixel : struct, IPixel - => Transform(source, matrix, KnownResamplers.Bicubic); + => Transform(source, matrix, Resamplers.Bicubic); /// /// Applies a projective transform to the image by the given matrix using the specified sampling algorithm. diff --git a/src/ImageSharp/Quantizers/QuantizerBase{TPixel}.cs b/src/ImageSharp/Quantizers/QuantizerBase{TPixel}.cs index 0b41edf98d..84dfd8dd5c 100644 --- a/src/ImageSharp/Quantizers/QuantizerBase{TPixel}.cs +++ b/src/ImageSharp/Quantizers/QuantizerBase{TPixel}.cs @@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Quantizers.Base public bool Dither { get; set; } = true; /// - public IErrorDiffuser DitherType { get; set; } = KnownDiffusers.FloydSteinberg; + public IErrorDiffuser DitherType { get; set; } = Diffusers.FloydSteinberg; /// public virtual QuantizedImage Quantize(ImageFrame image, int maxColors) diff --git a/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs b/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs index f65957128c..9a208e6159 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Convolution; using CoreImage = ImageSharp.Image; @@ -38,17 +39,17 @@ namespace SixLabors.ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp DetectEdges")] public void ImageProcessorCoreDetectEdges() { - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Kayyali)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Kayyali)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Kirsch)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Lapacian3X3)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Lapacian5X5)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.LaplacianOfGaussian)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Prewitt)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.RobertsCross)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Robinson)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Scharr)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Sobel)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Kayyali)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Kayyali)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Kirsch)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Laplacian3x3)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Laplacian5x5)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.LaplacianOfGaussian)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Prewitt)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.RobertsCross)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Robinson)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Scharr)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Sobel)); } } } diff --git a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs index 5f4e2d75b4..b14630cea8 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs @@ -19,6 +19,7 @@ namespace SixLabors.ImageSharp.Benchmarks using SixLabors.Primitives; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Advanced; + using SixLabors.ImageSharp.Processing.Processors.Overlays; public class Glow : BenchmarkBase { @@ -28,7 +29,7 @@ namespace SixLabors.ImageSharp.Benchmarks [GlobalSetup] public void Setup() { - this.bulk = new GlowProcessor(Configuration.Default.MemoryManager, NamedColors.Beige, 800 * .5f, GraphicsOptions.Default); + this.bulk = new GlowProcessor(NamedColors.Beige, 800 * .5f, GraphicsOptions.Default); this.parallel = new GlowProcessorParallel(NamedColors.Beige) { Radius = 800 * .5f, }; } @@ -75,7 +76,7 @@ namespace SixLabors.ImageSharp.Benchmarks public float Radius { get; set; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs index 5fcb860be5..c49ba05eef 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs @@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.Tests // We pass a new rectangle here based on the dest bounds since we've offset the matrix blend.Mutate(x => x.Transform( centeredMatrix, - KnownResamplers.Bicubic, + Resamplers.Bicubic, new Rectangle(0, 0, destBounds.Width, destBounds.Height))); var position = new Point((image.Width - blend.Width) / 2, (image.Height - blend.Height) / 2); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs index bf6b1f4ab2..70a35f182a 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs @@ -190,7 +190,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [MemberData(nameof(CommonConversionData))] public void ConvertFromGrayScale(int inputBufferLength, int resultBufferLength, int seed) { - var converter = JpegColorConverter.GetConverter(JpegColorSpace.GrayScale); + var converter = JpegColorConverter.GetConverter(JpegColorSpace.Grayscale); JpegColorConverter.ComponentValues values = CreateRandomValues(1, inputBufferLength, seed); Vector4[] result = new Vector4[resultBufferLength]; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs index e56e912074..eb8ee90f9c 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Theory] [InlineData(TestImages.Jpeg.Baseline.Testorig420, JpegColorSpace.YCbCr)] - [InlineData(TestImages.Jpeg.Baseline.Jpeg400, JpegColorSpace.GrayScale)] + [InlineData(TestImages.Jpeg.Baseline.Jpeg400, JpegColorSpace.Grayscale)] [InlineData(TestImages.Jpeg.Baseline.Ycck, JpegColorSpace.Ycck)] [InlineData(TestImages.Jpeg.Baseline.Cmyk, JpegColorSpace.Cmyk)] public void ColorSpace_IsDeducedCorrectly(string imageFile, object expectedColorSpaceValue) diff --git a/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs index 003f998d88..8879bf9919 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Binarization { + using SixLabors.ImageSharp.Processing.Binarization; + using SixLabors.ImageSharp.Processing.Binarization.Processors; + public class BinaryDitherTest : BaseImageOperationsExtensionTest { private readonly IOrderedDither orderedDither; @@ -15,8 +18,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization public BinaryDitherTest() { - this.orderedDither = KnownDitherers.BayerDither4x4; - this.errorDiffuser = KnownDiffusers.FloydSteinberg; + this.orderedDither = Ditherers.BayerDither4x4; + this.errorDiffuser = Diffusers.FloydSteinberg; } [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs b/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs index 488b3d18b1..6029b0d5fa 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Binarization { + using SixLabors.ImageSharp.Processing.Binarization; + using SixLabors.ImageSharp.Processing.Binarization.Processors; + public class BinaryThresholdTest : BaseImageOperationsExtensionTest { diff --git a/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs index cd0e8e5ab0..07c69a94c2 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + using SixLabors.ImageSharp.Processing.Convolution.Processors; + public class BoxBlurTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs index b52938aac1..45a5b03135 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs @@ -11,6 +11,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + using SixLabors.ImageSharp.Processing.Convolution.Processors; + public class DetectEdgesTest : BaseImageOperationsExtensionTest { @@ -34,21 +37,21 @@ namespace SixLabors.ImageSharp.Tests.Processing.Convolution // Assert.True(processor.Grayscale); } public static IEnumerable EdgeDetectionTheoryData => new[] { - new object[]{ new TestType>(), EdgeDetection.Kayyali }, - new object[]{ new TestType>(), EdgeDetection.Kirsch }, - new object[]{ new TestType>(), EdgeDetection.Lapacian3X3 }, - new object[]{ new TestType>(), EdgeDetection.Lapacian5X5 }, - new object[]{ new TestType>(), EdgeDetection.LaplacianOfGaussian }, - new object[]{ new TestType>(), EdgeDetection.Prewitt }, - new object[]{ new TestType>(), EdgeDetection.RobertsCross }, - new object[]{ new TestType>(), EdgeDetection.Robinson }, - new object[]{ new TestType>(), EdgeDetection.Scharr }, - new object[]{ new TestType>(), EdgeDetection.Sobel }, + new object[]{ new TestType>(), EdgeDetectionOperators.Kayyali }, + new object[]{ new TestType>(), EdgeDetectionOperators.Kirsch }, + new object[]{ new TestType>(), EdgeDetectionOperators.Laplacian3x3 }, + new object[]{ new TestType>(), EdgeDetectionOperators.Laplacian5x5 }, + new object[]{ new TestType>(), EdgeDetectionOperators.LaplacianOfGaussian }, + new object[]{ new TestType>(), EdgeDetectionOperators.Prewitt }, + new object[]{ new TestType>(), EdgeDetectionOperators.RobertsCross }, + new object[]{ new TestType>(), EdgeDetectionOperators.Robinson }, + new object[]{ new TestType>(), EdgeDetectionOperators.Scharr }, + new object[]{ new TestType>(), EdgeDetectionOperators.Sobel }, }; [Theory] [MemberData(nameof(EdgeDetectionTheoryData))] - public void DetectEdges_filter_SobelProcessorDefaultsSet(TestType type, EdgeDetection filter) + public void DetectEdges_filter_SobelProcessorDefaultsSet(TestType type, EdgeDetectionOperators filter) where TProcessor : IEdgeDetectorProcessor { this.operations.DetectEdges(filter); @@ -60,7 +63,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Convolution [Theory] [MemberData(nameof(EdgeDetectionTheoryData))] - public void DetectEdges_filter_grayscale_SobelProcessorDefaultsSet(TestType type, EdgeDetection filter) + public void DetectEdges_filter_grayscale_SobelProcessorDefaultsSet(TestType type, EdgeDetectionOperators filter) where TProcessor : IEdgeDetectorProcessor { bool grey = (int)filter % 2 == 0; diff --git a/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs index d0773a0bfe..5399a7ec83 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + using SixLabors.ImageSharp.Processing.Convolution.Processors; + public class GaussianBlurTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs index c7c78a21a6..518c2960fb 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + using SixLabors.ImageSharp.Processing.Convolution.Processors; + public class GaussianSharpenTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs index 03ae17848c..3868ecd703 100644 --- a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs +++ b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Binarization { + using SixLabors.ImageSharp.Processing.Dithering; + using SixLabors.ImageSharp.Processing.Dithering.Processors; + public class DitherTest : BaseImageOperationsExtensionTest { private readonly IOrderedDither orderedDither; @@ -21,8 +24,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization public DitherTest() { - this.orderedDither = KnownDitherers.BayerDither4x4; - this.errorDiffuser = KnownDiffusers.FloydSteinberg; + this.orderedDither = Ditherers.BayerDither4x4; + this.errorDiffuser = Diffusers.FloydSteinberg; } [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs index 36de67188f..f40cc250bb 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects { + using SixLabors.ImageSharp.Processing.Effects; + using SixLabors.ImageSharp.Processing.Effects.Processors; + public class OilPaintTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs b/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs index 8b50e14861..1cc69bcb68 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects { + using SixLabors.ImageSharp.Processing.Effects; + using SixLabors.ImageSharp.Processing.Effects.Processors; + public class PixelateTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs b/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs index 4ade9fe64b..2a3d6e0cfe 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs @@ -6,6 +6,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class BlackWhiteTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs index 05605767fb..dc3281a638 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class BrightnessTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs b/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs index 2dc695f560..d1e592c736 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs @@ -2,15 +2,16 @@ // Licensed under the Apache License, Version 2.0. using System.Collections.Generic; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; + using SixLabors.ImageSharp.Tests.TestUtilities; -using SixLabors.Primitives; + using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class ColorBlindnessTest : BaseImageOperationsExtensionTest { public static IEnumerable TheoryData = new[] { diff --git a/tests/ImageSharp.Tests/Processing/Filters/ContrastTest.cs b/tests/ImageSharp.Tests/Processing/Filters/ContrastTest.cs index 4aec24dad0..dab4ec5854 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/ContrastTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/ContrastTest.cs @@ -6,6 +6,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class ContrastTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/FilterTest.cs b/tests/ImageSharp.Tests/Processing/Filters/FilterTest.cs index d1e9c0ba0a..6fa22030a8 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/FilterTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/FilterTest.cs @@ -7,6 +7,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class FilterTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs b/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs index 80c377eb1d..5195894450 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs @@ -1,17 +1,17 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Collections; using System.Collections.Generic; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; + using SixLabors.ImageSharp.Tests.TestUtilities; -using SixLabors.Primitives; + using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class GrayscaleTest : BaseImageOperationsExtensionTest { public static IEnumerable ModeTheoryData = new[] { diff --git a/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs b/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs index bf03ee4f81..e9f79ff1d4 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class HueTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/InvertTest.cs b/tests/ImageSharp.Tests/Processing/Filters/InvertTest.cs index ad74b3c909..24d33e9f7d 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/InvertTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/InvertTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class InvertTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/KodachromeTest.cs b/tests/ImageSharp.Tests/Processing/Filters/KodachromeTest.cs index b3731d43c1..d776a9c8a7 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/KodachromeTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/KodachromeTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class KodachromeTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs b/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs index 32107cb716..5bd4394ab2 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs @@ -9,6 +9,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class LomographTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/OpacityTest.cs b/tests/ImageSharp.Tests/Processing/Filters/OpacityTest.cs index 4108cbddac..6d217fa152 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/OpacityTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/OpacityTest.cs @@ -6,6 +6,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class OpacityTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs b/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs index 5661851a56..5e43245af6 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class PolaroidTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/SaturateTest.cs b/tests/ImageSharp.Tests/Processing/Filters/SaturateTest.cs index e3b9e3d3b2..7d115f1ad2 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/SaturateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/SaturateTest.cs @@ -6,6 +6,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class SaturateTest : BaseImageOperationsExtensionTest { diff --git a/tests/ImageSharp.Tests/Processing/Filters/SepiaTest.cs b/tests/ImageSharp.Tests/Processing/Filters/SepiaTest.cs index 4983313882..b8a77c9f05 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/SepiaTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/SepiaTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class SepiaTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs index 9e7a046507..b3ecdacbeb 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Overlays { + using SixLabors.ImageSharp.Processing.Processors.Overlays; + public class GlowTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs index e082e42cd7..01555c02a8 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs @@ -10,6 +10,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Overlays { + using SixLabors.ImageSharp.Processing.Processors.Overlays; + public class VignetteTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs index aec201239d..eb41c8435a 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs @@ -11,6 +11,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization { + using SixLabors.ImageSharp.Processing.Binarization; + public class BinaryDitherTests : FileTestBase { public static readonly string[] CommonTestImages = @@ -20,29 +22,29 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization public static readonly TheoryData Ditherers = new TheoryData { - { "Bayer8x8", KnownDitherers.BayerDither8x8 }, - { "Bayer4x4", KnownDitherers.BayerDither4x4 }, - { "Ordered3x3", KnownDitherers.OrderedDither3x3 }, - { "Bayer2x2", KnownDitherers.BayerDither2x2 } + { "Bayer8x8", Dithering.Ditherers.BayerDither8x8 }, + { "Bayer4x4", Dithering.Ditherers.BayerDither4x4 }, + { "Ordered3x3", Dithering.Ditherers.OrderedDither3x3 }, + { "Bayer2x2", Dithering.Ditherers.BayerDither2x2 } }; public static readonly TheoryData ErrorDiffusers = new TheoryData { - { "Atkinson", KnownDiffusers.Atkinson }, - { "Burks", KnownDiffusers.Burks }, - { "FloydSteinberg", KnownDiffusers.FloydSteinberg }, - { "JarvisJudiceNinke", KnownDiffusers.JarvisJudiceNinke }, - { "Sierra2", KnownDiffusers.Sierra2 }, - { "Sierra3", KnownDiffusers.Sierra3 }, - { "SierraLite", KnownDiffusers.SierraLite }, - { "StevensonArce", KnownDiffusers.StevensonArce }, - { "Stucki", KnownDiffusers.Stucki }, + { "Atkinson", Diffusers.Atkinson }, + { "Burks", Diffusers.Burks }, + { "FloydSteinberg", Diffusers.FloydSteinberg }, + { "JarvisJudiceNinke", Diffusers.JarvisJudiceNinke }, + { "Sierra2", Diffusers.Sierra2 }, + { "Sierra3", Diffusers.Sierra3 }, + { "SierraLite", Diffusers.SierraLite }, + { "StevensonArce", Diffusers.StevensonArce }, + { "Stucki", Diffusers.Stucki }, }; - private static IOrderedDither DefaultDitherer => KnownDitherers.BayerDither4x4; + private static IOrderedDither DefaultDitherer => Dithering.Ditherers.BayerDither4x4; - private static IErrorDiffuser DefaultErrorDiffuser => KnownDiffusers.Atkinson; + private static IErrorDiffuser DefaultErrorDiffuser => Diffusers.Atkinson; [Theory] [WithFileCollection(nameof(CommonTestImages), nameof(Ditherers), DefaultPixelType)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs index 3daeecfc75..42b9b9adf6 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization { + using SixLabors.ImageSharp.Processing.Binarization; + public class BinaryThresholdTest : FileTestBase { public static readonly TheoryData BinaryThresholdValues diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs index 94af7aa37e..a86d5d3a03 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + public class BoxBlurTest : FileTestBase { public static readonly TheoryData BoxBlurValues diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs index 323842556e..a3687f7b5f 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs @@ -10,28 +10,30 @@ using Xunit; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + public class DetectEdgesTest : FileTestBase { public static readonly string[] CommonTestImages = { TestImages.Png.Bike }; - public static readonly TheoryData DetectEdgesFilters = new TheoryData + public static readonly TheoryData DetectEdgesFilters = new TheoryData { - EdgeDetection.Kayyali, - EdgeDetection.Kirsch, - EdgeDetection.Lapacian3X3, - EdgeDetection.Lapacian5X5, - EdgeDetection.LaplacianOfGaussian, - EdgeDetection.Prewitt, - EdgeDetection.RobertsCross, - EdgeDetection.Robinson, - EdgeDetection.Scharr, - EdgeDetection.Sobel + EdgeDetectionOperators.Kayyali, + EdgeDetectionOperators.Kirsch, + EdgeDetectionOperators.Laplacian3x3, + EdgeDetectionOperators.Laplacian5x5, + EdgeDetectionOperators.LaplacianOfGaussian, + EdgeDetectionOperators.Prewitt, + EdgeDetectionOperators.RobertsCross, + EdgeDetectionOperators.Robinson, + EdgeDetectionOperators.Scharr, + EdgeDetectionOperators.Sobel }; [Theory] [WithTestPatternImages(nameof(DetectEdgesFilters), 100, 100, DefaultPixelType)] [WithFileCollection(nameof(CommonTestImages), nameof(DetectEdgesFilters), DefaultPixelType)] - public void DetectEdges_WorksWithAllFilters(TestImageProvider provider, EdgeDetection detector) + public void DetectEdges_WorksWithAllFilters(TestImageProvider provider, EdgeDetectionOperators detector) where TPixel : struct, IPixel { using (Image image = provider.GetImage()) diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs index 89e9a13b5c..d5885bb98c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + public class GaussianBlurTest : FileTestBase { public static readonly TheoryData GaussianBlurValues = new TheoryData { 3, 5 }; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs index 4775444a5a..4f3237a21b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + public class GaussianSharpenTest : FileTestBase { public static readonly TheoryData GaussianSharpenValues diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index 58c63d48c7..68d6efeec7 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -11,6 +11,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization { + using SixLabors.ImageSharp.Processing.Dithering; + public class DitherTests : FileTestBase { public static readonly string[] CommonTestImages = @@ -20,29 +22,29 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization public static readonly TheoryData Ditherers = new TheoryData { - { "Bayer8x8", KnownDitherers.BayerDither8x8 }, - { "Bayer4x4", KnownDitherers.BayerDither4x4 }, - { "Ordered3x3", KnownDitherers.OrderedDither3x3 }, - { "Bayer2x2", KnownDitherers.BayerDither2x2 } + { "Bayer8x8", Dithering.Ditherers.BayerDither8x8 }, + { "Bayer4x4", Dithering.Ditherers.BayerDither4x4 }, + { "Ordered3x3", Dithering.Ditherers.OrderedDither3x3 }, + { "Bayer2x2", Dithering.Ditherers.BayerDither2x2 } }; public static readonly TheoryData ErrorDiffusers = new TheoryData { - { "Atkinson", KnownDiffusers.Atkinson }, - { "Burks", KnownDiffusers.Burks }, - { "FloydSteinberg", KnownDiffusers.FloydSteinberg }, - { "JarvisJudiceNinke", KnownDiffusers.JarvisJudiceNinke }, - { "Sierra2", KnownDiffusers.Sierra2 }, - { "Sierra3", KnownDiffusers.Sierra3 }, - { "SierraLite", KnownDiffusers.SierraLite }, - { "StevensonArce", KnownDiffusers.StevensonArce }, - { "Stucki", KnownDiffusers.Stucki }, + { "Atkinson", Diffusers.Atkinson }, + { "Burks", Diffusers.Burks }, + { "FloydSteinberg", Diffusers.FloydSteinberg }, + { "JarvisJudiceNinke", Diffusers.JarvisJudiceNinke }, + { "Sierra2", Diffusers.Sierra2 }, + { "Sierra3", Diffusers.Sierra3 }, + { "SierraLite", Diffusers.SierraLite }, + { "StevensonArce", Diffusers.StevensonArce }, + { "Stucki", Diffusers.Stucki }, }; - private static IOrderedDither DefaultDitherer => KnownDitherers.BayerDither4x4; + private static IOrderedDither DefaultDitherer => Dithering.Ditherers.BayerDither4x4; - private static IErrorDiffuser DefaultErrorDiffuser => KnownDiffusers.Atkinson; + private static IErrorDiffuser DefaultErrorDiffuser => Diffusers.Atkinson; [Theory] [WithFileCollection(nameof(CommonTestImages), nameof(Ditherers), DefaultPixelType)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs index a9127f61dc..868763baf4 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects { + using SixLabors.ImageSharp.Processing.Effects; + public class OilPaintTest : FileTestBase { public static readonly TheoryData OilPaintValues = new TheoryData diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs index b3f1ee3a28..98bfbc5538 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects { + using SixLabors.ImageSharp.Processing.Effects; + public class PixelateTest : FileTestBase { public static readonly TheoryData PixelateValues diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/BlackWhiteTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/BlackWhiteTest.cs index e373230a73..ccf9152f0e 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/BlackWhiteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/BlackWhiteTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class BlackWhiteTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs index 783e55d832..14f5fa0808 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class BrightnessTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs index c0df24d291..b0dcbd726b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs @@ -8,6 +8,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class ColorBlindnessTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs index b532649b3d..c6afc5e11b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class ContrastTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/FilterTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/FilterTest.cs index 515b970aee..077073b4c7 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/FilterTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/FilterTest.cs @@ -11,6 +11,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class FilterTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs index f61c529a38..192034fbb6 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class GrayscaleTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs index fe9f9d5db2..6e3fd5feff 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class HueTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/InvertTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/InvertTest.cs index 452397c5eb..de105437ba 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/InvertTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/InvertTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class InvertTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/KodachromeTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/KodachromeTest.cs index a5165250b7..2265e0b0b0 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/KodachromeTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/KodachromeTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class KodachromeTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/LomographTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/LomographTest.cs index 09c8becec3..92c5b788cf 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/LomographTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/LomographTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class LomographTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs index 2cba4fb8ed..c76bf3b1de 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class OpacityTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/PolaroidTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/PolaroidTest.cs index 4e0347d2a4..19fcc67885 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/PolaroidTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/PolaroidTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class PolaroidTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs index 9b963b94a4..18d77660e4 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class SaturateTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/SepiaTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/SepiaTest.cs index 2a63e992d7..50bf0e3a1b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/SepiaTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/SepiaTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class SepiaTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs index 2e1b43c388..3920aff8aa 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms public void PrintWeightsData() { var size = new Size(500, 500); - var proc = new ResizeProcessor(KnownResamplers.Bicubic, 200, 200, size); + var proc = new ResizeProcessor(Resamplers.Bicubic, 200, 200, size); WeightsBuffer weights = proc.PrecomputeWeights(Configuration.Default.MemoryManager, proc.Width, size.Width); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs index 8370a802cd..e2ae50aff0 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -20,20 +20,20 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms public static readonly TheoryData AllReSamplers = new TheoryData { - { "Bicubic", KnownResamplers.Bicubic }, - { "Triangle", KnownResamplers.Triangle}, - { "NearestNeighbor", KnownResamplers.NearestNeighbor }, - { "Box", KnownResamplers.Box }, + { "Bicubic", Resamplers.Bicubic }, + { "Triangle", Resamplers.Triangle}, + { "NearestNeighbor", Resamplers.NearestNeighbor }, + { "Box", Resamplers.Box }, // { "Lanczos2", KnownResamplers.Lanczos2 }, TODO: Add expected file - { "Lanczos3", KnownResamplers.Lanczos3 }, - { "Lanczos5", KnownResamplers.Lanczos5 }, - { "MitchellNetravali", KnownResamplers.MitchellNetravali }, - { "Lanczos8", KnownResamplers.Lanczos8 }, - { "Hermite", KnownResamplers.Hermite }, - { "Spline", KnownResamplers.Spline }, - { "Robidoux", KnownResamplers.Robidoux }, - { "RobidouxSharp", KnownResamplers.RobidouxSharp }, - { "Welch", KnownResamplers.Welch } + { "Lanczos3", Resamplers.Lanczos3 }, + { "Lanczos5", Resamplers.Lanczos5 }, + { "MitchellNetravali", Resamplers.MitchellNetravali }, + { "Lanczos8", Resamplers.Lanczos8 }, + { "Hermite", Resamplers.Hermite }, + { "Spline", Resamplers.Spline }, + { "Robidoux", Resamplers.Robidoux }, + { "RobidouxSharp", Resamplers.RobidouxSharp }, + { "Welch", Resamplers.Welch } }; [Theory] @@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { using (Image image = provider.GetImage()) { - image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2, KnownResamplers.NearestNeighbor)); + image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2, Resamplers.NearestNeighbor)); // Comparer fights decoder with gif-s. Could not use CompareToReferenceOutput here :( image.DebugSave(provider, extension: Extensions.Gif); @@ -119,7 +119,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms var sourceRectangle = new Rectangle(image.Width / 8, image.Height / 8, image.Width / 4, image.Height / 4); var destRectangle = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); - image.Mutate(x => x.Resize(image.Width, image.Height, KnownResamplers.Bicubic, sourceRectangle, destRectangle, false)); + image.Mutate(x => x.Resize(image.Width, image.Height, Resamplers.Bicubic, sourceRectangle, destRectangle, false)); image.DebugSave(provider); image.CompareToReferenceOutput(provider); @@ -300,7 +300,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(2, 0)] public static void BicubicWindowOscillatesCorrectly(float x, float expected) { - var sampler = KnownResamplers.Bicubic; + var sampler = Resamplers.Bicubic; float result = sampler.GetValue(x); Assert.Equal(result, expected); @@ -314,7 +314,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(2, 0)] public static void TriangleWindowOscillatesCorrectly(float x, float expected) { - var sampler = KnownResamplers.Triangle; + var sampler = Resamplers.Triangle; float result = sampler.GetValue(x); Assert.Equal(result, expected); @@ -328,7 +328,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(2, 0)] public static void Lanczos3WindowOscillatesCorrectly(float x, float expected) { - var sampler = KnownResamplers.Lanczos3; + var sampler = Resamplers.Lanczos3; float result = sampler.GetValue(x); Assert.Equal(result, expected); @@ -342,7 +342,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(4, 0)] public static void Lanczos5WindowOscillatesCorrectly(float x, float expected) { - var sampler = KnownResamplers.Lanczos5; + var sampler = Resamplers.Lanczos5; float result = sampler.GetValue(x); Assert.Equal(result, expected); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs index 17bf3def26..e8c5763d5e 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs @@ -24,21 +24,21 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms public static readonly List ResamplerNames = new List { - 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), + nameof(Resamplers.Bicubic), + nameof(Resamplers.Box), + nameof(Resamplers.CatmullRom), + nameof(Resamplers.Hermite), + nameof(Resamplers.Lanczos2), + nameof(Resamplers.Lanczos3), + nameof(Resamplers.Lanczos5), + nameof(Resamplers.Lanczos8), + nameof(Resamplers.MitchellNetravali), + nameof(Resamplers.NearestNeighbor), + nameof(Resamplers.Robidoux), + nameof(Resamplers.RobidouxSharp), + nameof(Resamplers.Spline), + nameof(Resamplers.Triangle), + nameof(Resamplers.Welch), }; [Theory] @@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms private static IResampler GetResampler(string name) { - PropertyInfo property = typeof(KnownResamplers).GetTypeInfo().GetProperty(name); + PropertyInfo property = typeof(Resamplers).GetTypeInfo().GetProperty(name); if (property == null) { diff --git a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs index ace6cb70d6..e0797c4da9 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs @@ -36,30 +36,30 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms public static readonly TheoryData ResamplerNames = new TheoryData { - 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), + nameof(Resamplers.Bicubic), + nameof(Resamplers.Box), + nameof(Resamplers.CatmullRom), + nameof(Resamplers.Hermite), + nameof(Resamplers.Lanczos2), + nameof(Resamplers.Lanczos3), + nameof(Resamplers.Lanczos5), + nameof(Resamplers.Lanczos8), + nameof(Resamplers.MitchellNetravali), + nameof(Resamplers.NearestNeighbor), + nameof(Resamplers.Robidoux), + nameof(Resamplers.RobidouxSharp), + nameof(Resamplers.Spline), + nameof(Resamplers.Triangle), + nameof(Resamplers.Welch), }; public static readonly TheoryData Transform_DoesNotCreateEdgeArtifacts_ResamplerNames = new TheoryData { - nameof(KnownResamplers.NearestNeighbor), - nameof(KnownResamplers.Triangle), - nameof(KnownResamplers.Bicubic), - nameof(KnownResamplers.Lanczos8), + nameof(Resamplers.NearestNeighbor), + nameof(Resamplers.Triangle), + nameof(Resamplers.Bicubic), + nameof(Resamplers.Lanczos8), }; public AffineTransformTests(ITestOutputHelper output) @@ -111,7 +111,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms this.PrintMatrix(m); - image.Mutate(i => i.Transform(m, KnownResamplers.Bicubic)); + image.Mutate(i => i.Transform(m, Resamplers.Bicubic)); string testOutputDetails = $"R({angleDeg})_S({sx},{sy})_T({tx},{ty})"; image.DebugSave(provider, testOutputDetails); @@ -128,7 +128,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { Matrix3x2 m = this.MakeManuallyCenteredMatrix(angleDeg, s, image); - image.Mutate(i => i.Transform(m, KnownResamplers.Bicubic)); + image.Mutate(i => i.Transform(m, Resamplers.Bicubic)); string testOutputDetails = $"R({angleDeg})_S({s})"; image.DebugSave(provider, testOutputDetails); @@ -161,7 +161,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { var m = Matrix3x2.CreateScale(2.0F, 1.5F); - image.Mutate(i => i.Transform(m, KnownResamplers.Spline, rectangle)); + image.Mutate(i => i.Transform(m, Resamplers.Spline, rectangle)); image.DebugSave(provider); image.CompareToReferenceOutput(provider); @@ -179,7 +179,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { var m = Matrix3x2.CreateScale(1.0F, 2.0F); - image.Mutate(i => i.Transform(m, KnownResamplers.Spline, rectangle)); + image.Mutate(i => i.Transform(m, Resamplers.Spline, rectangle)); image.DebugSave(provider); image.CompareToReferenceOutput(provider); @@ -223,7 +223,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms private static IResampler GetResampler(string name) { - PropertyInfo property = typeof(KnownResamplers).GetTypeInfo().GetProperty(name); + PropertyInfo property = typeof(Resamplers).GetTypeInfo().GetProperty(name); if (property == null) { diff --git a/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs index a9c2922d48..cf4f83ca47 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 500; int height = 565; - IResampler sampler = KnownResamplers.NearestNeighbor; + IResampler sampler = Resamplers.NearestNeighbor; this.operations.Pad(width, height); ResizeProcessor resizeProcessor = this.Verify>(); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs index b51d342cf1..5f3815711d 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 50; int height = 100; - IResampler sampler = KnownResamplers.Lanczos3; + IResampler sampler = Resamplers.Lanczos3; this.operations.Resize(width, height, sampler); ResizeProcessor resizeProcessor = this.Verify>(); @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 50; int height = 100; - IResampler sampler = KnownResamplers.Lanczos3; + IResampler sampler = Resamplers.Lanczos3; bool compand = true; // ReSharper disable once ConditionIsAlwaysTrueOrFalse @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 50; int height = 100; - IResampler sampler = KnownResamplers.Lanczos3; + IResampler sampler = Resamplers.Lanczos3; bool compand = true; ResizeMode mode = ResizeMode.Stretch; diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs index fe5af24d26..1e58b7097a 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs @@ -12,6 +12,8 @@ using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests { + using SixLabors.ImageSharp.Processing.Effects; + public class TestUtilityExtensionsTests { public TestUtilityExtensionsTests(ITestOutputHelper output) diff --git a/tests/Images/External b/tests/Images/External index 653f0c7e3c..e9f33352b7 160000 --- a/tests/Images/External +++ b/tests/Images/External @@ -1 +1 @@ -Subproject commit 653f0c7e3c84657f68dd46e5a380186b3696b956 +Subproject commit e9f33352b77a5176508d2d5dcafbd1bd33805530