diff --git a/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs b/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs index a20ba01ad1..7ae8ec01ef 100644 --- a/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs +++ b/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// The . public static IImageProcessingContext Diffuse(this IImageProcessingContext source) where TPixel : struct, IPixel - => Diffuse(source, Diffusers.FloydSteinberg, .5F); + => Diffuse(source, DiffuseMode.FloydSteinberg, .5F); /// /// Dithers the image reducing it to a web-safe palette using error diffusion. @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// The . public static IImageProcessingContext Diffuse(this IImageProcessingContext source, float threshold) where TPixel : struct, IPixel - => Diffuse(source, Diffusers.FloydSteinberg, threshold); + => Diffuse(source, DiffuseMode.FloydSteinberg, threshold); /// /// Dithers the image reducing it to a web-safe palette using error diffusion. diff --git a/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Diffusers.cs b/src/ImageSharp/Processing/Dithering/DiffuseMode.cs similarity index 93% rename from src/ImageSharp/Processing/Dithering/ErrorDiffusion/Diffusers.cs rename to src/ImageSharp/Processing/Dithering/DiffuseMode.cs index dda163e553..cc74f1230f 100644 --- a/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Diffusers.cs +++ b/src/ImageSharp/Processing/Dithering/DiffuseMode.cs @@ -1,12 +1,14 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion +using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; + +namespace SixLabors.ImageSharp.Processing.Dithering { /// /// Contains reusable static instances of known error diffusion algorithms /// - public static class Diffusers + public static class DiffuseMode { /// /// Gets the error diffuser that implements the Atkinson algorithm. diff --git a/src/ImageSharp/Processing/Dithering/DitherExtensions.cs b/src/ImageSharp/Processing/Dithering/DitherExtensions.cs index e91c450cdd..31ef12a0ac 100644 --- a/src/ImageSharp/Processing/Dithering/DitherExtensions.cs +++ b/src/ImageSharp/Processing/Dithering/DitherExtensions.cs @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// The . public static IImageProcessingContext Dither(this IImageProcessingContext source) where TPixel : struct, IPixel - => Dither(source, Ditherers.BayerDither4x4); + => Dither(source, DitherMode.BayerDither4x4); /// /// Dithers the image reducing it to a web-safe palette using ordered dithering. diff --git a/src/ImageSharp/Processing/Dithering/Ordered/Ditherers.cs b/src/ImageSharp/Processing/Dithering/DitherMode.cs similarity index 88% rename from src/ImageSharp/Processing/Dithering/Ordered/Ditherers.cs rename to src/ImageSharp/Processing/Dithering/DitherMode.cs index 65da1dbc46..f5122608c1 100644 --- a/src/ImageSharp/Processing/Dithering/Ordered/Ditherers.cs +++ b/src/ImageSharp/Processing/Dithering/DitherMode.cs @@ -1,12 +1,14 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Dithering.Ordered +using SixLabors.ImageSharp.Processing.Dithering.Ordered; + +namespace SixLabors.ImageSharp.Processing.Dithering { /// /// Contains reusable static instances of known ordered dither matrices /// - public class Ditherers + public class DitherMode { /// /// Gets the order ditherer using the 2x2 Bayer dithering matrix diff --git a/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs b/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs index e4cd44ec2d..96763195d2 100644 --- a/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Numerics; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Dithering; using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; namespace SixLabors.ImageSharp.Processing.Quantization @@ -42,7 +43,7 @@ namespace SixLabors.ImageSharp.Processing.Quantization public bool Dither { get; set; } = true; /// - public IErrorDiffuser DitherType { get; set; } = Diffusers.FloydSteinberg; + public IErrorDiffuser DitherType { get; set; } = DiffuseMode.FloydSteinberg; /// public virtual QuantizedFrame Quantize(ImageFrame image, int maxColors) diff --git a/src/ImageSharp/Processing/Transforms/PadExtensions.cs b/src/ImageSharp/Processing/Transforms/PadExtensions.cs index 7d26cba620..23e9d5d27e 100644 --- a/src/ImageSharp/Processing/Transforms/PadExtensions.cs +++ b/src/ImageSharp/Processing/Transforms/PadExtensions.cs @@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms { Size = new Size(width, height), Mode = ResizeMode.BoxPad, - Sampler = Resamplers.NearestNeighbor + Sampler = ResampleMode.NearestNeighbor }; return source.Resize(options); diff --git a/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs index 3846379cd7..3a58ed7873 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs @@ -10,6 +10,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms.Processors diff --git a/src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs index b9a4a6a76a..adeed55efd 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs @@ -3,6 +3,7 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms.Processors diff --git a/src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs index 513e6da323..5cdcde4839 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs @@ -3,6 +3,7 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms.Processors diff --git a/src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs b/src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs index 303713d6ce..6e663f1e12 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs @@ -4,6 +4,7 @@ using System; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; namespace SixLabors.ImageSharp.Processing.Transforms.Processors { @@ -20,6 +21,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors /// The sampler to perform the transform operation. protected InterpolatedTransformProcessorBase(IResampler sampler) { + Guard.NotNull(sampler, nameof(sampler)); this.Sampler = sampler; } diff --git a/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs index a628d8a049..9f68ab6ca7 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs @@ -10,6 +10,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; // TODO: Doesn't work yet! Implement tests + Finish implementation + Document Matrix4x4 behavior diff --git a/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs index 6e60be8436..7630db6a24 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs @@ -11,6 +11,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms.Processors diff --git a/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs index 9a069f1b6b..6835fbb253 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs @@ -3,11 +3,11 @@ using System; using System.Threading.Tasks; - using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.MetaData.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms.Processors @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors /// The angle of rotation in degrees. /// The source image size public RotateProcessor(float degrees, Size sourceSize) - : this(degrees, Resamplers.Bicubic, sourceSize) + : this(degrees, ResampleMode.Bicubic, sourceSize) { } diff --git a/src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs index 5bb594f2fe..cc3d901d6c 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms.Processors @@ -20,7 +21,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms.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, Resamplers.Bicubic, sourceSize) + : this(degreesX, degreesY, ResampleMode.Bicubic, sourceSize) { } diff --git a/src/ImageSharp/Processing/Transforms/Resamplers.cs b/src/ImageSharp/Processing/Transforms/ResampleMode.cs similarity index 97% rename from src/ImageSharp/Processing/Transforms/Resamplers.cs rename to src/ImageSharp/Processing/Transforms/ResampleMode.cs index 791d493d9e..bbbdc3b265 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers.cs +++ b/src/ImageSharp/Processing/Transforms/ResampleMode.cs @@ -1,12 +1,14 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; + namespace SixLabors.ImageSharp.Processing.Transforms { /// /// Contains reusable static instances of known resampling algorithms /// - public static class Resamplers + public static class ResampleMode { /// /// Gets the Bicubic sampler that implements the bicubic kernel algorithm W(x) diff --git a/src/ImageSharp/Processing/Transforms/BicubicResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/BicubicResampler.cs similarity index 95% rename from src/ImageSharp/Processing/Transforms/BicubicResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/BicubicResampler.cs index 5a48fd4ad3..dd655a8a34 100644 --- a/src/ImageSharp/Processing/Transforms/BicubicResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/BicubicResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the bicubic kernel algorithm W(x) as described on diff --git a/src/ImageSharp/Processing/Transforms/BoxResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/BoxResampler.cs similarity index 90% rename from src/ImageSharp/Processing/Transforms/BoxResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/BoxResampler.cs index fa31ac4fb5..d6f79721c4 100644 --- a/src/ImageSharp/Processing/Transforms/BoxResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/BoxResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the box algorithm. Similar to nearest neighbor when upscaling. diff --git a/src/ImageSharp/Processing/Transforms/CatmullRomResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/CatmullRomResampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/CatmullRomResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/CatmullRomResampler.cs index 03723823bb..7284bf715d 100644 --- a/src/ImageSharp/Processing/Transforms/CatmullRomResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/CatmullRomResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The Catmull-Rom filter is a well known standard Cubic Filter often used as a interpolation function. diff --git a/src/ImageSharp/Processing/Transforms/HermiteResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/HermiteResampler.cs similarity index 91% rename from src/ImageSharp/Processing/Transforms/HermiteResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/HermiteResampler.cs index f41c03e2db..2017a1cb54 100644 --- a/src/ImageSharp/Processing/Transforms/HermiteResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/HermiteResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The Hermite filter is type of smoothed triangular interpolation Filter, diff --git a/src/ImageSharp/Processing/Transforms/IResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/IResampler.cs similarity index 91% rename from src/ImageSharp/Processing/Transforms/IResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/IResampler.cs index fd23a4644d..6bc4feaf08 100644 --- a/src/ImageSharp/Processing/Transforms/IResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/IResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// Encapsulates an interpolation algorithm for resampling images. diff --git a/src/ImageSharp/Processing/Transforms/Lanczos2Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Lanczos2Resampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs index c78926ed23..35735189a0 100644 --- a/src/ImageSharp/Processing/Transforms/Lanczos2Resampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the Lanczos kernel algorithm as described on diff --git a/src/ImageSharp/Processing/Transforms/Lanczos3Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Lanczos3Resampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs index b6d08fc530..fa85767a64 100644 --- a/src/ImageSharp/Processing/Transforms/Lanczos3Resampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the Lanczos kernel algorithm as described on diff --git a/src/ImageSharp/Processing/Transforms/Lanczos5Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Lanczos5Resampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs index b8055f6ce9..ec6b7181a0 100644 --- a/src/ImageSharp/Processing/Transforms/Lanczos5Resampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the Lanczos kernel algorithm as described on diff --git a/src/ImageSharp/Processing/Transforms/Lanczos8Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Lanczos8Resampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs index 39afe11bbf..c1f6aecf1c 100644 --- a/src/ImageSharp/Processing/Transforms/Lanczos8Resampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the Lanczos kernel algorithm as described on diff --git a/src/ImageSharp/Processing/Transforms/MitchellNetravaliResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/MitchellNetravaliResampler.cs similarity index 90% rename from src/ImageSharp/Processing/Transforms/MitchellNetravaliResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/MitchellNetravaliResampler.cs index 0b1685e110..b7817400bb 100644 --- a/src/ImageSharp/Processing/Transforms/MitchellNetravaliResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/MitchellNetravaliResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the mitchell algorithm as described on diff --git a/src/ImageSharp/Processing/Transforms/NearestNeighborResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/NearestNeighborResampler.cs similarity index 89% rename from src/ImageSharp/Processing/Transforms/NearestNeighborResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/NearestNeighborResampler.cs index c0f019a88d..61155132eb 100644 --- a/src/ImageSharp/Processing/Transforms/NearestNeighborResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/NearestNeighborResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the nearest neighbor algorithm. This uses an unscaled filter diff --git a/src/ImageSharp/Processing/Transforms/RobidouxResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/RobidouxResampler.cs similarity index 90% rename from src/ImageSharp/Processing/Transforms/RobidouxResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/RobidouxResampler.cs index 829e1ee9bd..03a6e8677e 100644 --- a/src/ImageSharp/Processing/Transforms/RobidouxResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/RobidouxResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the Robidoux algorithm. diff --git a/src/ImageSharp/Processing/Transforms/RobidouxSharpResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/RobidouxSharpResampler.cs similarity index 90% rename from src/ImageSharp/Processing/Transforms/RobidouxSharpResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/RobidouxSharpResampler.cs index 4cbf13f58c..83213c3f4e 100644 --- a/src/ImageSharp/Processing/Transforms/RobidouxSharpResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/RobidouxSharpResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the Robidoux Sharp algorithm. diff --git a/src/ImageSharp/Processing/Transforms/SplineResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/SplineResampler.cs similarity index 90% rename from src/ImageSharp/Processing/Transforms/SplineResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/SplineResampler.cs index 3448d5fb8c..45f18a4a01 100644 --- a/src/ImageSharp/Processing/Transforms/SplineResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/SplineResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the spline algorithm. diff --git a/src/ImageSharp/Processing/Transforms/TriangleResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/TriangleResampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/TriangleResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/TriangleResampler.cs index 2f5783e207..0fde54486e 100644 --- a/src/ImageSharp/Processing/Transforms/TriangleResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/TriangleResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the triangle (bilinear) algorithm. diff --git a/src/ImageSharp/Processing/Transforms/WelchResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs similarity index 91% rename from src/ImageSharp/Processing/Transforms/WelchResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs index de60f9f247..01a07fed57 100644 --- a/src/ImageSharp/Processing/Transforms/WelchResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the welch algorithm. diff --git a/src/ImageSharp/Processing/Transforms/ResizeExtensions.cs b/src/ImageSharp/Processing/Transforms/ResizeExtensions.cs index 1580aa6366..4101d3cff4 100644 --- a/src/ImageSharp/Processing/Transforms/ResizeExtensions.cs +++ b/src/ImageSharp/Processing/Transforms/ResizeExtensions.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms @@ -34,7 +35,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// 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, Resamplers.Bicubic, false); + => Resize(source, size.Width, size.Height, ResampleMode.Bicubic, false); /// /// Resizes an image to the given . @@ -47,7 +48,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// 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, Resamplers.Bicubic, compand); + => Resize(source, size.Width, size.Height, ResampleMode.Bicubic, compand); /// /// Resizes an image to the given width and height. @@ -60,7 +61,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// 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, Resamplers.Bicubic, false); + => Resize(source, width, height, ResampleMode.Bicubic, false); /// /// Resizes an image to the given width and height. @@ -74,7 +75,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// 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, Resamplers.Bicubic, compand); + => Resize(source, width, height, ResampleMode.Bicubic, compand); /// /// Resizes an image to the given width and height with the given sampler. diff --git a/src/ImageSharp/Processing/Transforms/ResizeMode.cs b/src/ImageSharp/Processing/Transforms/ResizeMode.cs index 248ac20f4e..d81691cd37 100644 --- a/src/ImageSharp/Processing/Transforms/ResizeMode.cs +++ b/src/ImageSharp/Processing/Transforms/ResizeMode.cs @@ -4,7 +4,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms { /// - /// Enumerated resize modes to apply to resized images. + /// Enumerated resize modes to apply to images. /// public enum ResizeMode { @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// /// Pads the image to fit the bound of the container without resizing the /// original source. - /// When downscaling, performs the same functionality as + /// When downscaling, performs the same functionality as /// BoxPad, diff --git a/src/ImageSharp/Processing/Transforms/ResizeOptions.cs b/src/ImageSharp/Processing/Transforms/ResizeOptions.cs index afa3142e51..8d63847485 100644 --- a/src/ImageSharp/Processing/Transforms/ResizeOptions.cs +++ b/src/ImageSharp/Processing/Transforms/ResizeOptions.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms @@ -35,7 +36,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// /// Gets or sets the sampler to perform the resize operation. /// - public IResampler Sampler { get; set; } = Resamplers.Bicubic; + public IResampler Sampler { get; set; } = ResampleMode.Bicubic; /// /// Gets or sets a value indicating whether to compress diff --git a/src/ImageSharp/Processing/Transforms/RotateExtensions.cs b/src/ImageSharp/Processing/Transforms/RotateExtensions.cs index 9001bc3ff5..e4a233ba45 100644 --- a/src/ImageSharp/Processing/Transforms/RotateExtensions.cs +++ b/src/ImageSharp/Processing/Transforms/RotateExtensions.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; namespace SixLabors.ImageSharp.Processing.Transforms { @@ -31,7 +32,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// The public static IImageProcessingContext Rotate(this IImageProcessingContext source, float degrees) where TPixel : struct, IPixel - => Rotate(source, degrees, Resamplers.Bicubic); + => Rotate(source, degrees, ResampleMode.Bicubic); /// /// Rotates an image by the given angle in degrees using the specified sampling algorithm. diff --git a/src/ImageSharp/Processing/Transforms/SkewExtensions.cs b/src/ImageSharp/Processing/Transforms/SkewExtensions.cs index c80619aa9a..686f2c87c8 100644 --- a/src/ImageSharp/Processing/Transforms/SkewExtensions.cs +++ b/src/ImageSharp/Processing/Transforms/SkewExtensions.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; namespace SixLabors.ImageSharp.Processing.Transforms { @@ -21,7 +22,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// The public static IImageProcessingContext Skew(this IImageProcessingContext source, float degreesX, float degreesY) where TPixel : struct, IPixel - => Skew(source, degreesX, degreesY, Resamplers.Bicubic); + => Skew(source, degreesX, degreesY, ResampleMode.Bicubic); /// /// Skews an image by the given angles in degrees using the specified sampling algorithm. diff --git a/src/ImageSharp/Processing/Transforms/TransformExtensions.cs b/src/ImageSharp/Processing/Transforms/TransformExtensions.cs index 7bd37afeff..865511b26d 100644 --- a/src/ImageSharp/Processing/Transforms/TransformExtensions.cs +++ b/src/ImageSharp/Processing/Transforms/TransformExtensions.cs @@ -4,6 +4,7 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms @@ -22,7 +23,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// The public static IImageProcessingContext Transform(this IImageProcessingContext source, Matrix3x2 matrix) where TPixel : struct, IPixel - => Transform(source, matrix, Resamplers.Bicubic); + => Transform(source, matrix, ResampleMode.Bicubic); /// /// Transforms an image by the given matrix using the specified sampling algorithm. @@ -87,7 +88,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// The internal static IImageProcessingContext Transform(this IImageProcessingContext source, Matrix4x4 matrix) where TPixel : struct, IPixel - => Transform(source, matrix, Resamplers.Bicubic); + => Transform(source, matrix, ResampleMode.Bicubic); /// /// Applies a projective transform to the image by the given matrix using the specified sampling algorithm. diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs index 177891b94a..07f3aa5541 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs @@ -66,7 +66,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, - Resamplers.Bicubic, + ResampleMode.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/Processing/Binarization/BinaryDitherTest.cs b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs index 58845d2b9a..a742171b19 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs @@ -9,6 +9,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization { using SixLabors.ImageSharp.Processing.Binarization; using SixLabors.ImageSharp.Processing.Binarization.Processors; + using SixLabors.ImageSharp.Processing.Dithering; using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; using SixLabors.ImageSharp.Processing.Dithering.Ordered; @@ -19,8 +20,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization public BinaryDitherTest() { - this.orderedDither = Ditherers.BayerDither4x4; - this.errorDiffuser = Diffusers.FloydSteinberg; + this.orderedDither = DitherMode.BayerDither4x4; + this.errorDiffuser = DiffuseMode.FloydSteinberg; } [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs index ea0c8eecad..69aee9bc81 100644 --- a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs +++ b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; + using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Binarization @@ -25,8 +25,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization public DitherTest() { - this.orderedDither = Ditherers.BayerDither4x4; - this.errorDiffuser = Diffusers.FloydSteinberg; + this.orderedDither = DitherMode.BayerDither4x4; + this.errorDiffuser = DiffuseMode.FloydSteinberg; } [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs index 1859ed109f..2937573395 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs @@ -12,6 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization { using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Binarization; + using SixLabors.ImageSharp.Processing.Dithering; using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; using SixLabors.ImageSharp.Processing.Dithering.Ordered; @@ -24,29 +25,29 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization public static readonly TheoryData OrderedDitherers = new TheoryData { - { "Bayer8x8", Ditherers.BayerDither8x8 }, - { "Bayer4x4", Ditherers.BayerDither4x4 }, - { "Ordered3x3", Ditherers.OrderedDither3x3 }, - { "Bayer2x2", Ditherers.BayerDither2x2 } + { "Bayer8x8", DitherMode.BayerDither8x8 }, + { "Bayer4x4", DitherMode.BayerDither4x4 }, + { "Ordered3x3", DitherMode.OrderedDither3x3 }, + { "Bayer2x2", DitherMode.BayerDither2x2 } }; public static readonly TheoryData ErrorDiffusers = new TheoryData { - { "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 }, + { "Atkinson", DiffuseMode.Atkinson }, + { "Burks", DiffuseMode.Burks }, + { "FloydSteinberg", DiffuseMode.FloydSteinberg }, + { "JarvisJudiceNinke", DiffuseMode.JarvisJudiceNinke }, + { "Sierra2", DiffuseMode.Sierra2 }, + { "Sierra3", DiffuseMode.Sierra3 }, + { "SierraLite", DiffuseMode.SierraLite }, + { "StevensonArce", DiffuseMode.StevensonArce }, + { "Stucki", DiffuseMode.Stucki }, }; - private static IOrderedDither DefaultDitherer => Ditherers.BayerDither4x4; + private static IOrderedDither DefaultDitherer => DitherMode.BayerDither4x4; - private static IErrorDiffuser DefaultErrorDiffuser => Diffusers.Atkinson; + private static IErrorDiffuser DefaultErrorDiffuser => DiffuseMode.Atkinson; [Theory] [WithFileCollection(nameof(CommonTestImages), nameof(OrderedDitherers), DefaultPixelType)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index 2e4bea7e6f..3bb3aedfcf 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -24,29 +24,29 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization public static readonly TheoryData OrderedDitherers = new TheoryData { - { "Bayer8x8", Ditherers.BayerDither8x8 }, - { "Bayer4x4", Ditherers.BayerDither4x4 }, - { "Ordered3x3", Ditherers.OrderedDither3x3 }, - { "Bayer2x2", Ditherers.BayerDither2x2 } + { "Bayer8x8", DitherMode.BayerDither8x8 }, + { "Bayer4x4", DitherMode.BayerDither4x4 }, + { "Ordered3x3", DitherMode.OrderedDither3x3 }, + { "Bayer2x2", DitherMode.BayerDither2x2 } }; public static readonly TheoryData ErrorDiffusers = new TheoryData { - { "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 }, + { "Atkinson", DiffuseMode.Atkinson }, + { "Burks", DiffuseMode.Burks }, + { "FloydSteinberg", DiffuseMode.FloydSteinberg }, + { "JarvisJudiceNinke", DiffuseMode.JarvisJudiceNinke }, + { "Sierra2", DiffuseMode.Sierra2 }, + { "Sierra3", DiffuseMode.Sierra3 }, + { "SierraLite", DiffuseMode.SierraLite }, + { "StevensonArce", DiffuseMode.StevensonArce }, + { "Stucki", DiffuseMode.Stucki }, }; - private static IOrderedDither DefaultDitherer => Ditherers.BayerDither4x4; + private static IOrderedDither DefaultDitherer => DitherMode.BayerDither4x4; - private static IErrorDiffuser DefaultErrorDiffuser => Diffusers.Atkinson; + private static IErrorDiffuser DefaultErrorDiffuser => DiffuseMode.Atkinson; [Theory] [WithFileCollection(nameof(CommonTestImages), nameof(OrderedDitherers), DefaultPixelType)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs index 84030adf16..ab0efbd708 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs @@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms public void PrintWeightsData() { var size = new Size(500, 500); - var proc = new ResizeProcessor(Resamplers.Bicubic, 200, 200, size); + var proc = new ResizeProcessor(ResampleMode.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 38201d4d6f..82abb90288 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -2,11 +2,10 @@ // Licensed under the Apache License, Version 2.0. using System; - using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; - +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; using Xunit; @@ -22,20 +21,20 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms public static readonly TheoryData AllReSamplers = new TheoryData { - { "Bicubic", Resamplers.Bicubic }, - { "Triangle", Resamplers.Triangle}, - { "NearestNeighbor", Resamplers.NearestNeighbor }, - { "Box", Resamplers.Box }, + { "Bicubic", ResampleMode.Bicubic }, + { "Triangle", ResampleMode.Triangle}, + { "NearestNeighbor", ResampleMode.NearestNeighbor }, + { "Box", ResampleMode.Box }, // { "Lanczos2", KnownResamplers.Lanczos2 }, TODO: Add expected file - { "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 } + { "Lanczos3", ResampleMode.Lanczos3 }, + { "Lanczos5", ResampleMode.Lanczos5 }, + { "MitchellNetravali", ResampleMode.MitchellNetravali }, + { "Lanczos8", ResampleMode.Lanczos8 }, + { "Hermite", ResampleMode.Hermite }, + { "Spline", ResampleMode.Spline }, + { "Robidoux", ResampleMode.Robidoux }, + { "RobidouxSharp", ResampleMode.RobidouxSharp }, + { "Welch", ResampleMode.Welch } }; [Theory] @@ -104,7 +103,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { using (Image image = provider.GetImage()) { - image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2, Resamplers.NearestNeighbor)); + image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2, ResampleMode.NearestNeighbor)); // Comparer fights decoder with gif-s. Could not use CompareToReferenceOutput here :( image.DebugSave(provider, extension: Extensions.Gif); @@ -121,7 +120,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, Resamplers.Bicubic, sourceRectangle, destRectangle, false)); + image.Mutate(x => x.Resize(image.Width, image.Height, ResampleMode.Bicubic, sourceRectangle, destRectangle, false)); image.DebugSave(provider); image.CompareToReferenceOutput(provider); @@ -302,7 +301,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(2, 0)] public static void BicubicWindowOscillatesCorrectly(float x, float expected) { - var sampler = Resamplers.Bicubic; + var sampler = ResampleMode.Bicubic; float result = sampler.GetValue(x); Assert.Equal(result, expected); @@ -316,7 +315,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(2, 0)] public static void TriangleWindowOscillatesCorrectly(float x, float expected) { - var sampler = Resamplers.Triangle; + var sampler = ResampleMode.Triangle; float result = sampler.GetValue(x); Assert.Equal(result, expected); @@ -330,7 +329,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(2, 0)] public static void Lanczos3WindowOscillatesCorrectly(float x, float expected) { - var sampler = Resamplers.Lanczos3; + var sampler = ResampleMode.Lanczos3; float result = sampler.GetValue(x); Assert.Equal(result, expected); @@ -344,7 +343,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(4, 0)] public static void Lanczos5WindowOscillatesCorrectly(float x, float expected) { - var sampler = Resamplers.Lanczos5; + var sampler = ResampleMode.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 c092881c62..174aadf602 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs @@ -12,6 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Transforms; + using SixLabors.ImageSharp.Processing.Transforms.Resamplers; public class SkewTest : FileTestBase { @@ -25,21 +26,21 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms public static readonly List ResamplerNames = new List { - 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), + nameof(ResampleMode.Bicubic), + nameof(ResampleMode.Box), + nameof(ResampleMode.CatmullRom), + nameof(ResampleMode.Hermite), + nameof(ResampleMode.Lanczos2), + nameof(ResampleMode.Lanczos3), + nameof(ResampleMode.Lanczos5), + nameof(ResampleMode.Lanczos8), + nameof(ResampleMode.MitchellNetravali), + nameof(ResampleMode.NearestNeighbor), + nameof(ResampleMode.Robidoux), + nameof(ResampleMode.RobidouxSharp), + nameof(ResampleMode.Spline), + nameof(ResampleMode.Triangle), + nameof(ResampleMode.Welch), }; [Theory] @@ -72,7 +73,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms private static IResampler GetResampler(string name) { - PropertyInfo property = typeof(Resamplers).GetTypeInfo().GetProperty(name); + PropertyInfo property = typeof(ResampleMode).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 85c35ba275..6637b97405 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs @@ -3,6 +3,7 @@ using System.Numerics; using System.Reflection; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; using Xunit; using Xunit.Abstractions; @@ -38,30 +39,30 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms public static readonly TheoryData ResamplerNames = new TheoryData { - 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), + nameof(ResampleMode.Bicubic), + nameof(ResampleMode.Box), + nameof(ResampleMode.CatmullRom), + nameof(ResampleMode.Hermite), + nameof(ResampleMode.Lanczos2), + nameof(ResampleMode.Lanczos3), + nameof(ResampleMode.Lanczos5), + nameof(ResampleMode.Lanczos8), + nameof(ResampleMode.MitchellNetravali), + nameof(ResampleMode.NearestNeighbor), + nameof(ResampleMode.Robidoux), + nameof(ResampleMode.RobidouxSharp), + nameof(ResampleMode.Spline), + nameof(ResampleMode.Triangle), + nameof(ResampleMode.Welch), }; public static readonly TheoryData Transform_DoesNotCreateEdgeArtifacts_ResamplerNames = new TheoryData { - nameof(Resamplers.NearestNeighbor), - nameof(Resamplers.Triangle), - nameof(Resamplers.Bicubic), - nameof(Resamplers.Lanczos8), + nameof(ResampleMode.NearestNeighbor), + nameof(ResampleMode.Triangle), + nameof(ResampleMode.Bicubic), + nameof(ResampleMode.Lanczos8), }; public AffineTransformTests(ITestOutputHelper output) @@ -113,7 +114,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms this.PrintMatrix(m); - image.Mutate(i => i.Transform(m, Resamplers.Bicubic)); + image.Mutate(i => i.Transform(m, ResampleMode.Bicubic)); string testOutputDetails = $"R({angleDeg})_S({sx},{sy})_T({tx},{ty})"; image.DebugSave(provider, testOutputDetails); @@ -130,7 +131,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { Matrix3x2 m = this.MakeManuallyCenteredMatrix(angleDeg, s, image); - image.Mutate(i => i.Transform(m, Resamplers.Bicubic)); + image.Mutate(i => i.Transform(m, ResampleMode.Bicubic)); string testOutputDetails = $"R({angleDeg})_S({s})"; image.DebugSave(provider, testOutputDetails); @@ -163,7 +164,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { var m = Matrix3x2.CreateScale(2.0F, 1.5F); - image.Mutate(i => i.Transform(m, Resamplers.Spline, rectangle)); + image.Mutate(i => i.Transform(m, ResampleMode.Spline, rectangle)); image.DebugSave(provider); image.CompareToReferenceOutput(provider); @@ -181,7 +182,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { var m = Matrix3x2.CreateScale(1.0F, 2.0F); - image.Mutate(i => i.Transform(m, Resamplers.Spline, rectangle)); + image.Mutate(i => i.Transform(m, ResampleMode.Spline, rectangle)); image.DebugSave(provider); image.CompareToReferenceOutput(provider); @@ -225,7 +226,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms private static IResampler GetResampler(string name) { - PropertyInfo property = typeof(Resamplers).GetTypeInfo().GetProperty(name); + PropertyInfo property = typeof(ResampleMode).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 bb227496d8..46fc027126 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs @@ -1,9 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; - +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Transforms @@ -18,7 +16,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 500; int height = 565; - IResampler sampler = Resamplers.NearestNeighbor; + IResampler sampler = ResampleMode.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 b2170069f2..f9e09657cd 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.Processing.Transforms; using SixLabors.ImageSharp.Processing.Transforms.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; using Xunit; @@ -27,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 50; int height = 100; - IResampler sampler = Resamplers.Lanczos3; + IResampler sampler = ResampleMode.Lanczos3; this.operations.Resize(width, height, sampler); ResizeProcessor resizeProcessor = this.Verify>(); @@ -41,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 50; int height = 100; - IResampler sampler = Resamplers.Lanczos3; + IResampler sampler = ResampleMode.Lanczos3; bool compand = true; // ReSharper disable once ConditionIsAlwaysTrueOrFalse @@ -59,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 50; int height = 100; - IResampler sampler = Resamplers.Lanczos3; + IResampler sampler = ResampleMode.Lanczos3; bool compand = true; ResizeMode mode = ResizeMode.Stretch;