From 091cb8a3b5d12e608c69c4ab46e5b8407aead1ca Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 9 Mar 2018 10:56:36 +1100 Subject: [PATCH] Overlays and base processors --- .../PixelFormats/PixelBlenderMode.cs | 6 +- src/ImageSharp/Processing/Delegate.cs | 28 ------ .../Filters/Processors/LomographProcessor.cs | 2 +- .../Filters/Processors/PolaroidProcessor.cs | 2 +- ...dColor.cs => BackgroundColorExtensions.cs} | 33 +++---- .../Overlays/{Glow.cs => GlowExtensions.cs} | 35 ++++---- .../Processors}/BackgroundColorProcessor.cs | 15 ++-- .../Processors}/GlowProcessor.cs | 2 +- .../Processors}/VignetteProcessor.cs | 2 +- .../{Vignette.cs => VignetteExtensions.cs} | 37 +++----- .../ProcessingExtensions.cs} | 29 ++++-- .../Processors/CloningImageProcessor.cs | 4 +- .../Processors/DelegateProcessor.cs | 4 +- .../Quantization}/Box.cs | 0 .../Quantization}/IQuantizer{TPixel}.cs | 0 .../Quantization}/OctreeQuantizer{TPixel}.cs | 0 .../Quantization}/PaletteQuantizer{TPixel}.cs | 0 .../Quantization}/Quantization.cs | 0 .../Quantization}/Quantize.cs | 1 + .../Quantization}/QuantizedImage{TPixel}.cs | 0 .../Quantization}/QuantizerBase{TPixel}.cs | 0 .../Quantization}/WuQuantizer{TPixel}.cs | 0 .../Processors}/AffineTransformProcessor.cs | 0 .../Processors}/AutoOrientProcessor.cs | 0 .../CenteredAffineTransformProcessor.cs | 0 .../CenteredProjectiveTransformProcessor.cs | 0 .../Processors}/CropProcessor.cs | 0 .../Processors}/EntropyCropProcessor.cs | 0 .../Processors}/FlipProcessor.cs | 0 .../InterpolatedTransformProcessorBase.cs | 0 .../ProjectiveTransformProcessor.cs | 0 .../Processors}/ResizeProcessor.cs | 0 .../Processors}/RotateProcessor.cs | 0 .../Processors}/SkewProcessor.cs | 0 .../Processors}/TransformProcessorBase.cs | 0 .../Processors}/WeightsBuffer.cs | 0 .../Processors}/WeightsWindow.cs | 0 .../Drawing/DrawBeziers.cs | 2 +- .../Drawing/DrawLines.cs | 1 + .../Drawing/DrawPolygon.cs | 1 + .../Drawing/FillPolygon.cs | 1 + .../Drawing/FillRectangle.cs | 11 +-- .../Drawing/FillWithPattern.cs | 1 + tests/ImageSharp.Benchmarks/Samplers/Crop.cs | 1 + tests/ImageSharp.Benchmarks/Samplers/Glow.cs | 5 +- .../ImageSharp.Benchmarks/Samplers/Resize.cs | 1 + .../ImageSharp.Tests/Drawing/BeziersTests.cs | 3 + .../ImageSharp.Tests/Drawing/BlendedShapes.cs | 2 + .../ImageSharp.Tests/Drawing/DrawPathTests.cs | 3 + .../Drawing/FillPatternTests.cs | 9 +- .../Drawing/FillRegionProcessorTests.cs | 2 + .../Drawing/FillSolidBrushTests.cs | 3 + .../Drawing/LineComplexPolygonTests.cs | 3 + tests/ImageSharp.Tests/Drawing/LineTests.cs | 3 + .../ImageSharp.Tests/Drawing/PolygonTests.cs | 3 + .../Drawing/RecolorImageTest.cs | 2 + .../Drawing/SolidBezierTests.cs | 3 + .../Drawing/SolidComplexPolygonTests.cs | 3 + .../Drawing/SolidPolygonTests.cs | 3 + .../Formats/Bmp/BmpEncoderTests.cs | 1 + .../Formats/GeneralFormatTests.cs | 2 + .../Formats/Jpg/JpegEncoderTests.cs | 1 + .../Formats/Png/PngEncoderTests.cs | 1 + .../Formats/Png/PngSmokeTests.cs | 2 + .../Image/ImageProcessingContextTests.cs | 3 + .../Image/ImageRotationTests.cs | 2 + tests/ImageSharp.Tests/Issues/Issue412.cs | 2 + .../Memory/Fast2DArrayTests.cs | 89 ------------------- .../DataWriter/IccDataWriter.MatrixTests.cs | 6 +- .../Binarization/OrderedDitherFactoryTests.cs | 34 +++---- .../Processing/DelegateTest.cs | 2 + .../Processing/Effects/BackgroundColorTest.cs | 3 + .../Processing/Overlays/GlowTest.cs | 8 +- .../Processing/Overlays/VignetteTest.cs | 10 +-- .../Binarization/BinaryDitherTests.cs | 1 + .../Binarization/BinaryThresholdTest.cs | 1 + .../Processors/Convolution/BoxBlurTest.cs | 1 + .../Convolution/GaussianBlurTest.cs | 1 + .../Convolution/GaussianSharpenTest.cs | 1 + .../Processors/Dithering/DitherTests.cs | 1 + .../Processors/Effects/BackgroundColorTest.cs | 3 + .../Processors/Effects/OilPaintTest.cs | 1 + .../Processors/Effects/PixelateTest.cs | 1 + .../Processors/Overlays/GlowTest.cs | 3 + .../Processors/Overlays/VignetteTest.cs | 3 + .../Processors/Transforms/CropTest.cs | 2 + .../Processors/Transforms/EntropyCropTest.cs | 2 + .../Processors/Transforms/PadTest.cs | 2 + .../TestDataIcc/IccTestDataMatrix.cs | 14 +-- .../ImageProviders/SolidProvider.cs | 2 + .../ImageProviders/TestImageProvider.cs | 2 + .../TestUtilities/TestImageExtensions.cs | 1 + .../TestUtilities/TestUtils.cs | 1 + .../TestUtilities/Tests/ImageComparerTests.cs | 1 + .../Tests/ReferenceCodecTests.cs | 1 + 95 files changed, 220 insertions(+), 257 deletions(-) delete mode 100644 src/ImageSharp/Processing/Delegate.cs rename src/ImageSharp/Processing/Overlays/{BackgroundColor.cs => BackgroundColorExtensions.cs} (82%) rename src/ImageSharp/Processing/Overlays/{Glow.cs => GlowExtensions.cs} (87%) rename src/ImageSharp/Processing/{Processors/Overlays => Overlays/Processors}/BackgroundColorProcessor.cs (82%) rename src/ImageSharp/Processing/{Processors/Overlays => Overlays/Processors}/GlowProcessor.cs (98%) rename src/ImageSharp/Processing/{Processors/Overlays => Overlays/Processors}/VignetteProcessor.cs (99%) rename src/ImageSharp/Processing/Overlays/{Vignette.cs => VignetteExtensions.cs} (85%) rename src/ImageSharp/{ApplyProcessors.cs => Processing/ProcessingExtensions.cs} (73%) rename src/ImageSharp/{Quantizers => Processing/Quantization}/Box.cs (100%) rename src/ImageSharp/{Quantizers => Processing/Quantization}/IQuantizer{TPixel}.cs (100%) rename src/ImageSharp/{Quantizers => Processing/Quantization}/OctreeQuantizer{TPixel}.cs (100%) rename src/ImageSharp/{Quantizers => Processing/Quantization}/PaletteQuantizer{TPixel}.cs (100%) rename src/ImageSharp/{Quantizers => Processing/Quantization}/Quantization.cs (100%) rename src/ImageSharp/{Quantizers => Processing/Quantization}/Quantize.cs (98%) rename src/ImageSharp/{Quantizers => Processing/Quantization}/QuantizedImage{TPixel}.cs (100%) rename src/ImageSharp/{Quantizers => Processing/Quantization}/QuantizerBase{TPixel}.cs (100%) rename src/ImageSharp/{Quantizers => Processing/Quantization}/WuQuantizer{TPixel}.cs (100%) rename src/ImageSharp/Processing/{Processors/Transforms => Transforms/Processors}/AffineTransformProcessor.cs (100%) rename src/ImageSharp/Processing/{Processors/Transforms => Transforms/Processors}/AutoOrientProcessor.cs (100%) rename src/ImageSharp/Processing/{Processors/Transforms => Transforms/Processors}/CenteredAffineTransformProcessor.cs (100%) rename src/ImageSharp/Processing/{Processors/Transforms => Transforms/Processors}/CenteredProjectiveTransformProcessor.cs (100%) rename src/ImageSharp/Processing/{Processors/Transforms => Transforms/Processors}/CropProcessor.cs (100%) rename src/ImageSharp/Processing/{Processors/Transforms => Transforms/Processors}/EntropyCropProcessor.cs (100%) rename src/ImageSharp/Processing/{Processors/Transforms => Transforms/Processors}/FlipProcessor.cs (100%) rename src/ImageSharp/Processing/{Processors/Transforms => Transforms/Processors}/InterpolatedTransformProcessorBase.cs (100%) rename src/ImageSharp/Processing/{Processors/Transforms => Transforms/Processors}/ProjectiveTransformProcessor.cs (100%) rename src/ImageSharp/Processing/{Processors/Transforms => Transforms/Processors}/ResizeProcessor.cs (100%) rename src/ImageSharp/Processing/{Processors/Transforms => Transforms/Processors}/RotateProcessor.cs (100%) rename src/ImageSharp/Processing/{Processors/Transforms => Transforms/Processors}/SkewProcessor.cs (100%) rename src/ImageSharp/Processing/{Processors/Transforms => Transforms/Processors}/TransformProcessorBase.cs (100%) rename src/ImageSharp/Processing/{Processors/Transforms => Transforms/Processors}/WeightsBuffer.cs (100%) rename src/ImageSharp/Processing/{Processors/Transforms => Transforms/Processors}/WeightsWindow.cs (100%) delete mode 100644 tests/ImageSharp.Tests/Memory/Fast2DArrayTests.cs diff --git a/src/ImageSharp/PixelFormats/PixelBlenderMode.cs b/src/ImageSharp/PixelFormats/PixelBlenderMode.cs index ae70cdee4..7541be789 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenderMode.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenderMode.cs @@ -1,14 +1,10 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Collections.Generic; -using System.Text; - namespace SixLabors.ImageSharp.PixelFormats { /// - /// The various blending modes. + /// Enumerates the various blending modes. /// public enum PixelBlenderMode { diff --git a/src/ImageSharp/Processing/Delegate.cs b/src/ImageSharp/Processing/Delegate.cs deleted file mode 100644 index b390e46ae..000000000 --- a/src/ImageSharp/Processing/Delegate.cs +++ /dev/null @@ -1,28 +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; - -namespace SixLabors.ImageSharp -{ - /// - /// Extension methods for the type. - /// - public static partial class ImageExtensions - { - /// - /// Applies the given operation to the mutable image. - /// Useful when we need to extract information like Width/Height to parameterize the next operation working on the chain. - /// To achieve this the method actually implements an "inline" with as it's processing logic. - /// - /// The pixel format. - /// The image to mutate. - /// The operation to perform on the source. - /// The to allow chaining of operations. - public static IImageProcessingContext Apply(this IImageProcessingContext source, Action> operation) - where TPixel : struct, IPixel - => source.ApplyProcessor(new DelegateProcessor(operation)); - } -} diff --git a/src/ImageSharp/Processing/Filters/Processors/LomographProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/LomographProcessor.cs index 5ee6b4bc1..5e3d73fd1 100644 --- a/src/ImageSharp/Processing/Filters/Processors/LomographProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/LomographProcessor.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors.Overlays; +using SixLabors.ImageSharp.Processing.Overlays.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Filters.Processors diff --git a/src/ImageSharp/Processing/Filters/Processors/PolaroidProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/PolaroidProcessor.cs index 0a84eab8b..0e90efc7e 100644 --- a/src/ImageSharp/Processing/Filters/Processors/PolaroidProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/PolaroidProcessor.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors.Overlays; +using SixLabors.ImageSharp.Processing.Overlays.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Filters.Processors diff --git a/src/ImageSharp/Processing/Overlays/BackgroundColor.cs b/src/ImageSharp/Processing/Overlays/BackgroundColorExtensions.cs similarity index 82% rename from src/ImageSharp/Processing/Overlays/BackgroundColor.cs rename to src/ImageSharp/Processing/Overlays/BackgroundColorExtensions.cs index 22aad9ca6..72cba78e5 100644 --- a/src/ImageSharp/Processing/Overlays/BackgroundColor.cs +++ b/src/ImageSharp/Processing/Overlays/BackgroundColorExtensions.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.Overlays.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of a background color to the type. /// - public static partial class ImageExtensions + public static class BackgroundColorExtensions { /// /// Replaces the background color of image with the given one. @@ -19,11 +18,10 @@ namespace SixLabors.ImageSharp /// The pixel format. /// The image this method extends. /// The color to set as the background. - /// The options effecting pixel blending. /// The . - public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color, GraphicsOptions options) + public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color) where TPixel : struct, IPixel - => source.ApplyProcessor(new BackgroundColorProcessor(source.MemoryManager, color, options)); + => BackgroundColor(source, color, GraphicsOptions.Default); /// /// Replaces the background color of image with the given one. @@ -34,11 +32,10 @@ namespace SixLabors.ImageSharp /// /// The structure that specifies the portion of the image object to alter. /// - /// The options effecting pixel blending. /// The . - public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color, Rectangle rectangle, GraphicsOptions options) + public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color, Rectangle rectangle) where TPixel : struct, IPixel - => source.ApplyProcessor(new BackgroundColorProcessor(source.MemoryManager, color, options), rectangle); + => BackgroundColor(source, color, rectangle, GraphicsOptions.Default); /// /// Replaces the background color of image with the given one. @@ -46,12 +43,11 @@ namespace SixLabors.ImageSharp /// The pixel format. /// The image this method extends. /// The color to set as the background. + /// The options effecting pixel blending. /// The . - public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color) + public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color, GraphicsOptions options) where TPixel : struct, IPixel - { - return BackgroundColor(source, color, GraphicsOptions.Default); - } + => source.ApplyProcessor(new BackgroundColorProcessor(color, options)); /// /// Replaces the background color of image with the given one. @@ -62,11 +58,10 @@ namespace SixLabors.ImageSharp /// /// The structure that specifies the portion of the image object to alter. /// + /// The options effecting pixel blending. /// The . - public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color, Rectangle rectangle) + public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color, Rectangle rectangle, GraphicsOptions options) where TPixel : struct, IPixel - { - return BackgroundColor(source, color, rectangle, GraphicsOptions.Default); - } + => source.ApplyProcessor(new BackgroundColorProcessor(color, options), rectangle); } } diff --git a/src/ImageSharp/Processing/Overlays/Glow.cs b/src/ImageSharp/Processing/Overlays/GlowExtensions.cs similarity index 87% rename from src/ImageSharp/Processing/Overlays/Glow.cs rename to src/ImageSharp/Processing/Overlays/GlowExtensions.cs index 80eb4287a..a86128f88 100644 --- a/src/ImageSharp/Processing/Overlays/Glow.cs +++ b/src/ImageSharp/Processing/Overlays/GlowExtensions.cs @@ -3,16 +3,15 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; -using SixLabors.ImageSharp.Processing.Processors; -using SixLabors.ImageSharp.Processing.Processors.Overlays; +using SixLabors.ImageSharp.Processing.Overlays.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of a radial glow to the type. /// - public static partial class ImageExtensions + public static class GlowExtensions { /// /// Applies a radial glow effect to an image. @@ -22,9 +21,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Glow(this IImageProcessingContext source) where TPixel : struct, IPixel - { - return Glow(source, GraphicsOptions.Default); - } + => Glow(source, GraphicsOptions.Default); /// /// Applies a radial glow effect to an image. @@ -48,9 +45,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Glow(this IImageProcessingContext source, float radius) where TPixel : struct, IPixel - { - return Glow(source, radius, GraphicsOptions.Default); - } + => Glow(source, radius, GraphicsOptions.Default); /// /// Applies a radial glow effect to an image. @@ -63,7 +58,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Glow(this IImageProcessingContext source, Rectangle rectangle) where TPixel : struct, IPixel - => source.Glow(rectangle, GraphicsOptions.Default); + => source.Glow(rectangle, GraphicsOptions.Default); /// /// Applies a radial glow effect to an image. @@ -78,7 +73,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Glow(this IImageProcessingContext source, TPixel color, float radius, Rectangle rectangle) where TPixel : struct, IPixel - => source.Glow(color, ValueSize.Absolute(radius), rectangle, GraphicsOptions.Default); + => source.Glow(color, ValueSize.Absolute(radius), rectangle, GraphicsOptions.Default); /// /// Applies a radial glow effect to an image. @@ -89,7 +84,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Glow(this IImageProcessingContext source, GraphicsOptions options) where TPixel : struct, IPixel - => source.Glow(NamedColors.Black, ValueSize.PercentageOfWidth(0.5f), options); + => source.Glow(NamedColors.Black, ValueSize.PercentageOfWidth(0.5f), options); /// /// Applies a radial glow effect to an image. @@ -101,7 +96,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Glow(this IImageProcessingContext source, TPixel color, GraphicsOptions options) where TPixel : struct, IPixel - => source.Glow(color, ValueSize.PercentageOfWidth(0.5f), options); + => source.Glow(color, ValueSize.PercentageOfWidth(0.5f), options); /// /// Applies a radial glow effect to an image. @@ -113,7 +108,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Glow(this IImageProcessingContext source, float radius, GraphicsOptions options) where TPixel : struct, IPixel - => source.Glow(NamedColors.Black, ValueSize.Absolute(radius), options); + => source.Glow(NamedColors.Black, ValueSize.Absolute(radius), options); /// /// Applies a radial glow effect to an image. @@ -127,7 +122,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Glow(this IImageProcessingContext source, Rectangle rectangle, GraphicsOptions options) where TPixel : struct, IPixel - => source.Glow(NamedColors.Black, ValueSize.PercentageOfWidth(0.5f), rectangle, options); + => source.Glow(NamedColors.Black, ValueSize.PercentageOfWidth(0.5f), rectangle, options); /// /// Applies a radial glow effect to an image. @@ -143,7 +138,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Glow(this IImageProcessingContext source, TPixel color, float radius, Rectangle rectangle, GraphicsOptions options) where TPixel : struct, IPixel - => source.Glow(color, ValueSize.Absolute(radius), rectangle, options); + => source.Glow(color, ValueSize.Absolute(radius), rectangle, options); /// /// Applies a radial glow effect to an image. @@ -159,7 +154,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(color, radius, options), rectangle); + => source.ApplyProcessor(new GlowProcessor(color, radius, options), rectangle); /// /// Applies a radial glow effect to an image. @@ -172,6 +167,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(color, radius, options)); + => source.ApplyProcessor(new GlowProcessor(color, radius, options)); } } diff --git a/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs similarity index 82% rename from src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs rename to src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs index d07dcbeed..c91cc93c2 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs @@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Overlays.Processors { /// /// Sets the background color of the image. @@ -17,18 +17,14 @@ namespace SixLabors.ImageSharp.Processing.Processors internal class BackgroundColorProcessor : ImageProcessor where TPixel : struct, IPixel { - private readonly MemoryManager memoryManager; - /// /// Initializes a new instance of the class. /// - /// The to use for buffer allocations. /// The to set the background color to. /// The options defining blending algorithm and amount. - public BackgroundColorProcessor(MemoryManager memoryManager, TPixel color, GraphicsOptions options) + public BackgroundColorProcessor(TPixel color, GraphicsOptions options) { this.Value = color; - this.memoryManager = memoryManager; this.GraphicsOptions = options; } @@ -69,13 +65,14 @@ namespace SixLabors.ImageSharp.Processing.Processors int width = maxX - minX; - using (IBuffer colors = this.memoryManager.Allocate(width)) - using (IBuffer amount = this.memoryManager.Allocate(width)) + using (IBuffer colors = source.MemoryManager.Allocate(width)) + using (IBuffer amount = source.MemoryManager.Allocate(width)) { // Be careful! Do not capture colorSpan & amountSpan in the lambda below! Span colorSpan = colors.Span; Span amountSpan = amount.Span; + // TODO: Use Span.Fill? for (int i = 0; i < width; i++) { colorSpan[i] = this.Value; @@ -92,7 +89,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 color under the current one - blender.Blend(this.memoryManager, destination, colors.Span, destination, amount.Span); + blender.Blend(source.MemoryManager, destination, colors.Span, destination, amount.Span); }); } } diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs similarity index 98% rename from src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs rename to src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs index abd0c15bb..7477c1390 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs @@ -11,7 +11,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors.Overlays +namespace SixLabors.ImageSharp.Processing.Overlays.Processors { /// /// An that applies a radial glow effect an . diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs similarity index 99% rename from src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs rename to src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs index ad73b6553..bca63b314 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs @@ -11,7 +11,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors.Overlays +namespace SixLabors.ImageSharp.Processing.Overlays.Processors { /// /// An that applies a radial vignette effect to an . diff --git a/src/ImageSharp/Processing/Overlays/Vignette.cs b/src/ImageSharp/Processing/Overlays/VignetteExtensions.cs similarity index 85% rename from src/ImageSharp/Processing/Overlays/Vignette.cs rename to src/ImageSharp/Processing/Overlays/VignetteExtensions.cs index 4df53f14e..e533c914f 100644 --- a/src/ImageSharp/Processing/Overlays/Vignette.cs +++ b/src/ImageSharp/Processing/Overlays/VignetteExtensions.cs @@ -3,16 +3,15 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; -using SixLabors.ImageSharp.Processing.Processors; -using SixLabors.ImageSharp.Processing.Processors.Overlays; +using SixLabors.ImageSharp.Processing.Overlays.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of a radial glow to the type. /// - public static partial class ImageExtensions + public static class VignetteExtensions { /// /// Applies a radial vignette effect to an image. @@ -22,9 +21,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Vignette(this IImageProcessingContext source) where TPixel : struct, IPixel - { - return Vignette(source, GraphicsOptions.Default); - } + => Vignette(source, GraphicsOptions.Default); /// /// Applies a radial vignette effect to an image. @@ -35,9 +32,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Vignette(this IImageProcessingContext source, TPixel color) where TPixel : struct, IPixel - { - return Vignette(source, color, GraphicsOptions.Default); - } + => Vignette(source, color, GraphicsOptions.Default); /// /// Applies a radial vignette effect to an image. @@ -49,9 +44,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Vignette(this IImageProcessingContext source, float radiusX, float radiusY) where TPixel : struct, IPixel - { - return Vignette(source, radiusX, radiusY, GraphicsOptions.Default); - } + => Vignette(source, radiusX, radiusY, GraphicsOptions.Default); /// /// Applies a radial vignette effect to an image. @@ -64,9 +57,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Vignette(this IImageProcessingContext source, Rectangle rectangle) where TPixel : struct, IPixel - { - return Vignette(source, rectangle, GraphicsOptions.Default); - } + => Vignette(source, rectangle, GraphicsOptions.Default); /// /// Applies a radial vignette effect to an image. @@ -82,7 +73,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Vignette(this IImageProcessingContext source, TPixel color, float radiusX, float radiusY, Rectangle rectangle) where TPixel : struct, IPixel - => source.Vignette(color, radiusX, radiusY, rectangle, GraphicsOptions.Default); + => source.Vignette(color, radiusX, radiusY, rectangle, GraphicsOptions.Default); /// /// Applies a radial vignette effect to an image. @@ -93,7 +84,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Vignette(this IImageProcessingContext source, GraphicsOptions options) where TPixel : struct, IPixel - => source.VignetteInternal(NamedColors.Black, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), options); + => source.VignetteInternal(NamedColors.Black, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), options); /// /// Applies a radial vignette effect to an image. @@ -105,7 +96,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Vignette(this IImageProcessingContext source, TPixel color, GraphicsOptions options) where TPixel : struct, IPixel - => source.VignetteInternal(color, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), options); + => source.VignetteInternal(color, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), options); /// /// Applies a radial vignette effect to an image. @@ -118,7 +109,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Vignette(this IImageProcessingContext source, float radiusX, float radiusY, GraphicsOptions options) where TPixel : struct, IPixel - => source.VignetteInternal(NamedColors.Black, radiusX, radiusY, options); + => source.VignetteInternal(NamedColors.Black, radiusX, radiusY, options); /// /// Applies a radial vignette effect to an image. @@ -132,7 +123,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Vignette(this IImageProcessingContext source, Rectangle rectangle, GraphicsOptions options) where TPixel : struct, IPixel - => source.VignetteInternal(NamedColors.Black, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), rectangle, options); + => source.VignetteInternal(NamedColors.Black, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), rectangle, options); /// /// Applies a radial vignette effect to an image. @@ -149,7 +140,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Vignette(this IImageProcessingContext source, TPixel color, float radiusX, float radiusY, Rectangle rectangle, GraphicsOptions options) where TPixel : struct, IPixel - => source.VignetteInternal(color, radiusX, radiusY, rectangle, options); + => source.VignetteInternal(color, radiusX, radiusY, rectangle, options); private static IImageProcessingContext VignetteInternal(this IImageProcessingContext source, TPixel color, ValueSize radiusX, ValueSize radiusY, Rectangle rectangle, GraphicsOptions options) where TPixel : struct, IPixel diff --git a/src/ImageSharp/ApplyProcessors.cs b/src/ImageSharp/Processing/ProcessingExtensions.cs similarity index 73% rename from src/ImageSharp/ApplyProcessors.cs rename to src/ImageSharp/Processing/ProcessingExtensions.cs index c4954ef0d..97faab88f 100644 --- a/src/ImageSharp/ApplyProcessors.cs +++ b/src/ImageSharp/Processing/ProcessingExtensions.cs @@ -4,14 +4,27 @@ using System; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing { /// - /// Extension methods for the type. + /// Adds extensions that allow the processing of images to the type. /// - public static partial class ImageExtensions + public static class ProcessingExtensions { + /// + /// Applies the given operation to the mutable image. + /// Useful when we need to extract information like Width/Height to parametrize the next operation working on the chain. + /// To achieve this the method actually implements an "inline" with as it's processing logic. + /// + /// The pixel format. + /// The image to mutate. + /// The operation to perform on the source. + /// The to allow chaining of operations. + public static IImageProcessingContext Apply(this IImageProcessingContext source, Action> operation) + where TPixel : struct, IPixel => source.ApplyProcessor(new DelegateProcessor(operation)); + /// /// Mutates the source image by applying the image operation to it. /// @@ -52,7 +65,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// The image to clone. /// The operation to perform on the clone. - /// The new + /// The new public static Image Clone(this Image source, Action> operation) where TPixel : struct, IPixel { @@ -70,7 +83,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// The image to clone. /// The operations to perform on the clone. - /// The new + /// The new public static Image Clone(this Image source, params IImageProcessor[] operations) where TPixel : struct, IPixel { @@ -83,14 +96,14 @@ namespace SixLabors.ImageSharp } /// - /// Applies the given collection against the context + /// Applies the given collection against the context /// /// The pixel format. /// The image processing context. /// The operations to perform on the source. - /// The to allow chaining of operations. + /// The to allow chaining of operations. public static IImageProcessingContext ApplyProcessors(this IImageProcessingContext source, params IImageProcessor[] operations) - where TPixel : struct, IPixel + where TPixel : struct, IPixel { foreach (IImageProcessor p in operations) { diff --git a/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs b/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs index a089ffe1a..e7a9fc3f7 100644 --- a/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs @@ -6,10 +6,10 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Processors { /// - /// Allows the application of processors to images. + /// Allows the application of processing algorithms to a clone of the original image. /// /// The pixel format. internal abstract class CloningImageProcessor : ICloningImageProcessor diff --git a/src/ImageSharp/Processing/Processors/DelegateProcessor.cs b/src/ImageSharp/Processing/Processors/DelegateProcessor.cs index 0bfc14977..2ff00d583 100644 --- a/src/ImageSharp/Processing/Processors/DelegateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/DelegateProcessor.cs @@ -5,10 +5,10 @@ using System; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Processors { /// - /// Allows the application of processors to images. + /// Allows the application of processing algorithms to images via an action delegate /// /// The pixel format. internal class DelegateProcessor : ImageProcessor diff --git a/src/ImageSharp/Quantizers/Box.cs b/src/ImageSharp/Processing/Quantization/Box.cs similarity index 100% rename from src/ImageSharp/Quantizers/Box.cs rename to src/ImageSharp/Processing/Quantization/Box.cs diff --git a/src/ImageSharp/Quantizers/IQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs similarity index 100% rename from src/ImageSharp/Quantizers/IQuantizer{TPixel}.cs rename to src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs diff --git a/src/ImageSharp/Quantizers/OctreeQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/OctreeQuantizer{TPixel}.cs similarity index 100% rename from src/ImageSharp/Quantizers/OctreeQuantizer{TPixel}.cs rename to src/ImageSharp/Processing/Quantization/OctreeQuantizer{TPixel}.cs diff --git a/src/ImageSharp/Quantizers/PaletteQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/PaletteQuantizer{TPixel}.cs similarity index 100% rename from src/ImageSharp/Quantizers/PaletteQuantizer{TPixel}.cs rename to src/ImageSharp/Processing/Quantization/PaletteQuantizer{TPixel}.cs diff --git a/src/ImageSharp/Quantizers/Quantization.cs b/src/ImageSharp/Processing/Quantization/Quantization.cs similarity index 100% rename from src/ImageSharp/Quantizers/Quantization.cs rename to src/ImageSharp/Processing/Quantization/Quantization.cs diff --git a/src/ImageSharp/Quantizers/Quantize.cs b/src/ImageSharp/Processing/Quantization/Quantize.cs similarity index 98% rename from src/ImageSharp/Quantizers/Quantize.cs rename to src/ImageSharp/Processing/Quantization/Quantize.cs index f2a09abb7..70e2814d8 100644 --- a/src/ImageSharp/Quantizers/Quantize.cs +++ b/src/ImageSharp/Processing/Quantization/Quantize.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Quantizers; namespace SixLabors.ImageSharp diff --git a/src/ImageSharp/Quantizers/QuantizedImage{TPixel}.cs b/src/ImageSharp/Processing/Quantization/QuantizedImage{TPixel}.cs similarity index 100% rename from src/ImageSharp/Quantizers/QuantizedImage{TPixel}.cs rename to src/ImageSharp/Processing/Quantization/QuantizedImage{TPixel}.cs diff --git a/src/ImageSharp/Quantizers/QuantizerBase{TPixel}.cs b/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs similarity index 100% rename from src/ImageSharp/Quantizers/QuantizerBase{TPixel}.cs rename to src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs diff --git a/src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/WuQuantizer{TPixel}.cs similarity index 100% rename from src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs rename to src/ImageSharp/Processing/Quantization/WuQuantizer{TPixel}.cs diff --git a/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs similarity index 100% rename from src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor.cs rename to src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs diff --git a/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/AutoOrientProcessor.cs similarity index 100% rename from src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs rename to src/ImageSharp/Processing/Transforms/Processors/AutoOrientProcessor.cs diff --git a/src/ImageSharp/Processing/Processors/Transforms/CenteredAffineTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs similarity index 100% rename from src/ImageSharp/Processing/Processors/Transforms/CenteredAffineTransformProcessor.cs rename to src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs diff --git a/src/ImageSharp/Processing/Processors/Transforms/CenteredProjectiveTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs similarity index 100% rename from src/ImageSharp/Processing/Processors/Transforms/CenteredProjectiveTransformProcessor.cs rename to src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs diff --git a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/CropProcessor.cs similarity index 100% rename from src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs rename to src/ImageSharp/Processing/Transforms/Processors/CropProcessor.cs diff --git a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/EntropyCropProcessor.cs similarity index 100% rename from src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs rename to src/ImageSharp/Processing/Transforms/Processors/EntropyCropProcessor.cs diff --git a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs similarity index 100% rename from src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs rename to src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs diff --git a/src/ImageSharp/Processing/Processors/Transforms/InterpolatedTransformProcessorBase.cs b/src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs similarity index 100% rename from src/ImageSharp/Processing/Processors/Transforms/InterpolatedTransformProcessorBase.cs rename to src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs diff --git a/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs similarity index 100% rename from src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs rename to src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs diff --git a/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs similarity index 100% rename from src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs rename to src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs diff --git a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs similarity index 100% rename from src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs rename to src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs diff --git a/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs similarity index 100% rename from src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs rename to src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformProcessorBase.cs b/src/ImageSharp/Processing/Transforms/Processors/TransformProcessorBase.cs similarity index 100% rename from src/ImageSharp/Processing/Processors/Transforms/TransformProcessorBase.cs rename to src/ImageSharp/Processing/Transforms/Processors/TransformProcessorBase.cs diff --git a/src/ImageSharp/Processing/Processors/Transforms/WeightsBuffer.cs b/src/ImageSharp/Processing/Transforms/Processors/WeightsBuffer.cs similarity index 100% rename from src/ImageSharp/Processing/Processors/Transforms/WeightsBuffer.cs rename to src/ImageSharp/Processing/Transforms/Processors/WeightsBuffer.cs diff --git a/src/ImageSharp/Processing/Processors/Transforms/WeightsWindow.cs b/src/ImageSharp/Processing/Transforms/Processors/WeightsWindow.cs similarity index 100% rename from src/ImageSharp/Processing/Processors/Transforms/WeightsWindow.cs rename to src/ImageSharp/Processing/Transforms/Processors/WeightsWindow.cs diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs index ce1a88599..a8042c77c 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; - using SixLabors.ImageSharp.PixelFormats; + using SixLabors.ImageSharp.Processing; public class DrawBeziers : BenchmarkBase { diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs index 4f40c001d..f89d9a684 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs @@ -13,6 +13,7 @@ namespace SixLabors.ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; using SixLabors.ImageSharp.PixelFormats; + using SixLabors.ImageSharp.Processing; public class DrawLines : BenchmarkBase { diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs index fd8e4ad28..aa24088ae 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs @@ -14,6 +14,7 @@ namespace SixLabors.ImageSharp.Benchmarks using System.Numerics; using SixLabors.ImageSharp.PixelFormats; + using SixLabors.ImageSharp.Processing; public class DrawPolygon : BenchmarkBase { diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs index f948c4921..9075e02e8 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs @@ -14,6 +14,7 @@ namespace SixLabors.ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; using SixLabors.ImageSharp.PixelFormats; + using SixLabors.ImageSharp.Processing; public class FillPolygon : BenchmarkBase { diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs b/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs index b3890c101..1fd2dbe82 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs @@ -15,6 +15,7 @@ namespace SixLabors.ImageSharp.Benchmarks using System.Numerics; using SixLabors.ImageSharp.PixelFormats; + using SixLabors.ImageSharp.Processing; public class FillRectangle : BenchmarkBase { @@ -39,7 +40,7 @@ namespace SixLabors.ImageSharp.Benchmarks { using (Image image = new Image(800, 800)) { - image.Mutate(x => x.Fill(Rgba32.HotPink, new CoreRectangle(10, 10, 190, 140))); + image.Mutate(x => x.Fill(Rgba32.HotPink, new CoreRectangle(10, 10, 190, 140))); return new CoreSize(image.Width, image.Height); } @@ -53,10 +54,10 @@ namespace SixLabors.ImageSharp.Benchmarks image.Mutate(x => x.FillPolygon( Rgba32.HotPink, new SixLabors.Primitives.PointF[] { - new Vector2(10, 10), - new Vector2(200, 10), - new Vector2(200, 150), - new Vector2(10, 150) })); + new Vector2(10, 10), + new Vector2(200, 10), + new Vector2(200, 150), + new Vector2(10, 150) })); return new CoreSize(image.Width, image.Height); } diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs b/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs index 46d02e419..64132e479 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs @@ -14,6 +14,7 @@ namespace SixLabors.ImageSharp.Benchmarks using SixLabors.ImageSharp.Drawing.Brushes; using CoreBrushes = ImageSharp.Drawing.Brushes.Brushes; using SixLabors.ImageSharp.PixelFormats; + using SixLabors.ImageSharp.Processing; public class FillWithPattern { diff --git a/tests/ImageSharp.Benchmarks/Samplers/Crop.cs b/tests/ImageSharp.Benchmarks/Samplers/Crop.cs index 3681ff6f2..17c3933c0 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Crop.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Crop.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; using SixLabors.ImageSharp.PixelFormats; + using SixLabors.ImageSharp.Processing; using CoreSize = SixLabors.Primitives.Size; diff --git a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs index b14630cea..2771aa2e0 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; using SixLabors.ImageSharp.PixelFormats; - using SixLabors.ImageSharp.Processing.Processors; + using CoreSize = SixLabors.Primitives.Size; using SixLabors.ImageSharp.Processing; using System.Numerics; @@ -18,8 +18,7 @@ namespace SixLabors.ImageSharp.Benchmarks using SixLabors.ImageSharp.Memory; using SixLabors.Primitives; using SixLabors.ImageSharp.Helpers; - using SixLabors.ImageSharp.Advanced; - using SixLabors.ImageSharp.Processing.Processors.Overlays; + using SixLabors.ImageSharp.Processing.Overlays.Processors; public class Glow : BenchmarkBase { diff --git a/tests/ImageSharp.Benchmarks/Samplers/Resize.cs b/tests/ImageSharp.Benchmarks/Samplers/Resize.cs index 6e7e2c8c4..8bba227c5 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Resize.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Resize.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; using SixLabors.ImageSharp.PixelFormats; + using SixLabors.ImageSharp.Processing; using CoreSize = SixLabors.Primitives.Size; diff --git a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs index 5ffd9f5f1..af1364af4 100644 --- a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs +++ b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs @@ -12,6 +12,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing { + using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Overlays; + public class Beziers : FileTestBase { [Fact] diff --git a/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs b/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs index df029d2d7..bea0d8b07 100644 --- a/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs +++ b/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs @@ -11,6 +11,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing { + using SixLabors.ImageSharp.Processing; + public class BlendedShapes { public static IEnumerable modes = ((PixelBlenderMode[])Enum.GetValues(typeof(PixelBlenderMode))) diff --git a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs index 429acafb9..3902e874c 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs @@ -11,6 +11,9 @@ using ShapePath = SixLabors.Shapes.Path; namespace SixLabors.ImageSharp.Tests.Drawing { + using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Overlays; + public class DrawPathTests : FileTestBase { [Fact] diff --git a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs index d37058f5d..bd06e1f1f 100644 --- a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs @@ -11,6 +11,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing { + using SixLabors.ImageSharp.Primitives; + using SixLabors.ImageSharp.Processing; + public class FillPatternBrushTests : FileTestBase { private void Test(string name, Rgba32 background, IBrush brush, Rgba32[,] expectedPattern) @@ -28,9 +31,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing { // lets pick random spots to start checking Random r = new Random(); - Fast2DArray expectedPatternFast = new Fast2DArray(expectedPattern); - int xStride = expectedPatternFast.Width; - int yStride = expectedPatternFast.Height; + DenseMatrix expectedPatternFast = new DenseMatrix(expectedPattern); + int xStride = expectedPatternFast.Columns; + int yStride = expectedPatternFast.Rows; int offsetX = r.Next(image.Width / xStride) * xStride; int offsetY = r.Next(image.Height / yStride) * yStride; for (int x = 0; x < xStride; x++) diff --git a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs index 79ebf4778..21113f48c 100644 --- a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs @@ -12,6 +12,8 @@ using SixLabors.Primitives; namespace SixLabors.ImageSharp.Tests.Drawing { + using SixLabors.ImageSharp.Processing; + public class FillRegionProcessorTests { [Theory] diff --git a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs index 6eb139bac..88b6a8b25 100644 --- a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs @@ -12,6 +12,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing { + using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Overlays; + public class FillSolidBrushTests : FileTestBase { [Fact] diff --git a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs index 6c0670a85..8eb8d2159 100644 --- a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs @@ -12,6 +12,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing { + using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Overlays; + public class LineComplexPolygonTests : FileTestBase { [Fact] diff --git a/tests/ImageSharp.Tests/Drawing/LineTests.cs b/tests/ImageSharp.Tests/Drawing/LineTests.cs index d8c5c41d8..7b26d9e1d 100644 --- a/tests/ImageSharp.Tests/Drawing/LineTests.cs +++ b/tests/ImageSharp.Tests/Drawing/LineTests.cs @@ -10,6 +10,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing { + using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Overlays; + public class LineTests : FileTestBase { [Fact] diff --git a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs index a43f14eb7..f2d5187e3 100644 --- a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs @@ -13,6 +13,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing { + using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Overlays; + public class PolygonTests : FileTestBase { [Fact] diff --git a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs index 52668cc56..baaa8fe2a 100644 --- a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs @@ -10,6 +10,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests { + using SixLabors.ImageSharp.Processing; + public class RecolorImageTest : FileTestBase { [Fact] diff --git a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs index 4c6cc7acb..1fc1b172f 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs @@ -9,6 +9,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing { + using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Overlays; + [GroupOutput("Drawing")] public class SolidBezierTests { diff --git a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs index e1849b0d0..59ddc43ed 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs @@ -11,6 +11,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing { + using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Overlays; + public class SolidComplexPolygonTests : FileTestBase { [Fact] diff --git a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs index be7c8adb0..fbb0f0095 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs @@ -14,6 +14,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing { + using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Overlays; + public class SolidPolygonTests : FileTestBase { [Fact] diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs index 3a5fbe838..aed68f76b 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs @@ -9,6 +9,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests { + using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using Xunit.Abstractions; diff --git a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs index 22a811fee..463d5c7d8 100644 --- a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs +++ b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs @@ -14,6 +14,8 @@ namespace SixLabors.ImageSharp.Tests { using System; + using SixLabors.ImageSharp.Processing; + public class GeneralFormatTests : FileTestBase { [Theory] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs index cc030bbf7..ec3469153 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs @@ -13,6 +13,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.PixelFormats; + using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; using SixLabors.Primitives; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index 0010bb41d..d2ea982ae 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -14,6 +14,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests { + using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Quantizers; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs index fc17df93d..660f01dff 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs @@ -10,6 +10,8 @@ using SixLabors.ImageSharp.Formats.Png; namespace SixLabors.ImageSharp.Tests.Formats.Png { + using SixLabors.ImageSharp.Processing; + public class PngSmokeTests { [Theory] diff --git a/tests/ImageSharp.Tests/Image/ImageProcessingContextTests.cs b/tests/ImageSharp.Tests/Image/ImageProcessingContextTests.cs index f8f7b6758..e226e1ce8 100644 --- a/tests/ImageSharp.Tests/Image/ImageProcessingContextTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageProcessingContextTests.cs @@ -1,11 +1,14 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +//using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; using Xunit; namespace SixLabors.ImageSharp.Tests { + using SixLabors.ImageSharp.Processing; + public class ImageProcessingContextTests { [Fact] diff --git a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs index 73c2f78f4..59677ac78 100644 --- a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests { + using SixLabors.ImageSharp.Processing; + public class ImageRotationTests { [Fact] diff --git a/tests/ImageSharp.Tests/Issues/Issue412.cs b/tests/ImageSharp.Tests/Issues/Issue412.cs index b77112ba6..77db68281 100644 --- a/tests/ImageSharp.Tests/Issues/Issue412.cs +++ b/tests/ImageSharp.Tests/Issues/Issue412.cs @@ -8,6 +8,8 @@ using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Tests.Issues { + using SixLabors.ImageSharp.Processing; + public class Issue412 { [Theory] diff --git a/tests/ImageSharp.Tests/Memory/Fast2DArrayTests.cs b/tests/ImageSharp.Tests/Memory/Fast2DArrayTests.cs deleted file mode 100644 index a5364db72..000000000 --- a/tests/ImageSharp.Tests/Memory/Fast2DArrayTests.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -namespace SixLabors.ImageSharp.Tests.Memory -{ - using System; - - using SixLabors.ImageSharp.Memory; - - using Xunit; - - public class Fast2DArrayTests - { - private static readonly float[,] FloydSteinbergMatrix = - { - { 0, 0, 7 }, - { 3, 5, 1 } - }; - - [Fact] - public void Fast2DArrayThrowsOnNullInitializer() - { - Assert.Throws(() => - { - var fast = new Fast2DArray(null); - }); - } - - [Fact] - public void Fast2DArrayThrowsOnEmptyZeroWidth() - { - Assert.Throws(() => - { - var fast = new Fast2DArray(0, 10); - }); - } - - [Fact] - public void Fast2DArrayThrowsOnEmptyZeroHeight() - { - Assert.Throws(() => - { - var fast = new Fast2DArray(10, 0); - }); - } - - [Fact] - public void Fast2DArrayThrowsOnEmptyInitializer() - { - Assert.Throws(() => - { - var fast = new Fast2DArray(new float[0, 0]); - }); - } - - [Fact] - public void Fast2DArrayReturnsCorrectDimensions() - { - var fast = new Fast2DArray(FloydSteinbergMatrix); - Assert.True(fast.Width == FloydSteinbergMatrix.GetLength(1)); - Assert.True(fast.Height == FloydSteinbergMatrix.GetLength(0)); - } - - [Fact] - public void Fast2DArrayGetReturnsCorrectResults() - { - Fast2DArray fast = FloydSteinbergMatrix; - - for (int row = 0; row < fast.Height; row++) - { - for (int column = 0; column < fast.Width; column++) - { - Assert.True(Math.Abs(fast[row, column] - FloydSteinbergMatrix[row, column]) < Constants.Epsilon); - } - } - } - - [Fact] - public void Fast2DArrayGetSetReturnsCorrectResults() - { - var fast = new Fast2DArray(4, 4); - const float Val = 5F; - - fast[3, 3] = Val; - - Assert.True(Math.Abs(Val - fast[3, 3]) < Constants.Epsilon); - } - } -} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MatrixTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MatrixTests.cs index 437c223fa..f01a5ef96 100644 --- a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MatrixTests.cs +++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MatrixTests.cs @@ -8,6 +8,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Icc { + using SixLabors.ImageSharp.Primitives; + public class IccDataWriterMatrixTests { [Theory] @@ -35,8 +37,8 @@ namespace SixLabors.ImageSharp.Tests.Icc } [Theory] - [MemberData(nameof(IccTestDataMatrix.Matrix2D_Fast2DArrayTestData), MemberType = typeof(IccTestDataMatrix))] - internal void WriteMatrix2D_Fast2DArray(byte[] expected, int xCount, int yCount, bool isSingle, Fast2DArray data) + [MemberData(nameof(IccTestDataMatrix.Matrix2D_DenseMatrixTestData), MemberType = typeof(IccTestDataMatrix))] + internal void WriteMatrix2D_DenseMatrix(byte[] expected, int xCount, int yCount, bool isSingle, DenseMatrix data) { IccDataWriter writer = CreateWriter(); diff --git a/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs b/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs index a0ddc2c7c..e9a97992a 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs @@ -7,16 +7,18 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Binarization { + using SixLabors.ImageSharp.Primitives; + public class OrderedDitherFactoryTests { - private static readonly Fast2DArray Expected2x2Matrix = new Fast2DArray( + private static readonly DenseMatrix Expected2x2Matrix = new DenseMatrix( new uint[2, 2] { { 0, 2 }, { 3, 1 } }); - private static readonly Fast2DArray Expected3x3Matrix = new Fast2DArray( + private static readonly DenseMatrix Expected3x3Matrix = new DenseMatrix( new uint[3, 3] { { 0, 5, 2 }, @@ -24,7 +26,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization { 3, 6, 1 } }); - private static readonly Fast2DArray Expected4x4Matrix = new Fast2DArray( + private static readonly DenseMatrix Expected4x4Matrix = new DenseMatrix( new uint[4, 4] { { 0, 8, 2, 10 }, @@ -33,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization { 15, 7, 13, 5 } }); - private static readonly Fast2DArray Expected8x8Matrix = new Fast2DArray( + private static readonly DenseMatrix Expected8x8Matrix = new DenseMatrix( new uint[8, 8] { { 0, 32, 8, 40, 2, 34, 10, 42 }, @@ -50,10 +52,10 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization [Fact] public void OrderedDitherFactoryCreatesCorrect2x2Matrix() { - Fast2DArray actual = OrderedDitherFactory.CreateDitherMatrix(2); - for (int y = 0; y < actual.Height; y++) + DenseMatrix actual = OrderedDitherFactory.CreateDitherMatrix(2); + for (int y = 0; y < actual.Rows; y++) { - for (int x = 0; x < actual.Width; x++) + for (int x = 0; x < actual.Columns; x++) { Assert.Equal(Expected2x2Matrix[y, x], actual[y, x]); } @@ -63,10 +65,10 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization [Fact] public void OrderedDitherFactoryCreatesCorrect3x3Matrix() { - Fast2DArray actual = OrderedDitherFactory.CreateDitherMatrix(3); - for (int y = 0; y < actual.Height; y++) + DenseMatrix actual = OrderedDitherFactory.CreateDitherMatrix(3); + for (int y = 0; y < actual.Rows; y++) { - for (int x = 0; x < actual.Width; x++) + for (int x = 0; x < actual.Columns; x++) { Assert.Equal(Expected3x3Matrix[y, x], actual[y, x]); } @@ -76,10 +78,10 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization [Fact] public void OrderedDitherFactoryCreatesCorrect4x4Matrix() { - Fast2DArray actual = OrderedDitherFactory.CreateDitherMatrix(4); - for (int y = 0; y < actual.Height; y++) + DenseMatrix actual = OrderedDitherFactory.CreateDitherMatrix(4); + for (int y = 0; y < actual.Rows; y++) { - for (int x = 0; x < actual.Width; x++) + for (int x = 0; x < actual.Columns; x++) { Assert.Equal(Expected4x4Matrix[y, x], actual[y, x]); } @@ -89,10 +91,10 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization [Fact] public void OrderedDitherFactoryCreatesCorrect8x8Matrix() { - Fast2DArray actual = OrderedDitherFactory.CreateDitherMatrix(8); - for (int y = 0; y < actual.Height; y++) + DenseMatrix actual = OrderedDitherFactory.CreateDitherMatrix(8); + for (int y = 0; y < actual.Rows; y++) { - for (int x = 0; x < actual.Width; x++) + for (int x = 0; x < actual.Columns; x++) { Assert.Equal(Expected8x8Matrix[y, x], actual[y, x]); } diff --git a/tests/ImageSharp.Tests/Processing/DelegateTest.cs b/tests/ImageSharp.Tests/Processing/DelegateTest.cs index 518a28bea..73d3c8023 100644 --- a/tests/ImageSharp.Tests/Processing/DelegateTest.cs +++ b/tests/ImageSharp.Tests/Processing/DelegateTest.cs @@ -8,6 +8,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing { + using SixLabors.ImageSharp.Processing.Processors; + public class DelegateTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs b/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs index a24b8a4d4..ceb25d58e 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects { + using SixLabors.ImageSharp.Processing.Overlays; + using SixLabors.ImageSharp.Processing.Overlays.Processors; + public class BackgroundColorTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs index 0a87f8343..0d4695c29 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs @@ -2,16 +2,14 @@ // Licensed under the Apache License, Version 2.0. using System; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Overlays.Processors; using SixLabors.Primitives; using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Overlays { - using SixLabors.ImageSharp.Primitives; - 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 25b7d26ad..665b6cf1c 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs @@ -1,18 +1,14 @@ // 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.Tests.TestUtilities; +using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Overlays.Processors; using SixLabors.Primitives; using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Overlays { - using SixLabors.ImageSharp.Primitives; - 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 eb41c8435..f5f0ee7a6 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs @@ -11,6 +11,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization { + using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Binarization; public class BinaryDitherTests : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs index 42b9b9adf..b1092782c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs @@ -9,6 +9,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization { + using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Binarization; public class BinaryThresholdTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs index a86d5d3a0..b49fbf435 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs @@ -9,6 +9,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution { + using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Convolution; public class BoxBlurTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs index d5885bb98..69a635e9d 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs @@ -9,6 +9,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution { + using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Convolution; public class GaussianBlurTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs index 4f3237a21..468aa277c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs @@ -9,6 +9,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution { + using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Convolution; public class GaussianSharpenTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index 68d6efeec..519790655 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -11,6 +11,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization { + using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Dithering; public class DitherTests : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs index 2dd44b3a7..1e234e81e 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs @@ -9,6 +9,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects { + using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Overlays; + public class BackgroundColorTest : FileTestBase { [Theory] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs index 868763baf..715e997bf 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs @@ -9,6 +9,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects { + using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Effects; public class OilPaintTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs index 98bfbc553..84831e415 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs @@ -9,6 +9,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects { + using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Effects; public class PixelateTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Processors/Overlays/GlowTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Overlays/GlowTest.cs index 5693b6d75..5c610fb31 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Overlays/GlowTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Overlays/GlowTest.cs @@ -9,6 +9,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Overlays { + using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Overlays; + public class GlowTest : FileTestBase { [Theory] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Overlays/VignetteTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Overlays/VignetteTest.cs index 0d9c3e89b..1c69b531c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Overlays/VignetteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Overlays/VignetteTest.cs @@ -9,6 +9,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Overlays { + using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Overlays; + public class VignetteTest : FileTestBase { [Theory] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs index aa18feac2..69515b2cb 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs @@ -6,6 +6,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { + using SixLabors.ImageSharp.Processing; + public class CropTest : FileTestBase { [Theory] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs index 57341560e..27502df30 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs @@ -6,6 +6,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { + using SixLabors.ImageSharp.Processing; + public class EntropyCropTest : FileTestBase { public static readonly TheoryData EntropyCropValues diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs index b5f26b488..f83a08bae 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs @@ -6,6 +6,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { + using SixLabors.ImageSharp.Processing; + public class PadTest : FileTestBase { [Theory] diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs index 8e4b7d3d5..02bda3a0b 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs @@ -6,6 +6,8 @@ using SixLabors.ImageSharp.Memory; namespace SixLabors.ImageSharp.Tests { + using SixLabors.ImageSharp.Primitives; + internal static class IccTestDataMatrix { #region 2D @@ -42,12 +44,12 @@ namespace SixLabors.ImageSharp.Tests /// /// 3x3 Matrix /// - public static readonly Fast2DArray Single_Fast2DArray_ValGrad = new Fast2DArray(Single_2DArray_ValGrad); + public static readonly DenseMatrix Single_DenseMatrix_ValGrad = new DenseMatrix(Single_2DArray_ValGrad); /// /// 3x3 Matrix /// - public static readonly Fast2DArray Single_Fast2DArray_ValIdentity = new Fast2DArray(Single_2DArray_ValIdentity); + public static readonly DenseMatrix Single_DenseMatrix_ValIdentity = new DenseMatrix(Single_2DArray_ValIdentity); /// /// 3x3 Matrix @@ -110,11 +112,11 @@ namespace SixLabors.ImageSharp.Tests new object[] { Single_2D_Grad, 3, 3, true, Single_2DArray_ValGrad }, }; - public static readonly object[][] Matrix2D_Fast2DArrayTestData = + public static readonly object[][] Matrix2D_DenseMatrixTestData = { - new object[] { Fix16_2D_Grad, 3, 3, false, Single_Fast2DArray_ValGrad }, - new object[] { Fix16_2D_Identity, 3, 3, false, Single_Fast2DArray_ValIdentity }, - new object[] { Single_2D_Grad, 3, 3, true, Single_Fast2DArray_ValGrad }, + new object[] { Fix16_2D_Grad, 3, 3, false, Single_DenseMatrix_ValGrad }, + new object[] { Fix16_2D_Identity, 3, 3, false, Single_DenseMatrix_ValIdentity }, + new object[] { Single_2D_Grad, 3, 3, true, Single_DenseMatrix_ValGrad }, }; public static readonly object[][] Matrix2D_Matrix4x4TestData = diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs index 32860d2a4..9901661f4 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs @@ -9,6 +9,8 @@ using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests { + using SixLabors.ImageSharp.Processing; + /// /// Provides instances for parametric unit tests. /// diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs index 1352a2476..0f9634837 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs @@ -13,6 +13,8 @@ namespace SixLabors.ImageSharp.Tests { using Castle.Core.Internal; + using SixLabors.ImageSharp.Processing; + public interface ITestImageProvider { PixelTypes PixelType { get; } diff --git a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs index f03f9db09..3df71a08a 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs @@ -17,6 +17,7 @@ namespace SixLabors.ImageSharp.Tests using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.MetaData; + using SixLabors.ImageSharp.Processing; using Xunit; diff --git a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs index dd033ae7c..d31094085 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs @@ -10,6 +10,7 @@ using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Tests { + using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.Primitives; diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs index 3f8ec0556..8e6d60a50 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs @@ -13,6 +13,7 @@ namespace SixLabors.ImageSharp.Tests using Xunit; using Xunit.Abstractions; + using SixLabors.ImageSharp.Processing; public class ImageComparerTests { diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceCodecTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceCodecTests.cs index c67e4e06b..6ff935b54 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceCodecTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceCodecTests.cs @@ -3,6 +3,7 @@ namespace SixLabors.ImageSharp.Tests using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.PixelFormats; + using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;