diff --git a/src/ImageSharp.Drawing/DrawImage.cs b/src/ImageSharp.Drawing/DrawImage.cs index f1db72db6..9ff593d3e 100644 --- a/src/ImageSharp.Drawing/DrawImage.cs +++ b/src/ImageSharp.Drawing/DrawImage.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; namespace SixLabors.ImageSharp diff --git a/src/ImageSharp.Drawing/FillRegion.cs b/src/ImageSharp.Drawing/FillRegion.cs index 2e5d311c6..343225ab0 100644 --- a/src/ImageSharp.Drawing/FillRegion.cs +++ b/src/ImageSharp.Drawing/FillRegion.cs @@ -5,6 +5,7 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; namespace SixLabors.ImageSharp { diff --git a/src/ImageSharp.Drawing/Paths/DrawBeziers.cs b/src/ImageSharp.Drawing/Paths/DrawBeziers.cs index de4fdd003..268a8c3c5 100644 --- a/src/ImageSharp.Drawing/Paths/DrawBeziers.cs +++ b/src/ImageSharp.Drawing/Paths/DrawBeziers.cs @@ -6,6 +6,7 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; using SixLabors.Shapes; diff --git a/src/ImageSharp.Drawing/Paths/DrawLines.cs b/src/ImageSharp.Drawing/Paths/DrawLines.cs index e5d9a1b3b..397cd20e7 100644 --- a/src/ImageSharp.Drawing/Paths/DrawLines.cs +++ b/src/ImageSharp.Drawing/Paths/DrawLines.cs @@ -6,6 +6,7 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; using SixLabors.Shapes; diff --git a/src/ImageSharp.Drawing/Paths/DrawPath.cs b/src/ImageSharp.Drawing/Paths/DrawPath.cs index b6c821a60..b265342a4 100644 --- a/src/ImageSharp.Drawing/Paths/DrawPath.cs +++ b/src/ImageSharp.Drawing/Paths/DrawPath.cs @@ -5,6 +5,7 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using SixLabors.Shapes; namespace SixLabors.ImageSharp diff --git a/src/ImageSharp.Drawing/Paths/DrawPathCollection.cs b/src/ImageSharp.Drawing/Paths/DrawPathCollection.cs index a126663b0..17d7fed41 100644 --- a/src/ImageSharp.Drawing/Paths/DrawPathCollection.cs +++ b/src/ImageSharp.Drawing/Paths/DrawPathCollection.cs @@ -5,6 +5,7 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using SixLabors.Shapes; namespace SixLabors.ImageSharp diff --git a/src/ImageSharp.Drawing/Paths/DrawPolygon.cs b/src/ImageSharp.Drawing/Paths/DrawPolygon.cs index 771ea9e61..7615284d2 100644 --- a/src/ImageSharp.Drawing/Paths/DrawPolygon.cs +++ b/src/ImageSharp.Drawing/Paths/DrawPolygon.cs @@ -6,6 +6,7 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; using SixLabors.Shapes; diff --git a/src/ImageSharp.Drawing/Paths/DrawRectangle.cs b/src/ImageSharp.Drawing/Paths/DrawRectangle.cs index 6b98d1f8e..db825e2e8 100644 --- a/src/ImageSharp.Drawing/Paths/DrawRectangle.cs +++ b/src/ImageSharp.Drawing/Paths/DrawRectangle.cs @@ -5,6 +5,7 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; namespace SixLabors.ImageSharp diff --git a/src/ImageSharp.Drawing/Paths/FillPathBuilder.cs b/src/ImageSharp.Drawing/Paths/FillPathBuilder.cs index fff082f2d..f9846b863 100644 --- a/src/ImageSharp.Drawing/Paths/FillPathBuilder.cs +++ b/src/ImageSharp.Drawing/Paths/FillPathBuilder.cs @@ -5,6 +5,7 @@ using System; using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using SixLabors.Shapes; namespace SixLabors.ImageSharp diff --git a/src/ImageSharp.Drawing/Paths/FillPathCollection.cs b/src/ImageSharp.Drawing/Paths/FillPathCollection.cs index b252b95d5..d8fd89678 100644 --- a/src/ImageSharp.Drawing/Paths/FillPathCollection.cs +++ b/src/ImageSharp.Drawing/Paths/FillPathCollection.cs @@ -4,6 +4,7 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using SixLabors.Shapes; namespace SixLabors.ImageSharp diff --git a/src/ImageSharp.Drawing/Paths/FillPaths.cs b/src/ImageSharp.Drawing/Paths/FillPaths.cs index f554ed758..eb8fcc4ee 100644 --- a/src/ImageSharp.Drawing/Paths/FillPaths.cs +++ b/src/ImageSharp.Drawing/Paths/FillPaths.cs @@ -4,6 +4,7 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using SixLabors.Shapes; namespace SixLabors.ImageSharp diff --git a/src/ImageSharp.Drawing/Paths/FillPolygon.cs b/src/ImageSharp.Drawing/Paths/FillPolygon.cs index d8723bc31..4e3fea9c7 100644 --- a/src/ImageSharp.Drawing/Paths/FillPolygon.cs +++ b/src/ImageSharp.Drawing/Paths/FillPolygon.cs @@ -6,6 +6,7 @@ using System.Numerics; using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; using SixLabors.Shapes; diff --git a/src/ImageSharp.Drawing/Paths/FillRectangle.cs b/src/ImageSharp.Drawing/Paths/FillRectangle.cs index 52578de17..2f3b67629 100644 --- a/src/ImageSharp.Drawing/Paths/FillRectangle.cs +++ b/src/ImageSharp.Drawing/Paths/FillRectangle.cs @@ -4,6 +4,7 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; namespace SixLabors.ImageSharp diff --git a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs index 46e27be78..dcf71bde0 100644 --- a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs @@ -7,7 +7,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Drawing.Processors diff --git a/src/ImageSharp.Drawing/Processors/FillProcessor.cs b/src/ImageSharp.Drawing/Processors/FillProcessor.cs index b8cbddcba..70ac2507a 100644 --- a/src/ImageSharp.Drawing/Processors/FillProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/FillProcessor.cs @@ -2,21 +2,18 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Numerics; using System.Threading.Tasks; -using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Brushes.Processors; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Drawing.Processors { /// - /// Using the bursh as a source of pixels colors blends the brush color with source. + /// Using the brush as a source of pixels colors blends the brush color with source. /// /// The pixel format. internal class FillProcessor : ImageProcessor diff --git a/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs b/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs index 66a35f151..40db43a02 100644 --- a/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs @@ -2,24 +2,21 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Buffers; -using System.Diagnostics; using System.Runtime.CompilerServices; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Brushes.Processors; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Drawing.Processors { /// - /// Usinf a brsuh and a shape fills shape with contents of brush the + /// Using a brush and a shape fills shape with contents of brush the /// /// The type of the color. - /// + /// internal class FillRegionProcessor : ImageProcessor where TPixel : struct, IPixel { diff --git a/src/ImageSharp.Drawing/Text/DrawText.Path.cs b/src/ImageSharp.Drawing/Text/DrawText.Path.cs index 274b59205..f1fbd2cec 100644 --- a/src/ImageSharp.Drawing/Text/DrawText.Path.cs +++ b/src/ImageSharp.Drawing/Text/DrawText.Path.cs @@ -7,6 +7,7 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using SixLabors.Shapes; namespace SixLabors.ImageSharp diff --git a/src/ImageSharp.Drawing/Text/DrawText.cs b/src/ImageSharp.Drawing/Text/DrawText.cs index c0105011e..cac5ae22f 100644 --- a/src/ImageSharp.Drawing/Text/DrawText.cs +++ b/src/ImageSharp.Drawing/Text/DrawText.cs @@ -7,6 +7,7 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; using SixLabors.Shapes; diff --git a/src/ImageSharp/Configuration.cs b/src/ImageSharp/Configuration.cs index d41e48678..06c588af3 100644 --- a/src/ImageSharp/Configuration.cs +++ b/src/ImageSharp/Configuration.cs @@ -2,17 +2,18 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Collections.Concurrent; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Gif; using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Png; +#if !NETSTANDARD1_1 using SixLabors.ImageSharp.IO; +#endif using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Processing; namespace SixLabors.ImageSharp { diff --git a/src/ImageSharp/Formats/Gif/GifEncoder.cs b/src/ImageSharp/Formats/Gif/GifEncoder.cs index b548098be..ad3e85f92 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoder.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoder.cs @@ -1,14 +1,11 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Collections.Generic; using System.IO; using System.Text; - using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Quantizers; +using SixLabors.ImageSharp.Processing.Quantization; namespace SixLabors.ImageSharp.Formats.Gif { diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index 13ca5f2c6..bdb228f52 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Buffers; using System.IO; using System.Linq; using System.Text; @@ -10,7 +9,7 @@ using SixLabors.ImageSharp.IO; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.MetaData; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Quantizers; +using SixLabors.ImageSharp.Processing.Quantization; namespace SixLabors.ImageSharp.Formats.Gif { @@ -106,7 +105,7 @@ namespace SixLabors.ImageSharp.Formats.Gif var pixelQuantizer = (IQuantizer)this.quantizer; // Quantize the image returning a palette. - QuantizedImage quantized = pixelQuantizer.Quantize(image.Frames.RootFrame, size); + QuantizedFrame quantized = pixelQuantizer.Quantize(image.Frames.RootFrame, size); int index = this.GetTransparentIndex(quantized); @@ -154,7 +153,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// /// The . /// - private int GetTransparentIndex(QuantizedImage quantized) + private int GetTransparentIndex(QuantizedFrame quantized) where TPixel : struct, IPixel { // Transparent pixels are much more likely to be found at the end of a palette @@ -347,7 +346,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// The pixel format. /// The to encode. /// The writer to write to the stream with. - private void WriteColorTable(QuantizedImage image, EndianBinaryWriter writer) + private void WriteColorTable(QuantizedFrame image, EndianBinaryWriter writer) where TPixel : struct, IPixel { // Grab the palette and write it to the stream. @@ -377,9 +376,9 @@ namespace SixLabors.ImageSharp.Formats.Gif /// Writes the image pixel data to the stream. /// /// The pixel format. - /// The containing indexed pixels. + /// The containing indexed pixels. /// The stream to write to. - private void WriteImageData(QuantizedImage image, EndianBinaryWriter writer) + private void WriteImageData(QuantizedFrame image, EndianBinaryWriter writer) where TPixel : struct, IPixel { using (var encoder = new LzwEncoder(this.memoryManager, image.Pixels, (byte)this.bitDepth)) diff --git a/src/ImageSharp/Formats/Gif/IGifEncoderOptions.cs b/src/ImageSharp/Formats/Gif/IGifEncoderOptions.cs index 374dea659..a709b2b9d 100644 --- a/src/ImageSharp/Formats/Gif/IGifEncoderOptions.cs +++ b/src/ImageSharp/Formats/Gif/IGifEncoderOptions.cs @@ -1,12 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Collections.Generic; -using System.IO; using System.Text; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Quantizers; +using SixLabors.ImageSharp.Processing.Quantization; namespace SixLabors.ImageSharp.Formats.Gif { @@ -38,6 +34,6 @@ namespace SixLabors.ImageSharp.Formats.Gif /// /// Gets the quantizer for reducing the color count. /// - IQuantizer Quantizer { get; } + IQuantizer Quantizer { get; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Formats/Png/IPngEncoderOptions.cs b/src/ImageSharp/Formats/Png/IPngEncoderOptions.cs index 6b4b05e31..28020f260 100644 --- a/src/ImageSharp/Formats/Png/IPngEncoderOptions.cs +++ b/src/ImageSharp/Formats/Png/IPngEncoderOptions.cs @@ -1,15 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Collections.Generic; -using System.IO; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Quantizers; +using SixLabors.ImageSharp.Processing.Quantization; namespace SixLabors.ImageSharp.Formats.Png { /// - /// The options availible for manipulating the encoder pipeline + /// The options available for manipulating the encoder pipeline /// internal interface IPngEncoderOptions { diff --git a/src/ImageSharp/Formats/Png/PngEncoder.cs b/src/ImageSharp/Formats/Png/PngEncoder.cs index 0c40ccf2a..2cff18410 100644 --- a/src/ImageSharp/Formats/Png/PngEncoder.cs +++ b/src/ImageSharp/Formats/Png/PngEncoder.cs @@ -3,9 +3,8 @@ using System.IO; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Quantizers; +using SixLabors.ImageSharp.Processing.Quantization; namespace SixLabors.ImageSharp.Formats.Png { diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index 1ab7a83ce..29c9d2a14 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Buffers; using System.IO; using System.Linq; using SixLabors.ImageSharp.Advanced; @@ -10,7 +9,7 @@ using SixLabors.ImageSharp.Formats.Png.Filters; using SixLabors.ImageSharp.Formats.Png.Zlib; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Quantizers; +using SixLabors.ImageSharp.Processing.Quantization; namespace SixLabors.ImageSharp.Formats.Png { @@ -308,7 +307,7 @@ namespace SixLabors.ImageSharp.Formats.Png where TPixel : struct, IPixel { // Quantize the image and get the pixels. - QuantizedImage quantized = this.WritePaletteChunk(stream, header, image); + QuantizedFrame quantized = this.WritePaletteChunk(stream, header, image); this.palettePixelData = quantized.Pixels; } @@ -498,8 +497,8 @@ namespace SixLabors.ImageSharp.Formats.Png /// The containing image data. /// The . /// The image to encode. - /// The - private QuantizedImage WritePaletteChunk(Stream stream, PngHeader header, ImageFrame image) + /// The + private QuantizedFrame WritePaletteChunk(Stream stream, PngHeader header, ImageFrame image) where TPixel : struct, IPixel { if (this.paletteSize > 256) @@ -513,7 +512,7 @@ namespace SixLabors.ImageSharp.Formats.Png } // Quantize the image returning a palette. This boxing is icky. - QuantizedImage quantized = ((IQuantizer)this.quantizer).Quantize(image, this.paletteSize); + QuantizedFrame quantized = ((IQuantizer)this.quantizer).Quantize(image, this.paletteSize); // Grab the palette and write it to the stream. TPixel[] palette = quantized.Palette; diff --git a/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs index 9e96ddcde..ff2c9348e 100644 --- a/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs @@ -6,6 +6,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Binarization.Processors diff --git a/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs index 8d72ba66f..b1fb22731 100644 --- a/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs @@ -6,6 +6,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Binarization.Processors diff --git a/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs index 39d829c73..3c29194f6 100644 --- a/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Binarization.Processors diff --git a/src/ImageSharp/Processing/Convolution/Processors/BoxBlurProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/BoxBlurProcessor.cs index b3e477f3c..886fb5d75 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/BoxBlurProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/BoxBlurProcessor.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors diff --git a/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs index bbdd2f979..ebadd2850 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs @@ -8,6 +8,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors diff --git a/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs index 51479929f..0a3393315 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs @@ -8,6 +8,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors diff --git a/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs index eb65091fe..ee7d93a03 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs @@ -9,6 +9,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors diff --git a/src/ImageSharp/Processing/Convolution/Processors/EdgeDetector2DProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetector2DProcessor.cs index d853fdb8e..c3530647a 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/EdgeDetector2DProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetector2DProcessor.cs @@ -4,6 +4,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing.Filters.Processors; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors diff --git a/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorCompassProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorCompassProcessor.cs index b2f78fc85..bcedd7a3c 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorCompassProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorCompassProcessor.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing.Filters.Processors; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors diff --git a/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorProcessor.cs index ecb6364a8..e0ca83828 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorProcessor.cs @@ -4,6 +4,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing.Filters.Processors; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors diff --git a/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs index 9b3ad51b7..6f33e23ec 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs @@ -4,6 +4,7 @@ using System; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors diff --git a/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs index bb55e60c9..5f296e29e 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs @@ -4,6 +4,7 @@ using System; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors diff --git a/src/ImageSharp/Processing/Convolution/Processors/IEdgeDetectorProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/IEdgeDetectorProcessor.cs index e43aff70b..486929e02 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/IEdgeDetectorProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/IEdgeDetectorProcessor.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; namespace SixLabors.ImageSharp.Processing.Convolution.Processors { diff --git a/src/ImageSharp/DefaultInternalImageProcessorContext.cs b/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs similarity index 97% rename from src/ImageSharp/DefaultInternalImageProcessorContext.cs rename to src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs index 7ccc65e27..05760bb04 100644 --- a/src/ImageSharp/DefaultInternalImageProcessorContext.cs +++ b/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs @@ -5,10 +5,10 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing { /// /// Performs processor application operations on the source image diff --git a/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs index 4e2a2cb79..e01e3ce3b 100644 --- a/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs @@ -6,6 +6,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Dithering.Processors diff --git a/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs index 213f7ca90..254c44a2a 100644 --- a/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs @@ -6,6 +6,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Dithering.Processors diff --git a/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs b/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs index 782d33b53..89cc7cfb6 100644 --- a/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Numerics; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; namespace SixLabors.ImageSharp.Processing.Dithering.Processors { diff --git a/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs b/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs index aafc2df88..2bf35d220 100644 --- a/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs +++ b/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs @@ -8,6 +8,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Effects.Processors diff --git a/src/ImageSharp/Processing/Effects/Processors/PixelateProcessor.cs b/src/ImageSharp/Processing/Effects/Processors/PixelateProcessor.cs index 23f81e05e..d45d2093f 100644 --- a/src/ImageSharp/Processing/Effects/Processors/PixelateProcessor.cs +++ b/src/ImageSharp/Processing/Effects/Processors/PixelateProcessor.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Common; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Effects.Processors diff --git a/src/ImageSharp/Processing/Filters/ColorBlindnessExtensions.cs b/src/ImageSharp/Processing/Filters/ColorBlindnessExtensions.cs index 6a0caf3b4..b7dc87150 100644 --- a/src/ImageSharp/Processing/Filters/ColorBlindnessExtensions.cs +++ b/src/ImageSharp/Processing/Filters/ColorBlindnessExtensions.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Filters.Processors; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Filters @@ -21,10 +22,7 @@ namespace SixLabors.ImageSharp.Processing.Filters /// The . public static IImageProcessingContext ColorBlindness(this IImageProcessingContext source, ColorBlindness colorBlindness) where TPixel : struct, IPixel - { - source.ApplyProcessor(GetProcessor(colorBlindness)); - return source; - } + => source.ApplyProcessor(GetProcessor(colorBlindness)); /// /// Applies the given colorblindness simulator to the image. @@ -38,10 +36,7 @@ namespace SixLabors.ImageSharp.Processing.Filters /// The . public static IImageProcessingContext ColorBlindness(this IImageProcessingContext source, ColorBlindness colorBlindness, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(GetProcessor(colorBlindness), rectangle); - return source; - } + => source.ApplyProcessor(GetProcessor(colorBlindness), rectangle); private static IImageProcessor GetProcessor(ColorBlindness colorBlindness) where TPixel : struct, IPixel @@ -67,4 +62,4 @@ namespace SixLabors.ImageSharp.Processing.Filters } } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Filters/GrayscaleExtensions.cs b/src/ImageSharp/Processing/Filters/GrayscaleExtensions.cs index be5b69eed..34ee4d0f3 100644 --- a/src/ImageSharp/Processing/Filters/GrayscaleExtensions.cs +++ b/src/ImageSharp/Processing/Filters/GrayscaleExtensions.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Filters.Processors; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Filters diff --git a/src/ImageSharp/Processing/Filters/Processors/FilterProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/FilterProcessor.cs index fb094d7bd..5267a36b4 100644 --- a/src/ImageSharp/Processing/Filters/Processors/FilterProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/FilterProcessor.cs @@ -7,12 +7,13 @@ using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// - /// Provides methods that accept a matrix to apply freeform filters to images. + /// Provides methods that accept a matrix to apply free-form filters to images. /// /// The pixel format. internal class FilterProcessor : ImageProcessor diff --git a/src/ImageSharp/IImageProcessingContextFactory.cs b/src/ImageSharp/Processing/IImageProcessingContextFactory.cs similarity index 86% rename from src/ImageSharp/IImageProcessingContextFactory.cs rename to src/ImageSharp/Processing/IImageProcessingContextFactory.cs index b7b935ecd..1ec2d191f 100644 --- a/src/ImageSharp/IImageProcessingContextFactory.cs +++ b/src/ImageSharp/Processing/IImageProcessingContextFactory.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing { /// /// Represents an interface that will create IInternalImageProcessingContext instances @@ -16,13 +16,13 @@ namespace SixLabors.ImageSharp /// The pixel format /// The source image. /// A flag to determine whether image operations are allowed to mutate the source image. - /// A new IImageOPeration + /// A new IInternalImageProcessingContext CreateImageProcessingContext(Image source, bool mutate) where TPixel : struct, IPixel; } /// - /// The default implmentation of + /// The default implementation of /// internal class DefaultImageOperationsProviderFactory : IImageProcessingContextFactory { @@ -33,4 +33,4 @@ namespace SixLabors.ImageSharp return new DefaultInternalImageProcessorContext(source, mutate); } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/IImageProcessingContext{TPixel}.cs b/src/ImageSharp/Processing/IImageProcessingContext{TPixel}.cs similarity index 96% rename from src/ImageSharp/IImageProcessingContext{TPixel}.cs rename to src/ImageSharp/Processing/IImageProcessingContext{TPixel}.cs index 0e8efde3b..f56777bed 100644 --- a/src/ImageSharp/IImageProcessingContext{TPixel}.cs +++ b/src/ImageSharp/Processing/IImageProcessingContext{TPixel}.cs @@ -3,10 +3,10 @@ using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing { /// /// An interface to queue up image operations to apply to an image. diff --git a/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs index c91cc93c2..e0639d8ad 100644 --- a/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.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.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Overlays.Processors diff --git a/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs index 7477c1390..22250cc18 100644 --- a/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs @@ -9,6 +9,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Overlays.Processors diff --git a/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs index bca63b314..364eb0b79 100644 --- a/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs @@ -9,6 +9,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Overlays.Processors diff --git a/src/ImageSharp/Processing/ProcessingExtensions.cs b/src/ImageSharp/Processing/ProcessingExtensions.cs index 97faab88f..9d06c61d4 100644 --- a/src/ImageSharp/Processing/ProcessingExtensions.cs +++ b/src/ImageSharp/Processing/ProcessingExtensions.cs @@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.Processing } /// - /// Applies the given collection against the context + /// Applies the given collection against the context /// /// The pixel format. /// The image processing context. diff --git a/src/ImageSharp/ICloningImageProcessor.cs b/src/ImageSharp/Processing/Processors/ICloningImageProcessor.cs similarity index 83% rename from src/ImageSharp/ICloningImageProcessor.cs rename to src/ImageSharp/Processing/Processors/ICloningImageProcessor.cs index aeb3c815e..024ccbced 100644 --- a/src/ImageSharp/ICloningImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ICloningImageProcessor.cs @@ -4,7 +4,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Processors { /// /// Encapsulates methods to alter the pixels of a new image, cloned from the original image. @@ -24,9 +24,9 @@ namespace SixLabors.ImageSharp.Processing /// is null. /// /// - /// doesnt fit the dimension of the image. + /// doesn't fit the dimension of the image. /// - /// Returns the cloned image after thre processor has been applied to it. + /// Returns the cloned image after there processor has been applied to it. Image CloneAndApply(Image source, Rectangle sourceRectangle); } -} +} \ No newline at end of file diff --git a/src/ImageSharp/IImageProcessor.cs b/src/ImageSharp/Processing/Processors/IImageProcessor.cs similarity index 95% rename from src/ImageSharp/IImageProcessor.cs rename to src/ImageSharp/Processing/Processors/IImageProcessor.cs index c7fb565ca..d7fe0465b 100644 --- a/src/ImageSharp/IImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/IImageProcessor.cs @@ -4,7 +4,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Processors { /// /// Encapsulates methods to alter the pixels of an image. @@ -28,4 +28,4 @@ namespace SixLabors.ImageSharp /// void Apply(Image source, Rectangle sourceRectangle); } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/ImageProcessor.cs b/src/ImageSharp/Processing/Processors/ImageProcessor.cs index 124b34559..0d27a9e1e 100644 --- a/src/ImageSharp/Processing/Processors/ImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ImageProcessor.cs @@ -6,7 +6,7 @@ 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. @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Processing #else catch (Exception ex) { - throw new ImageProcessingException($"An error occured when processing the image using {this.GetType().Name}. See the inner exception for more detail.", ex); + throw new ImageProcessingException($"An error occurred when processing the image using {this.GetType().Name}. See the inner exception for more detail.", ex); #endif } } @@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Processing #else catch (Exception ex) { - throw new ImageProcessingException($"An error occured when processing the image using {this.GetType().Name}. See the inner exception for more detail.", ex); + throw new ImageProcessingException($"An error occurred when processing the image using {this.GetType().Name}. See the inner exception for more detail.", ex); #endif } } diff --git a/src/ImageSharp/Processing/Quantization/Box.cs b/src/ImageSharp/Processing/Quantization/Box.cs index cd1936b65..e6e1166f8 100644 --- a/src/ImageSharp/Processing/Quantization/Box.cs +++ b/src/ImageSharp/Processing/Quantization/Box.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Quantizers +namespace SixLabors.ImageSharp.Processing.Quantization { /// /// Represents a box color cube. diff --git a/src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs index 82f6146a3..f2d280477 100644 --- a/src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs @@ -4,7 +4,7 @@ using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Quantizers +namespace SixLabors.ImageSharp.Processing.Quantization { /// /// Provides methods for for allowing quantization of images pixels with configurable dithering. @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Quantizers /// /// A representing a quantized version of the image pixels. /// - QuantizedImage Quantize(ImageFrame image, int maxColors); + QuantizedFrame Quantize(ImageFrame image, int maxColors); } /// @@ -39,4 +39,4 @@ namespace SixLabors.ImageSharp.Quantizers /// IErrorDiffuser DitherType { get; set; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Quantization/OctreeQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/OctreeQuantizer{TPixel}.cs index 8b8db6177..5d8104937 100644 --- a/src/ImageSharp/Processing/Quantization/OctreeQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/OctreeQuantizer{TPixel}.cs @@ -4,11 +4,11 @@ using System; using System.Collections.Generic; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Quantizers.Base; -namespace SixLabors.ImageSharp.Quantizers +namespace SixLabors.ImageSharp.Processing.Quantization { /// /// Encapsulates methods to calculate the color palette if an image using an Octree pattern. @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Quantizers } /// - public override QuantizedImage Quantize(ImageFrame image, int maxColors) + public override QuantizedFrame Quantize(ImageFrame image, int maxColors) { this.colors = (byte)maxColors.Clamp(1, 255); this.octree = new Octree(this.GetBitsNeededForColorDepth(this.colors)); @@ -66,6 +66,28 @@ namespace SixLabors.ImageSharp.Quantizers return base.Quantize(image, this.colors); } + /// + protected override void FirstPass(ImageFrame source, int width, int height) + { + // Loop through each row + for (int y = 0; y < height; y++) + { + Span row = source.GetPixelRowSpan(y); + ref TPixel scanBaseRef = ref MemoryMarshal.GetReference(row); + + // And loop through each column + var rgba = default(Rgba32); + for (int x = 0; x < width; x++) + { + ref TPixel pixel = ref Unsafe.Add(ref scanBaseRef, x); + pixel.ToRgba32(ref rgba); + + // Add the color to the Octree + this.octree.AddColor(ref pixel, ref rgba); + } + } + } + /// protected override void SecondPass(ImageFrame source, byte[] output, int width, int height) { @@ -115,14 +137,6 @@ namespace SixLabors.ImageSharp.Quantizers } } - /// - protected override void InitialQuantizePixel(TPixel pixel) - { - // Add the color to the Octree - var rgba = default(Rgba32); - this.octree.AddColor(pixel, ref rgba); - } - /// protected override TPixel[] GetPalette() { @@ -173,7 +187,7 @@ namespace SixLabors.ImageSharp.Quantizers { if (this.Dither) { - // The colors have changed so we need to use Euclidean distance caclulation to find the closest value. + // The colors have changed so we need to use Euclidean distance calculation to find the closest value. // This palette can never be null here. return this.GetClosestPixel(pixel, this.palette, this.colorMap); } @@ -184,7 +198,7 @@ namespace SixLabors.ImageSharp.Quantizers return this.transparentIndex; } - return (byte)this.octree.GetPaletteIndex(pixel, ref rgba); + return (byte)this.octree.GetPaletteIndex(ref pixel, ref rgba); } /// @@ -268,7 +282,7 @@ namespace SixLabors.ImageSharp.Quantizers /// /// The pixel data. /// The color. - public void AddColor(TPixel pixel, ref Rgba32 rgba) + public void AddColor(ref TPixel pixel, ref Rgba32 rgba) { // Check if this request is for the same color as the last if (this.previousColor.Equals(pixel)) @@ -278,18 +292,18 @@ namespace SixLabors.ImageSharp.Quantizers if (this.previousNode == null) { this.previousColor = pixel; - this.root.AddColor(pixel, this.maxColorBits, 0, this, ref rgba); + this.root.AddColor(ref pixel, this.maxColorBits, 0, this, ref rgba); } else { // Just update the previous node - this.previousNode.Increment(pixel, ref rgba); + this.previousNode.Increment(ref pixel, ref rgba); } } else { this.previousColor = pixel; - this.root.AddColor(pixel, this.maxColorBits, 0, this, ref rgba); + this.root.AddColor(ref pixel, this.maxColorBits, 0, this, ref rgba); } } @@ -325,9 +339,9 @@ namespace SixLabors.ImageSharp.Quantizers /// /// The . /// - public int GetPaletteIndex(TPixel pixel, ref Rgba32 rgba) + public int GetPaletteIndex(ref TPixel pixel, ref Rgba32 rgba) { - return this.root.GetPaletteIndex(pixel, 0, ref rgba); + return this.root.GetPaletteIndex(ref pixel, 0, ref rgba); } /// @@ -454,12 +468,12 @@ namespace SixLabors.ImageSharp.Quantizers /// The level in the tree /// The tree to which this node belongs /// The color to map to. - public void AddColor(TPixel pixel, int colorBits, int level, Octree octree, ref Rgba32 rgba) + public void AddColor(ref TPixel pixel, int colorBits, int level, Octree octree, ref Rgba32 rgba) { // Update the color information if this is a leaf if (this.leaf) { - this.Increment(pixel, ref rgba); + this.Increment(ref pixel, ref rgba); // Setup the previous node octree.TrackPrevious(this); @@ -484,7 +498,7 @@ namespace SixLabors.ImageSharp.Quantizers } // Add the color to the child node - child.AddColor(pixel, colorBits, level + 1, octree, ref rgba); + child.AddColor(ref pixel, colorBits, level + 1, octree, ref rgba); } } @@ -562,7 +576,7 @@ namespace SixLabors.ImageSharp.Quantizers /// /// The representing the index of the pixel in the palette. /// - public int GetPaletteIndex(TPixel pixel, int level, ref Rgba32 rgba) + public int GetPaletteIndex(ref TPixel pixel, int level, ref Rgba32 rgba) { int index = this.paletteIndex; @@ -577,7 +591,7 @@ namespace SixLabors.ImageSharp.Quantizers if (this.children[pixelIndex] != null) { - index = this.children[pixelIndex].GetPaletteIndex(pixel, level + 1, ref rgba); + index = this.children[pixelIndex].GetPaletteIndex(ref pixel, level + 1, ref rgba); } else { @@ -593,7 +607,7 @@ namespace SixLabors.ImageSharp.Quantizers /// /// The pixel to add. /// The color to map to. - public void Increment(TPixel pixel, ref Rgba32 rgba) + public void Increment(ref TPixel pixel, ref Rgba32 rgba) { pixel.ToRgba32(ref rgba); this.pixelCount++; diff --git a/src/ImageSharp/Processing/Quantization/PaletteQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/PaletteQuantizer{TPixel}.cs index cd1b4b07b..8955e14dd 100644 --- a/src/ImageSharp/Processing/Quantization/PaletteQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/PaletteQuantizer{TPixel}.cs @@ -6,9 +6,8 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Quantizers.Base; -namespace SixLabors.ImageSharp.Quantizers +namespace SixLabors.ImageSharp.Processing.Quantization { /// /// Encapsulates methods to create a quantized image based upon the given palette. @@ -49,7 +48,7 @@ namespace SixLabors.ImageSharp.Quantizers } /// - public override QuantizedImage Quantize(ImageFrame image, int maxColors) + public override QuantizedFrame Quantize(ImageFrame image, int maxColors) { Array.Resize(ref this.colors, maxColors.Clamp(1, 255)); this.colorMap.Clear(); diff --git a/src/ImageSharp/Processing/Quantization/Processors/QuantizeProcessor.cs b/src/ImageSharp/Processing/Quantization/Processors/QuantizeProcessor.cs new file mode 100644 index 000000000..e6b109993 --- /dev/null +++ b/src/ImageSharp/Processing/Quantization/Processors/QuantizeProcessor.cs @@ -0,0 +1,72 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using System; +using System.Threading.Tasks; +using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.Primitives; + +namespace SixLabors.ImageSharp.Processing.Quantization.Processors +{ + /// + /// Enables the quantization of images to remove the number of colors used in the image palette. + /// + /// The pixel format. + internal class QuantizeProcessor : ImageProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// The quantizer used to reduce the color palette + /// The maximum number of colors to reduce the palette to + public QuantizeProcessor(IQuantizer quantizer, int maxColors) + { + Guard.NotNull(quantizer, nameof(quantizer)); + Guard.MustBeGreaterThan(maxColors, 0, nameof(maxColors)); + + this.Quantizer = quantizer; + this.MaxColors = maxColors; + } + + /// + /// Gets the quantizer + /// + public IQuantizer Quantizer { get; } + + /// + /// Gets the maximum number of palette colors + /// + public int MaxColors { get; } + + /// + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + { + QuantizedFrame quantized = this.Quantizer.Quantize(source, this.MaxColors); + int paletteCount = quantized.Palette.Length - 1; + + using (Buffer2D pixels = source.MemoryManager.Allocate2D(quantized.Width, quantized.Height)) + { + Parallel.For( + 0, + pixels.Height, + configuration.ParallelOptions, + y => + { + Span row = pixels.GetRowSpan(y); + int yy = y * pixels.Width; + for (int x = 0; x < pixels.Width; x++) + { + int i = x + yy; + TPixel color = quantized.Palette[Math.Min(paletteCount, quantized.Pixels[i])]; + row[x] = color; + } + }); + + Buffer2D.SwapContents(source.PixelBuffer, pixels); + } + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Quantization/Quantization.cs b/src/ImageSharp/Processing/Quantization/QuantizationMode.cs similarity index 90% rename from src/ImageSharp/Processing/Quantization/Quantization.cs rename to src/ImageSharp/Processing/Quantization/QuantizationMode.cs index df55d3e87..69857b384 100644 --- a/src/ImageSharp/Processing/Quantization/Quantization.cs +++ b/src/ImageSharp/Processing/Quantization/QuantizationMode.cs @@ -1,12 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Quantization { /// /// Provides enumeration over how an image should be quantized. /// - public enum Quantization + public enum QuantizationMode { /// /// An adaptive Octree quantizer. Fast with good quality. diff --git a/src/ImageSharp/Processing/Quantization/Quantize.cs b/src/ImageSharp/Processing/Quantization/QuantizeExtensions.cs similarity index 53% rename from src/ImageSharp/Processing/Quantization/Quantize.cs rename to src/ImageSharp/Processing/Quantization/QuantizeExtensions.cs index 70e2814d8..2b367ffe9 100644 --- a/src/ImageSharp/Processing/Quantization/Quantize.cs +++ b/src/ImageSharp/Processing/Quantization/QuantizeExtensions.cs @@ -1,20 +1,15 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Threading.Tasks; -using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Quantizers; +using SixLabors.ImageSharp.Processing.Quantization.Processors; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Quantization { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of quantizing algorithms to the type. /// - public static partial class ImageExtensions + public static class QuantizeExtensions { /// /// Applies quantization to the image. @@ -24,17 +19,17 @@ namespace SixLabors.ImageSharp /// The quantization mode to apply to perform the operation. /// The maximum number of colors to return. Defaults to 256. /// The . - public static IImageProcessingContext Quantize(this IImageProcessingContext source, Quantization mode = Quantization.Octree, int maxColors = 256) + public static IImageProcessingContext Quantize(this IImageProcessingContext source, QuantizationMode mode = QuantizationMode.Octree, int maxColors = 256) where TPixel : struct, IPixel { IQuantizer quantizer; switch (mode) { - case Quantization.Wu: + case QuantizationMode.Wu: quantizer = new WuQuantizer(); break; - case Quantization.Palette: + case QuantizationMode.Palette: quantizer = new PaletteQuantizer(); break; @@ -56,34 +51,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Quantize(this IImageProcessingContext source, IQuantizer quantizer, int maxColors) where TPixel : struct, IPixel - { - return source.Apply(img => - { - // TODO : move helper logic into the processor - QuantizedImage quantized = quantizer.Quantize(img.Frames.RootFrame, maxColors); - int palleteCount = quantized.Palette.Length - 1; - - using (Buffer2D pixels = source.MemoryManager.Allocate2D(quantized.Width, quantized.Height)) - { - Parallel.For( - 0, - pixels.Height, - img.GetConfiguration().ParallelOptions, - y => - { - Span row = pixels.GetRowSpan(y); - int yy = y * pixels.Width; - for (int x = 0; x < pixels.Width; x++) - { - int i = x + yy; - TPixel color = quantized.Palette[Math.Min(palleteCount, quantized.Pixels[i])]; - row[x] = color; - } - }); - - Buffer2D.SwapContents(img.Frames[0].PixelBuffer, pixels); - } - }); - } + => source.ApplyProcessor(new QuantizeProcessor(quantizer, maxColors)); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Quantization/QuantizedImage{TPixel}.cs b/src/ImageSharp/Processing/Quantization/QuantizedFrame{TPixel}.cs similarity index 73% rename from src/ImageSharp/Processing/Quantization/QuantizedImage{TPixel}.cs rename to src/ImageSharp/Processing/Quantization/QuantizedFrame{TPixel}.cs index 52cf1a8d9..ac87e1c7c 100644 --- a/src/ImageSharp/Processing/Quantization/QuantizedImage{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/QuantizedFrame{TPixel}.cs @@ -4,23 +4,23 @@ using System; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Quantizers +namespace SixLabors.ImageSharp.Processing.Quantization { /// - /// Represents a quantized image where the pixels indexed by a color palette. + /// Represents a quantized image frame where the pixels indexed by a color palette. /// /// The pixel format. - public class QuantizedImage + public class QuantizedFrame where TPixel : struct, IPixel { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The image width. /// The image height. /// The color palette. /// The quantized pixels. - public QuantizedImage(int width, int height, TPixel[] palette, byte[] pixels) + public QuantizedFrame(int width, int height, TPixel[] palette, byte[] pixels) { Guard.MustBeGreaterThan(width, 0, nameof(width)); Guard.MustBeGreaterThan(height, 0, nameof(height)); @@ -39,22 +39,22 @@ namespace SixLabors.ImageSharp.Quantizers } /// - /// Gets the width of this . + /// Gets the width of this . /// public int Width { get; } /// - /// Gets the height of this . + /// Gets the height of this . /// public int Height { get; } /// - /// Gets the color palette of this . + /// Gets the color palette of this . /// public TPixel[] Palette { get; } /// - /// Gets the pixels of this . + /// Gets the pixels of this . /// public byte[] Pixels { get; } } diff --git a/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs b/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs index 84dfd8dd5..bda029332 100644 --- a/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs @@ -9,7 +9,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Quantizers.Base +namespace SixLabors.ImageSharp.Processing.Quantization { /// /// Encapsulates methods to calculate the color palette of an image. @@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Quantizers.Base public IErrorDiffuser DitherType { get; set; } = Diffusers.FloydSteinberg; /// - public virtual QuantizedImage Quantize(ImageFrame image, int maxColors) + public virtual QuantizedFrame Quantize(ImageFrame image, int maxColors) { Guard.NotNull(image, nameof(image)); @@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.Quantizers.Base this.SecondPass(image, quantizedPixels, width, height); } - return new QuantizedImage(width, height, colorPalette, quantizedPixels); + return new QuantizedFrame(width, height, colorPalette, quantizedPixels); } /// @@ -90,18 +90,6 @@ namespace SixLabors.ImageSharp.Quantizers.Base /// The height in pixels of the image. protected virtual void FirstPass(ImageFrame source, int width, int height) { - // Loop through each row - for (int y = 0; y < height; y++) - { - Span row = source.GetPixelRowSpan(y); - - // And loop through each column - for (int x = 0; x < width; x++) - { - // Now I have the pixel, call the FirstPassQuantize function... - this.InitialQuantizePixel(row[x]); - } - } } /// @@ -113,19 +101,6 @@ namespace SixLabors.ImageSharp.Quantizers.Base /// The height in pixels of the image protected abstract void SecondPass(ImageFrame source, byte[] output, int width, int height); - /// - /// Override this to process the pixel in the first pass of the algorithm - /// TODO: We really should do this on a per-row basis! Shouldn't we internalize this method? - /// - /// The pixel to quantize - /// - /// This function need only be overridden if your quantize algorithm needs two passes, - /// such as an Octree quantizer. - /// - protected virtual void InitialQuantizePixel(TPixel pixel) - { - } - /// /// Retrieve the palette for the quantized image. Can be called more than once so make sure calls are cached. /// diff --git a/src/ImageSharp/Processing/Quantization/WuQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/WuQuantizer{TPixel}.cs index 0aadf4973..0c2371cf3 100644 --- a/src/ImageSharp/Processing/Quantization/WuQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/WuQuantizer{TPixel}.cs @@ -2,16 +2,15 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Buffers; using System.Collections.Generic; using System.Numerics; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Quantizers.Base; -namespace SixLabors.ImageSharp.Quantizers +namespace SixLabors.ImageSharp.Processing.Quantization { /// /// An implementation of Wu's color quantizer with alpha channel. @@ -137,7 +136,7 @@ namespace SixLabors.ImageSharp.Quantizers } /// - public override QuantizedImage Quantize(ImageFrame image, int maxColors) + public override QuantizedFrame Quantize(ImageFrame image, int maxColors) { Guard.NotNull(image, nameof(image)); @@ -199,14 +198,13 @@ namespace SixLabors.ImageSharp.Quantizers return this.palette; } - /// - protected override void InitialQuantizePixel(TPixel pixel) + /// + /// Quantizes the pixel + /// + /// The rgba used to quantize the pixel input + private void QuantizePixel(ref Rgba32 rgba) { // Add the color to a 3-D color histogram. - // Colors are expected in r->g->b->a format - var rgba = default(Rgba32); - pixel.ToRgba32(ref rgba); - int r = rgba.R >> (8 - IndexBits); int g = rgba.G >> (8 - IndexBits); int b = rgba.B >> (8 - IndexBits); @@ -238,11 +236,16 @@ namespace SixLabors.ImageSharp.Quantizers // Loop through each row for (int y = 0; y < height; y++) { + Span row = source.GetPixelRowSpan(y); + ref TPixel scanBaseRef = ref MemoryMarshal.GetReference(row); + // And loop through each column + var rgba = default(Rgba32); for (int x = 0; x < width; x++) { - // Now I have the pixel, call the FirstPassQuantize function... - this.InitialQuantizePixel(source[x, y]); + ref TPixel pixel = ref Unsafe.Add(ref scanBaseRef, x); + pixel.ToRgba32(ref rgba); + this.QuantizePixel(ref rgba); } } diff --git a/src/ImageSharp/Processing/Transforms/Processors/AutoOrientProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/AutoOrientProcessor.cs index a0a5bfa77..fdb58918a 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/AutoOrientProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/AutoOrientProcessor.cs @@ -4,6 +4,7 @@ using System; using SixLabors.ImageSharp.MetaData.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms.Processors diff --git a/src/ImageSharp/Processing/Transforms/Processors/EntropyCropProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/EntropyCropProcessor.cs index 668d73690..66b781517 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/EntropyCropProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/EntropyCropProcessor.cs @@ -5,6 +5,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Binarization.Processors; using SixLabors.ImageSharp.Processing.Convolution.Processors; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms.Processors diff --git a/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs index 28c1c9794..9d945a869 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs @@ -7,6 +7,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms.Processors diff --git a/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs b/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs index e5eb29544..a8368e99b 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs @@ -10,9 +10,8 @@ namespace SixLabors.ImageSharp.Benchmarks.Image using BenchmarkDotNet.Attributes; using SixLabors.ImageSharp; - using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Png; - using SixLabors.ImageSharp.Quantizers; + using SixLabors.ImageSharp.Processing.Quantization; using CoreImage = ImageSharp.Image; diff --git a/tests/ImageSharp.Benchmarks/Image/EncodePng.cs b/tests/ImageSharp.Benchmarks/Image/EncodePng.cs index 53522a51f..f81cc4d85 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodePng.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodePng.cs @@ -11,8 +11,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Image using BenchmarkDotNet.Attributes; using SixLabors.ImageSharp.Formats.Png; - using SixLabors.ImageSharp.Quantizers; - using SixLabors.ImageSharp.Quantizers.Base; + using SixLabors.ImageSharp.Processing.Quantization; using SixLabors.ImageSharp.Tests; using CoreImage = ImageSharp.Image; diff --git a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs index 2771aa2e0..261241a69 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs @@ -19,6 +19,7 @@ namespace SixLabors.ImageSharp.Benchmarks using SixLabors.Primitives; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Processing.Overlays.Processors; + using SixLabors.ImageSharp.Processing.Processors; public class Glow : BenchmarkBase { diff --git a/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs b/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs index db1e7903d..294cbc0a1 100644 --- a/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs +++ b/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs @@ -7,6 +7,8 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Tests diff --git a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs index 463d5c7d8..b78a8083e 100644 --- a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs +++ b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs @@ -15,6 +15,7 @@ namespace SixLabors.ImageSharp.Tests using System; using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Quantization; public class GeneralFormatTests : FileTestBase { @@ -73,7 +74,7 @@ namespace SixLabors.ImageSharp.Tests { using (FileStream output = File.OpenWrite($"{path}/Octree-{file.FileName}")) { - image.Mutate(x => x.Quantize(Quantization.Octree)); + image.Mutate(x => x.Quantize(QuantizationMode.Octree)); image.Save(output, mimeType); } @@ -83,7 +84,7 @@ namespace SixLabors.ImageSharp.Tests { using (FileStream output = File.OpenWrite($"{path}/Wu-{file.FileName}")) { - image.Mutate(x => x.Quantize(Quantization.Wu)); + image.Mutate(x => x.Quantize(QuantizationMode.Wu)); image.Save(output, mimeType); } } @@ -92,7 +93,7 @@ namespace SixLabors.ImageSharp.Tests { using (FileStream output = File.OpenWrite($"{path}/Palette-{file.FileName}")) { - image.Mutate(x => x.Quantize(Quantization.Palette)); + image.Mutate(x => x.Quantize(QuantizationMode.Palette)); image.Save(output, mimeType); } } diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index d2ea982ae..7f983e1e4 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -1,13 +1,11 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Collections.Generic; using System.IO; using System.Linq; -using System.Threading.Tasks; + using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Png; -using SixLabors.ImageSharp.IO; using SixLabors.ImageSharp.PixelFormats; using Xunit; // ReSharper disable InconsistentNaming @@ -15,7 +13,6 @@ using Xunit; namespace SixLabors.ImageSharp.Tests { using SixLabors.ImageSharp.Processing; - using SixLabors.ImageSharp.Quantizers; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; public class PngEncoderTests diff --git a/tests/ImageSharp.Tests/ImageOperationTests.cs b/tests/ImageSharp.Tests/ImageOperationTests.cs index a5d6d2eb9..5bc846c3b 100644 --- a/tests/ImageSharp.Tests/ImageOperationTests.cs +++ b/tests/ImageSharp.Tests/ImageOperationTests.cs @@ -2,15 +2,12 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Collections.Generic; -using System.IO; using System.Linq; -using SixLabors.ImageSharp.Formats; -using SixLabors.ImageSharp.IO; -using SixLabors.ImageSharp.PixelFormats; + using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Processors; using Moq; -using SixLabors.Primitives; + using Xunit; namespace SixLabors.ImageSharp.Tests @@ -42,7 +39,7 @@ namespace SixLabors.ImageSharp.Tests this.image.Mutate(x => x.ApplyProcessor(this.processor)); Assert.True(this.provider.HasCreated(this.image)); - Assert.Contains(this.processor, this.provider.AppliedOperations(this.image).Select(x=>x.Processor)); + Assert.Contains(this.processor, this.provider.AppliedOperations(this.image).Select(x => x.Processor)); } [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs b/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs index d1e592c73..cfe716c73 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters { using SixLabors.ImageSharp.Processing.Filters; using SixLabors.ImageSharp.Processing.Filters.Processors; + using SixLabors.ImageSharp.Processing.Processors; public class ColorBlindnessTest : BaseImageOperationsExtensionTest { diff --git a/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs b/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs index 519589445..ee649eaa6 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters { using SixLabors.ImageSharp.Processing.Filters; using SixLabors.ImageSharp.Processing.Filters.Processors; + using SixLabors.ImageSharp.Processing.Processors; public class GrayscaleTest : BaseImageOperationsExtensionTest { diff --git a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs index 18fd29237..8ca04ac23 100644 --- a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs +++ b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs @@ -1,7 +1,7 @@ namespace SixLabors.ImageSharp.Tests { using SixLabors.ImageSharp.PixelFormats; - using SixLabors.ImageSharp.Quantizers; + using SixLabors.ImageSharp.Processing.Quantization; using Xunit; @@ -33,7 +33,7 @@ foreach (ImageFrame frame in image.Frames) { - QuantizedImage quantized = quantizer.Quantize(frame, 256); + QuantizedFrame quantized = quantizer.Quantize(frame, 256); int index = this.GetTransparentIndex(quantized); Assert.Equal(index, quantized.Pixels[0]); @@ -55,7 +55,7 @@ foreach (ImageFrame frame in image.Frames) { - QuantizedImage quantized = quantizer.Quantize(frame, 256); + QuantizedFrame quantized = quantizer.Quantize(frame, 256); int index = this.GetTransparentIndex(quantized); Assert.Equal(index, quantized.Pixels[0]); @@ -77,7 +77,7 @@ foreach (ImageFrame frame in image.Frames) { - QuantizedImage quantized = quantizer.Quantize(frame, 256); + QuantizedFrame quantized = quantizer.Quantize(frame, 256); int index = this.GetTransparentIndex(quantized); Assert.Equal(index, quantized.Pixels[0]); @@ -85,7 +85,7 @@ } } - private int GetTransparentIndex(QuantizedImage quantized) + private int GetTransparentIndex(QuantizedFrame quantized) where TPixel : struct, IPixel { // Transparent pixels are much more likely to be found at the end of a palette