From 13fa40874e3153ab939c77e7d6ac18e62d023412 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 7 Mar 2018 00:37:21 +1100 Subject: [PATCH 01/18] Binarization, Convolution, DIthering, Effects & Filters --- ImageSharp.ruleset | 2 + .../Processors/DrawImageProcessor.cs | 2 +- .../Processors/FillProcessor.cs | 2 +- .../Processors/FillRegionProcessor.cs | 2 +- .../{KnownDiffusers.cs => Diffusers.cs} | 2 +- .../{KnownDitherers.cs => Ditherers.cs} | 2 +- .../JpegColorConverter.FromGrayScale.cs | 6 +- .../ColorConverters/JpegColorConverter.cs | 2 +- .../Jpeg/Common/Decoder/JpegColorSpace.cs | 2 +- .../Jpeg/GolangPort/OrigJpegDecoderCore.cs | 6 +- src/ImageSharp/Formats/Png/PngDecoder.cs | 4 +- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 2 +- src/ImageSharp/IImageProcessor.cs | 2 +- src/ImageSharp/ImageSharp.csproj | 5 +- src/ImageSharp/Numerics/ValueSize.cs | 10 +- ...yDiffuse.cs => BinaryDiffuseExtensions.cs} | 28 ++-- ...aryDither.cs => BinaryDitherExtensions.cs} | 28 ++-- ...eshold.cs => BinaryThresholdExtensions.cs} | 28 ++-- .../BinaryErrorDiffusionProcessor.cs | 4 +- .../BinaryOrderedDitherProcessor.cs | 4 +- .../Processors}/BinaryThresholdProcessor.cs | 4 +- .../Processing/ColorMatrix/Lomograph.cs | 75 ---------- .../Processing/ColorMatrix/Polaroid.cs | 75 ---------- .../{BoxBlur.cs => BoxBlurExtensions.cs} | 13 +- ...etectEdges.cs => DetectEdgesExtensions.cs} | 72 +++++----- ...Detection.cs => EdgeDetectionOperators.cs} | 14 +- ...ssianBlur.cs => GaussianBlurExtensions.cs} | 12 +- ...harpen.cs => GaussianSharpenExtensions.cs} | 12 +- .../Processors}/BoxBlurProcessor.cs | 8 +- .../Processors}/Convolution2DProcessor.cs | 4 +- .../Processors}/Convolution2PassProcessor.cs | 4 +- .../Processors}/ConvolutionProcessor.cs | 4 +- .../Processors}/EdgeDetector2DProcessor.cs | 15 +- .../EdgeDetectorCompassProcessor.cs | 22 ++- .../Processors}/EdgeDetectorProcessor.cs | 17 ++- .../Processors}/GaussianBlurProcessor.cs | 24 ++-- .../Processors}/GaussianSharpenProcessor.cs | 26 ++-- .../Processors}/IEdgeDetectorProcessor.cs | 7 +- .../Convolution/Processors/KayyaliKernels.cs | 35 +++++ .../Processors/KayyaliProcessor.cs | 24 ++++ .../Convolution/Processors/KirschProcessor.cs | 49 +++++++ .../Convolution/Processors/KirshKernels.cs | 101 ++++++++++++++ .../Processors/Laplacian3x3Processor.cs | 25 ++++ .../Processors/Laplacian5x5Processor.cs | 25 ++++ .../Processors/LaplacianKernelFactory.cs | 40 ++++++ .../Processors/LaplacianKernels.cs | 36 +++++ .../LaplacianOfGaussianProcessor.cs | 25 ++++ .../Convolution/Processors/PrewittKernels.cs | 35 +++++ .../Processors/PrewittProcessor.cs | 25 ++++ .../Processors/RobertsCrossKernels.cs | 33 +++++ .../Processors/RobertsCrossProcessor.cs | 25 ++++ .../Convolution/Processors/RobinsonKernels.cs | 101 ++++++++++++++ .../Processors/RobinsonProcessor.cs | 50 +++++++ .../Convolution/Processors/ScharrKernels.cs | 35 +++++ .../Convolution/Processors/ScharrProcessor.cs | 25 ++++ .../Convolution/Processors/SobelKernels.cs | 35 +++++ .../Convolution/Processors/SobelProcessor.cs | 26 ++++ .../{Diffuse.cs => DiffuseExtensions.cs} | 10 +- .../{Dither.cs => DitherExtensions.cs} | 10 +- .../ErrorDiffusionPaletteProcessor.cs | 4 +- .../OrderedDitherPaletteProcessor.cs | 4 +- .../Processors}/PaletteDitherProcessorBase.cs | 4 +- .../Processors}/PixelPair.cs | 2 +- .../{OilPainting.cs => OilPaintExtensions.cs} | 21 ++- .../{Pixelate.cs => PixelateExtensions.cs} | 15 +- .../Processors}/OilPaintingProcessor.cs | 6 +- .../Processors}/PixelateProcessor.cs | 6 +- .../BlackWhiteExtensions.cs} | 18 +-- .../BrightnessExtensions.cs} | 13 +- .../Options => Filters}/ColorBlindness.cs | 2 +- .../ColorBlindnessExtensions.cs} | 24 ++-- .../ContrastExtensions.cs} | 12 +- .../Filter.cs => Filters/FilterExtensions.cs} | 18 +-- .../GrayscaleExtensions.cs} | 33 +++-- .../Options => Filters}/GrayscaleMode.cs | 6 +- .../Hue.cs => Filters/HueExtensions.cs} | 20 +-- .../Invert.cs => Filters/InvertExtensions.cs} | 15 +- .../KodachromeExtensions.cs} | 20 +-- .../Processing/Filters/LomographExtensions.cs | 38 +++++ .../{ColorMatrix => Filters}/MatrixFilters.cs | 8 +- .../OpacityExtensions.cs} | 13 +- .../Processing/Filters/PolaroidExtensions.cs | 38 +++++ .../Processors}/AchromatomalyProcessor.cs | 2 +- .../Processors}/AchromatopsiaProcessor.cs | 2 +- .../Processors}/BlackWhiteProcessor.cs | 2 +- .../Processors}/BrightnessProcessor.cs | 4 +- .../Processors}/ContrastProcessor.cs | 4 +- .../Processors}/DeuteranomalyProcessor.cs | 2 +- .../Processors}/DeuteranopiaProcessor.cs | 2 +- .../Processors}/FilterProcessor.cs | 4 +- .../Processors}/GrayscaleBt601Processor.cs | 4 +- .../Processors}/GrayscaleBt709Processor.cs | 2 +- .../Processors}/HueProcessor.cs | 2 +- .../Processors}/InvertProcessor.cs | 2 +- .../Processors}/KodachromeProcessor.cs | 2 +- .../Filters/Processors/LomographProcessor.cs | 33 +++++ .../Processors}/OpacityProcessor.cs | 2 +- .../Filters/Processors/PolaroidProcessor.cs | 35 +++++ .../Processors}/ProtanomalyProcessor.cs | 2 +- .../Processors}/ProtanopiaProcessor.cs | 3 +- .../Processors}/README.md | 0 .../Processors}/SaturateProcessor.cs | 4 +- .../Processors}/SepiaProcessor.cs | 2 +- .../Processors}/TritanomalyProcessor.cs | 2 +- .../Processors}/TritanopiaProcessor.cs | 2 +- .../SaturateExtensions.cs} | 20 +-- .../Sepia.cs => Filters/SepiaExtensions.cs} | 8 +- .../{Effects => Overlays}/BackgroundColor.cs | 0 src/ImageSharp/Processing/Overlays/Glow.cs | 5 +- .../Processing/Overlays/Vignette.cs | 5 +- .../Processors/CloningImageProcessor.cs | 15 +- .../EdgeDetection/KayyaliProcessor.cs | 50 ------- .../EdgeDetection/KirschProcessor.cs | 132 ------------------ .../EdgeDetection/Laplacian3X3Processor.cs | 39 ------ .../EdgeDetection/Laplacian5X5Processor.cs | 41 ------ .../LaplacianOfGaussianProcessor.cs | 41 ------ .../EdgeDetection/PrewittProcessor.cs | 50 ------- .../EdgeDetection/RobertsCrossProcessor.cs | 48 ------- .../EdgeDetection/RobinsonProcessor.cs | 132 ------------------ .../EdgeDetection/ScharrProcessor.cs | 50 ------- .../EdgeDetection/SobelProcessor.cs | 50 ------- .../Processors/DelegateProcessor.cs | 2 +- .../Processors/Filters/LomographProcessor.cs | 43 ------ .../Processors/Filters/PolaroidProcessor.cs | 43 ------ .../Processing/Processors/ImageProcessor.cs | 12 +- .../BackgroundColorProcessor.cs | 16 +-- .../Processors/Overlays/GlowProcessor.cs | 51 ++++--- .../Processors/Overlays/VignetteProcessor.cs | 62 ++++---- .../Transforms/AffineTransformProcessor.cs | 2 +- .../Transforms/AutoOrientProcessor.cs | 2 +- .../Processors/Transforms/CropProcessor.cs | 2 +- .../Transforms/EntropyCropProcessor.cs | 6 +- .../Processors/Transforms/FlipProcessor.cs | 2 +- .../ProjectiveTransformProcessor.cs | 2 +- .../Processors/Transforms/ResizeProcessor.cs | 8 +- .../Processors/Transforms/RotateProcessor.cs | 6 +- .../Processors/Transforms/SkewProcessor.cs | 2 +- .../Transforms/Options/ResizeOptions.cs | 2 +- src/ImageSharp/Processing/Transforms/Pad.cs | 2 +- .../{KnownResamplers.cs => Resamplers.cs} | 2 +- .../Processing/Transforms/Resize.cs | 8 +- .../Processing/Transforms/Rotate.cs | 2 +- src/ImageSharp/Processing/Transforms/Skew.cs | 2 +- .../Processing/Transforms/Transform.cs | 4 +- .../Quantizers/QuantizerBase{TPixel}.cs | 2 +- .../Samplers/DetectEdges.cs | 23 +-- tests/ImageSharp.Benchmarks/Samplers/Glow.cs | 5 +- .../ImageSharp.Tests/Drawing/DrawImageTest.cs | 2 +- .../Formats/Jpg/JpegColorConverterTests.cs | 2 +- .../Formats/Jpg/ParseStreamTests.cs | 2 +- .../Binarization/BinaryDitherTest.cs | 7 +- .../Binarization/BinaryThresholdTest.cs | 3 + .../Processing/Convolution/BoxBlurTest.cs | 3 + .../Processing/Convolution/DetectEdgesTest.cs | 27 ++-- .../Convolution/GaussianBlurTest.cs | 3 + .../Convolution/GaussianSharpenTest.cs | 3 + .../Processing/Dithering/DitherTest.cs | 7 +- .../Processing/Effects/OilPaintTest.cs | 3 + .../Processing/Effects/PixelateTest.cs | 3 + .../Processing/Filters/BlackWhiteTest.cs | 3 + .../Processing/Filters/BrightnessTest.cs | 3 + .../Processing/Filters/ColorBlindnessTest.cs | 9 +- .../Processing/Filters/ContrastTest.cs | 3 + .../Processing/Filters/FilterTest.cs | 3 + .../Processing/Filters/GrayscaleTest.cs | 10 +- .../Processing/Filters/HueTest.cs | 3 + .../Processing/Filters/InvertTest.cs | 3 + .../Processing/Filters/KodachromeTest.cs | 3 + .../Processing/Filters/LomographTest.cs | 3 + .../Processing/Filters/OpacityTest.cs | 3 + .../Processing/Filters/PolaroidTest.cs | 3 + .../Processing/Filters/SaturateTest.cs | 3 + .../Processing/Filters/SepiaTest.cs | 3 + .../Processing/Overlays/GlowTest.cs | 2 + .../Processing/Overlays/VignetteTest.cs | 2 + .../Binarization/BinaryDitherTests.cs | 32 +++-- .../Binarization/BinaryThresholdTest.cs | 2 + .../Processors/Convolution/BoxBlurTest.cs | 2 + .../Processors/Convolution/DetectEdgesTest.cs | 26 ++-- .../Convolution/GaussianBlurTest.cs | 2 + .../Convolution/GaussianSharpenTest.cs | 2 + .../Processors/Dithering/DitherTests.cs | 32 +++-- .../Processors/Effects/OilPaintTest.cs | 2 + .../Processors/Effects/PixelateTest.cs | 2 + .../Processors/Filters/BlackWhiteTest.cs | 2 + .../Processors/Filters/BrightnessTest.cs | 2 + .../Processors/Filters/ColorBlindnessTest.cs | 2 + .../Processors/Filters/ContrastTest.cs | 2 + .../Processors/Filters/FilterTest.cs | 2 + .../Processors/Filters/GrayscaleTest.cs | 2 + .../Processing/Processors/Filters/HueTest.cs | 2 + .../Processors/Filters/InvertTest.cs | 2 + .../Processors/Filters/KodachromeTest.cs | 2 + .../Processors/Filters/LomographTest.cs | 2 + .../Processors/Filters/OpacityTest.cs | 2 + .../Processors/Filters/PolaroidTest.cs | 2 + .../Processors/Filters/SaturateTest.cs | 2 + .../Processors/Filters/SepiaTest.cs | 2 + .../Transforms/ResizeProfilingBenchmarks.cs | 2 +- .../Processors/Transforms/ResizeTests.cs | 38 ++--- .../Processors/Transforms/SkewTest.cs | 32 ++--- .../Transforms/AffineTransformTests.cs | 48 +++---- .../Processing/Transforms/PadTest.cs | 2 +- .../Processing/Transforms/ResizeTests.cs | 6 +- .../Tests/TestUtilityExtensionsTests.cs | 2 + tests/Images/External | 2 +- 206 files changed, 1621 insertions(+), 1544 deletions(-) rename src/ImageSharp/Dithering/ErrorDiffusion/{KnownDiffusers.cs => Diffusers.cs} (98%) rename src/ImageSharp/Dithering/Ordered/{KnownDitherers.cs => Ditherers.cs} (97%) rename src/ImageSharp/Processing/Binarization/{BinaryDiffuse.cs => BinaryDiffuseExtensions.cs} (82%) rename src/ImageSharp/Processing/Binarization/{BinaryDither.cs => BinaryDitherExtensions.cs} (81%) rename src/ImageSharp/Processing/Binarization/{BinaryThreshold.cs => BinaryThresholdExtensions.cs} (82%) rename src/ImageSharp/Processing/{Processors/Binarization => Binarization/Processors}/BinaryErrorDiffusionProcessor.cs (96%) rename src/ImageSharp/Processing/{Processors/Binarization => Binarization/Processors}/BinaryOrderedDitherProcessor.cs (95%) rename src/ImageSharp/Processing/{Processors/Binarization => Binarization/Processors}/BinaryThresholdProcessor.cs (94%) delete mode 100644 src/ImageSharp/Processing/ColorMatrix/Lomograph.cs delete mode 100644 src/ImageSharp/Processing/ColorMatrix/Polaroid.cs rename src/ImageSharp/Processing/Convolution/{BoxBlur.cs => BoxBlurExtensions.cs} (90%) rename src/ImageSharp/Processing/Convolution/{DetectEdges.cs => DetectEdgesExtensions.cs} (74%) rename src/ImageSharp/Processing/Convolution/{Options/EdgeDetection.cs => EdgeDetectionOperators.cs} (83%) rename src/ImageSharp/Processing/Convolution/{GaussianBlur.cs => GaussianBlurExtensions.cs} (89%) rename src/ImageSharp/Processing/Convolution/{GaussianSharpen.cs => GaussianSharpenExtensions.cs} (89%) rename src/ImageSharp/Processing/{Processors/Convolution => Convolution/Processors}/BoxBlurProcessor.cs (91%) rename src/ImageSharp/Processing/{Processors/Convolution => Convolution/Processors}/Convolution2DProcessor.cs (95%) rename src/ImageSharp/Processing/{Processors/Convolution => Convolution/Processors}/Convolution2PassProcessor.cs (95%) rename src/ImageSharp/Processing/{Processors/Convolution => Convolution/Processors}/ConvolutionProcessor.cs (94%) rename src/ImageSharp/Processing/{Processors/Convolution/EdgeDetection => Convolution/Processors}/EdgeDetector2DProcessor.cs (69%) rename src/ImageSharp/Processing/{Processors/Convolution/EdgeDetection => Convolution/Processors}/EdgeDetectorCompassProcessor.cs (83%) rename src/ImageSharp/Processing/{Processors/Convolution/EdgeDetection => Convolution/Processors}/EdgeDetectorProcessor.cs (64%) rename src/ImageSharp/Processing/{Processors/Convolution => Convolution/Processors}/GaussianBlurProcessor.cs (88%) rename src/ImageSharp/Processing/{Processors/Convolution => Convolution/Processors}/GaussianSharpenProcessor.cs (89%) rename src/ImageSharp/Processing/{Processors/Convolution/EdgeDetection => Convolution/Processors}/IEdgeDetectorProcessor.cs (77%) create mode 100644 src/ImageSharp/Processing/Convolution/Processors/KayyaliKernels.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/KayyaliProcessor.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/KirschProcessor.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/KirshKernels.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/Laplacian3x3Processor.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/Laplacian5x5Processor.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/LaplacianKernelFactory.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/LaplacianKernels.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/LaplacianOfGaussianProcessor.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/PrewittKernels.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/PrewittProcessor.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/RobertsCrossKernels.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/RobertsCrossProcessor.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/RobinsonKernels.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/RobinsonProcessor.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/ScharrKernels.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/ScharrProcessor.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/SobelKernels.cs create mode 100644 src/ImageSharp/Processing/Convolution/Processors/SobelProcessor.cs rename src/ImageSharp/Processing/Dithering/{Diffuse.cs => DiffuseExtensions.cs} (95%) rename src/ImageSharp/Processing/Dithering/{Dither.cs => DitherExtensions.cs} (94%) rename src/ImageSharp/Processing/{Processors/Dithering => Dithering/Processors}/ErrorDiffusionPaletteProcessor.cs (96%) rename src/ImageSharp/Processing/{Processors/Dithering => Dithering/Processors}/OrderedDitherPaletteProcessor.cs (95%) rename src/ImageSharp/Processing/{Processors/Dithering => Dithering/Processors}/PaletteDitherProcessorBase.cs (95%) rename src/ImageSharp/Processing/{Processors/Dithering => Dithering/Processors}/PixelPair.cs (96%) rename src/ImageSharp/Processing/Effects/{OilPainting.cs => OilPaintExtensions.cs} (86%) rename src/ImageSharp/Processing/Effects/{Pixelate.cs => PixelateExtensions.cs} (81%) rename src/ImageSharp/Processing/{Processors/Effects => Effects/Processors}/OilPaintingProcessor.cs (95%) rename src/ImageSharp/Processing/{Processors/Effects => Effects/Processors}/PixelateProcessor.cs (93%) rename src/ImageSharp/Processing/{ColorMatrix/BlackWhite.cs => Filters/BlackWhiteExtensions.cs} (75%) rename src/ImageSharp/Processing/{ColorMatrix/Brightness.cs => Filters/BrightnessExtensions.cs} (83%) rename src/ImageSharp/Processing/{ColorMatrix/Options => Filters}/ColorBlindness.cs (95%) rename src/ImageSharp/Processing/{ColorMatrix/ColorBlindness.cs => Filters/ColorBlindnessExtensions.cs} (77%) rename src/ImageSharp/Processing/{ColorMatrix/Contrast.cs => Filters/ContrastExtensions.cs} (83%) rename src/ImageSharp/Processing/{ColorMatrix/Filter.cs => Filters/FilterExtensions.cs} (77%) rename src/ImageSharp/Processing/{ColorMatrix/Grayscale.cs => Filters/GrayscaleExtensions.cs} (86%) rename src/ImageSharp/Processing/{ColorMatrix/Options => Filters}/GrayscaleMode.cs (77%) rename src/ImageSharp/Processing/{ColorMatrix/Hue.cs => Filters/HueExtensions.cs} (75%) rename src/ImageSharp/Processing/{Effects/Invert.cs => Filters/InvertExtensions.cs} (76%) rename src/ImageSharp/Processing/{ColorMatrix/Kodachrome.cs => Filters/KodachromeExtensions.cs} (74%) create mode 100644 src/ImageSharp/Processing/Filters/LomographExtensions.cs rename src/ImageSharp/Processing/{ColorMatrix => Filters}/MatrixFilters.cs (98%) rename src/ImageSharp/Processing/{ColorMatrix/Opacity.cs => Filters/OpacityExtensions.cs} (78%) create mode 100644 src/ImageSharp/Processing/Filters/PolaroidExtensions.cs rename src/ImageSharp/Processing/{Processors/Filters/ColorBlindness => Filters/Processors}/AchromatomalyProcessor.cs (92%) rename src/ImageSharp/Processing/{Processors/Filters/ColorBlindness => Filters/Processors}/AchromatopsiaProcessor.cs (92%) rename src/ImageSharp/Processing/{Processors/Filters => Filters/Processors}/BlackWhiteProcessor.cs (91%) rename src/ImageSharp/Processing/{Processors/Filters => Filters/Processors}/BrightnessProcessor.cs (85%) rename src/ImageSharp/Processing/{Processors/Filters => Filters/Processors}/ContrastProcessor.cs (85%) rename src/ImageSharp/Processing/{Processors/Filters/ColorBlindness => Filters/Processors}/DeuteranomalyProcessor.cs (92%) rename src/ImageSharp/Processing/{Processors/Filters/ColorBlindness => Filters/Processors}/DeuteranopiaProcessor.cs (92%) rename src/ImageSharp/Processing/{Processors/Filters => Filters/Processors}/FilterProcessor.cs (91%) rename src/ImageSharp/Processing/{Processors/Filters => Filters/Processors}/GrayscaleBt601Processor.cs (88%) rename src/ImageSharp/Processing/{Processors/Filters => Filters/Processors}/GrayscaleBt709Processor.cs (94%) rename src/ImageSharp/Processing/{Processors/Filters => Filters/Processors}/HueProcessor.cs (93%) rename src/ImageSharp/Processing/{Processors/Filters => Filters/Processors}/InvertProcessor.cs (93%) rename src/ImageSharp/Processing/{Processors/Filters => Filters/Processors}/KodachromeProcessor.cs (92%) create mode 100644 src/ImageSharp/Processing/Filters/Processors/LomographProcessor.cs rename src/ImageSharp/Processing/{Processors/Filters => Filters/Processors}/OpacityProcessor.cs (93%) create mode 100644 src/ImageSharp/Processing/Filters/Processors/PolaroidProcessor.cs rename src/ImageSharp/Processing/{Processors/Filters/ColorBlindness => Filters/Processors}/ProtanomalyProcessor.cs (92%) rename src/ImageSharp/Processing/{Processors/Filters/ColorBlindness => Filters/Processors}/ProtanopiaProcessor.cs (90%) rename src/ImageSharp/Processing/{Processors/Filters/ColorBlindness => Filters/Processors}/README.md (100%) rename src/ImageSharp/Processing/{Processors/Filters => Filters/Processors}/SaturateProcessor.cs (86%) rename src/ImageSharp/Processing/{Processors/Filters => Filters/Processors}/SepiaProcessor.cs (93%) rename src/ImageSharp/Processing/{Processors/Filters/ColorBlindness => Filters/Processors}/TritanomalyProcessor.cs (92%) rename src/ImageSharp/Processing/{Processors/Filters/ColorBlindness => Filters/Processors}/TritanopiaProcessor.cs (92%) rename src/ImageSharp/Processing/{ColorMatrix/Saturate.cs => Filters/SaturateExtensions.cs} (82%) rename src/ImageSharp/Processing/{ColorMatrix/Sepia.cs => Filters/SepiaExtensions.cs} (91%) rename src/ImageSharp/Processing/{Effects => Overlays}/BackgroundColor.cs (100%) delete mode 100644 src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs delete mode 100644 src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs delete mode 100644 src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs delete mode 100644 src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs delete mode 100644 src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs delete mode 100644 src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs delete mode 100644 src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs delete mode 100644 src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs delete mode 100644 src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs delete mode 100644 src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs delete mode 100644 src/ImageSharp/Processing/Processors/Filters/LomographProcessor.cs delete mode 100644 src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs rename src/ImageSharp/Processing/Processors/{Effects => Overlays}/BackgroundColorProcessor.cs (86%) rename src/ImageSharp/Processing/Transforms/Resamplers/{KnownResamplers.cs => Resamplers.cs} (99%) diff --git a/ImageSharp.ruleset b/ImageSharp.ruleset index 2149364b1b..3567dc4b9e 100644 --- a/ImageSharp.ruleset +++ b/ImageSharp.ruleset @@ -7,5 +7,7 @@ temp remove the header requirement as stylecop is currently failing to read the stylecop.json file from 'dotnet build' --> + + \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs index 632b4d449d..46e27be78f 100644 --- a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Drawing.Processors public Point Location { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { Image targetImage = this.Image; PixelBlender blender = this.Blender; diff --git a/src/ImageSharp.Drawing/Processors/FillProcessor.cs b/src/ImageSharp.Drawing/Processors/FillProcessor.cs index 3bf18a37ba..b8cbddcba0 100644 --- a/src/ImageSharp.Drawing/Processors/FillProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/FillProcessor.cs @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Drawing.Processors } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { int startX = sourceRectangle.X; int endX = sourceRectangle.Right; diff --git a/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs b/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs index 076785526c..66a35f1517 100644 --- a/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Drawing.Processors public GraphicsOptions Options { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { Region region = this.Region; Rectangle rect = region.Bounds; diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/KnownDiffusers.cs b/src/ImageSharp/Dithering/ErrorDiffusion/Diffusers.cs similarity index 98% rename from src/ImageSharp/Dithering/ErrorDiffusion/KnownDiffusers.cs rename to src/ImageSharp/Dithering/ErrorDiffusion/Diffusers.cs index c75530b8e7..6e2055e34f 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/KnownDiffusers.cs +++ b/src/ImageSharp/Dithering/ErrorDiffusion/Diffusers.cs @@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Dithering /// /// Contains reusable static instances of known error diffusion algorithms /// - public static class KnownDiffusers + public static class Diffusers { /// /// Gets the error diffuser that implements the Atkinson algorithm. diff --git a/src/ImageSharp/Dithering/Ordered/KnownDitherers.cs b/src/ImageSharp/Dithering/Ordered/Ditherers.cs similarity index 97% rename from src/ImageSharp/Dithering/Ordered/KnownDitherers.cs rename to src/ImageSharp/Dithering/Ordered/Ditherers.cs index e58cbad8ab..53e94dca49 100644 --- a/src/ImageSharp/Dithering/Ordered/KnownDitherers.cs +++ b/src/ImageSharp/Dithering/Ordered/Ditherers.cs @@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Dithering /// /// Contains reusable static instances of known ordered dither matrices /// - public class KnownDitherers + public class Ditherers { /// /// Gets the order ditherer using the 2x2 Bayer dithering matrix diff --git a/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs b/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs index 5c720e61c3..4769bef1d7 100644 --- a/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs +++ b/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs @@ -8,10 +8,10 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder.ColorConverters { internal abstract partial class JpegColorConverter { - internal class FromGrayScale : ColorConverters.JpegColorConverter + internal class FromGrayscale : ColorConverters.JpegColorConverter { - public FromGrayScale() - : base(JpegColorSpace.GrayScale) + public FromGrayscale() + : base(JpegColorSpace.Grayscale) { } diff --git a/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.cs b/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.cs index 187b65f72b..4391be5484 100644 --- a/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.cs +++ b/src/ImageSharp/Formats/Jpeg/Common/Decoder/ColorConverters/JpegColorConverter.cs @@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder.ColorConverters /// private static readonly JpegColorConverter[] Converters = { - GetYCbCrConverter(), new FromYccK(), new FromCmyk(), new FromGrayScale(), new FromRgb() + GetYCbCrConverter(), new FromYccK(), new FromCmyk(), new FromGrayscale(), new FromRgb() }; /// diff --git a/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegColorSpace.cs b/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegColorSpace.cs index da353d2795..abc93727e1 100644 --- a/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegColorSpace.cs +++ b/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegColorSpace.cs @@ -7,7 +7,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder { Undefined = 0, - GrayScale, + Grayscale, Ycck, diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs index 6cc275d49d..d3d1efe7fd 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs @@ -640,7 +640,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort switch (remaining) { - case 6 + (3 * 1): // Grayscale image. + case 6 + (3 * 1): // grayscale image. this.ComponentCount = 1; break; case 6 + (3 * 3): // YCbCr or RGB image. @@ -767,7 +767,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort switch (this.ComponentCount) { case 1: - return JpegColorSpace.GrayScale; + return JpegColorSpace.Grayscale; case 3: if (!this.isAdobe || this.adobe.ColorTransform == OrigJpegConstants.Adobe.ColorTransformYCbCr) { @@ -790,7 +790,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort } throw new ImageFormatException($"Unsupported color mode. Max components 4; found {this.ComponentCount}." - + "JpegDecoder only supports YCbCr, RGB, YccK, CMYK and Grayscale color spaces."); + + "JpegDecoder only supports YCbCr, RGB, YccK, CMYK and grayscale color spaces."); } private Image PostProcessIntoImage() diff --git a/src/ImageSharp/Formats/Png/PngDecoder.cs b/src/ImageSharp/Formats/Png/PngDecoder.cs index 9bde4f8cc3..57d45ecddb 100644 --- a/src/ImageSharp/Formats/Png/PngDecoder.cs +++ b/src/ImageSharp/Formats/Png/PngDecoder.cs @@ -20,8 +20,8 @@ namespace SixLabors.ImageSharp.Formats.Png /// /// RGBA (True color) with alpha (8 bit). /// RGB (True color) without alpha (8 bit). - /// Grayscale with alpha (8 bit). - /// Grayscale without alpha (8 bit). + /// grayscale with alpha (8 bit). + /// grayscale without alpha (8 bit). /// Palette Index with alpha (8 bit). /// Palette Index without alpha (8 bit). /// diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 1d1db2787a..dba4eaa15c 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -170,7 +170,7 @@ namespace SixLabors.ImageSharp.Formats.Png private Rgb24 rgb24Trans; /// - /// Represents any color in a Grayscale encoded png that should be transparent + /// Represents any color in a grayscale encoded png that should be transparent /// private byte intensityTrans; diff --git a/src/ImageSharp/IImageProcessor.cs b/src/ImageSharp/IImageProcessor.cs index bd6df8d835..c7fb565cac 100644 --- a/src/ImageSharp/IImageProcessor.cs +++ b/src/ImageSharp/IImageProcessor.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp /// is null. /// /// - /// doesnt fit the dimension of the image. + /// doesn't fit the dimension of the image. /// void Apply(Image source, Rectangle sourceRectangle); } diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 86a0ab7ea5..4433836793 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -37,7 +37,7 @@ - + All @@ -126,7 +126,4 @@ PorterDuffFunctions.Generated.tt - - - \ No newline at end of file diff --git a/src/ImageSharp/Numerics/ValueSize.cs b/src/ImageSharp/Numerics/ValueSize.cs index fcf61a586d..02573816d9 100644 --- a/src/ImageSharp/Numerics/ValueSize.cs +++ b/src/ImageSharp/Numerics/ValueSize.cs @@ -61,9 +61,9 @@ namespace SixLabors.ImageSharp /// /// Implicitly converts a float into an absolute value /// - /// the vlaue to use as the absolute figure. - public static implicit operator ValueSize(float d) - => Absolute(d); + /// the value to use as the absolute figure. + public static implicit operator ValueSize(float f) + => Absolute(f); /// /// Create a new ValueSize with as a PercentageOfWidth type with value set to percentage. @@ -99,7 +99,7 @@ namespace SixLabors.ImageSharp /// Calculates the specified size. /// /// The size. - /// The calucalted value + /// The calculated value public float Calculate(Size size) { switch (this.Type) @@ -123,7 +123,7 @@ namespace SixLabors.ImageSharp /// public bool Equals(ValueSize other) { - return this.Type == other.Type && this.Value == other.Value; + return this.Type == other.Type && this.Value.Equals(other.Value); } } } diff --git a/src/ImageSharp/Processing/Binarization/BinaryDiffuse.cs b/src/ImageSharp/Processing/Binarization/BinaryDiffuseExtensions.cs similarity index 82% rename from src/ImageSharp/Processing/Binarization/BinaryDiffuse.cs rename to src/ImageSharp/Processing/Binarization/BinaryDiffuseExtensions.cs index eb50087570..d06a9b75be 100644 --- a/src/ImageSharp/Processing/Binarization/BinaryDiffuse.cs +++ b/src/ImageSharp/Processing/Binarization/BinaryDiffuseExtensions.cs @@ -3,15 +3,15 @@ using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Binarization.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Binarization { /// - /// Extension methods for the type. + /// Adds binary diffusion extensions to the type. /// - public static partial class ImageExtensions + public static class BinaryDiffuseExtensions { /// /// Dithers the image reducing it to two colors using error diffusion. @@ -23,10 +23,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDiffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold)); - return source; - } + => source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold)); /// /// Dithers the image reducing it to two colors using error diffusion. @@ -41,10 +38,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDiffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold), rectangle); - return source; - } + => source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold), rectangle); /// /// Dithers the image reducing it to two colors using error diffusion. @@ -58,10 +52,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDiffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold, TPixel upperColor, TPixel lowerColor) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold, upperColor, lowerColor)); - return source; - } + => source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold, upperColor, lowerColor)); /// /// Dithers the image reducing it to two colors using error diffusion. @@ -78,9 +69,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDiffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold, TPixel upperColor, TPixel lowerColor, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold, upperColor, lowerColor), rectangle); - return source; - } + => source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold, upperColor, lowerColor), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Binarization/BinaryDither.cs b/src/ImageSharp/Processing/Binarization/BinaryDitherExtensions.cs similarity index 81% rename from src/ImageSharp/Processing/Binarization/BinaryDither.cs rename to src/ImageSharp/Processing/Binarization/BinaryDitherExtensions.cs index 715dff472d..039fc57b7e 100644 --- a/src/ImageSharp/Processing/Binarization/BinaryDither.cs +++ b/src/ImageSharp/Processing/Binarization/BinaryDitherExtensions.cs @@ -3,15 +3,15 @@ using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Binarization.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Binarization { /// - /// Extension methods for the type. + /// Adds binary dithering extensions to the type. /// - public static partial class ImageExtensions + public static class BinaryDitherExtensions { /// /// Dithers the image reducing it to two colors using ordered dithering. @@ -22,10 +22,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDither(this IImageProcessingContext source, IOrderedDither dither) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither)); - return source; - } + => source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither)); /// /// Dithers the image reducing it to two colors using ordered dithering. @@ -38,10 +35,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDither(this IImageProcessingContext source, IOrderedDither dither, TPixel upperColor, TPixel lowerColor) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither, upperColor, lowerColor)); - return source; - } + => source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither, upperColor, lowerColor)); /// /// Dithers the image reducing it to two colors using ordered dithering. @@ -55,10 +49,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDither(this IImageProcessingContext source, IOrderedDither dither, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither), rectangle); - return source; - } + => source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither), rectangle); /// /// Dithers the image reducing it to two colors using ordered dithering. @@ -74,9 +65,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryDither(this IImageProcessingContext source, IOrderedDither dither, TPixel upperColor, TPixel lowerColor, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither, upperColor, lowerColor), rectangle); - return source; - } + => source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither, upperColor, lowerColor), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Binarization/BinaryThreshold.cs b/src/ImageSharp/Processing/Binarization/BinaryThresholdExtensions.cs similarity index 82% rename from src/ImageSharp/Processing/Binarization/BinaryThreshold.cs rename to src/ImageSharp/Processing/Binarization/BinaryThresholdExtensions.cs index 3f86528f51..0050613948 100644 --- a/src/ImageSharp/Processing/Binarization/BinaryThreshold.cs +++ b/src/ImageSharp/Processing/Binarization/BinaryThresholdExtensions.cs @@ -2,15 +2,15 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Binarization.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Binarization { /// - /// Extension methods for the type. + /// Adds binary thresholding extensions to the type. /// - public static partial class ImageExtensions + public static class BinaryThresholdExtensions { /// /// Applies binarization to the image splitting the pixels at the given threshold. @@ -21,10 +21,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryThresholdProcessor(threshold)); - return source; - } + => source.ApplyProcessor(new BinaryThresholdProcessor(threshold)); /// /// Applies binarization to the image splitting the pixels at the given threshold. @@ -38,10 +35,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryThresholdProcessor(threshold), rectangle); - return source; - } + => source.ApplyProcessor(new BinaryThresholdProcessor(threshold), rectangle); /// /// Applies binarization to the image splitting the pixels at the given threshold. @@ -54,10 +48,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold, TPixel upperColor, TPixel lowerColor) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor)); - return source; - } + => source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor)); /// /// Applies binarization to the image splitting the pixels at the given threshold. @@ -73,9 +64,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold, TPixel upperColor, TPixel lowerColor, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor), rectangle); - return source; - } + => source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor), rectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs similarity index 96% rename from src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor.cs rename to src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs index 80a4236452..9e96ddcde6 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs @@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Binarization.Processors { /// /// Performs binary threshold filtering against an image using error diffusion. @@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public TPixel LowerColor { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { float threshold = this.Threshold * 255F; var rgba = default(Rgba32); diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs similarity index 95% rename from src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs rename to src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs index baa8df8cca..8d72ba66fa 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs @@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Binarization.Processors { /// /// Performs binary threshold filtering against an image using ordered dithering. @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public TPixel LowerColor { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { var rgba = default(Rgba32); bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8); diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs similarity index 94% rename from src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs rename to src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs index 609b090923..39d829c73a 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs @@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Binarization.Processors { /// /// Performs simple binary threshold filtering against an image. @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public TPixel LowerColor { get; set; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { float threshold = this.Threshold * 255F; TPixel upper = this.UpperColor; diff --git a/src/ImageSharp/Processing/ColorMatrix/Lomograph.cs b/src/ImageSharp/Processing/ColorMatrix/Lomograph.cs deleted file mode 100644 index ca79841c76..0000000000 --- a/src/ImageSharp/Processing/ColorMatrix/Lomograph.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; -using SixLabors.Primitives; - -namespace SixLabors.ImageSharp -{ - /// - /// Extension methods for the type. - /// - public static partial class ImageExtensions - { - /// - /// Alters the colors of the image recreating an old Lomograph camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// The . - public static IImageProcessingContext Lomograph(this IImageProcessingContext source) - where TPixel : struct, IPixel - { - return Lomograph(source, GraphicsOptions.Default); - } - - /// - /// Alters the colors of the image recreating an old Lomograph camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// - /// The structure that specifies the portion of the image object to alter. - /// - /// The . - public static IImageProcessingContext Lomograph(this IImageProcessingContext source, Rectangle rectangle) - where TPixel : struct, IPixel - { - return Lomograph(source, rectangle, GraphicsOptions.Default); - } - - /// - /// Alters the colors of the image recreating an old Lomograph camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// The options effecting pixel blending. - /// The . - public static IImageProcessingContext Lomograph(this IImageProcessingContext source, GraphicsOptions options) - where TPixel : struct, IPixel - { - source.ApplyProcessor(new LomographProcessor(source.MemoryManager, options)); - return source; - } - - /// - /// Alters the colors of the image recreating an old Lomograph camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// - /// The structure that specifies the portion of the image object to alter. - /// - /// The options effecting pixel blending. - /// The . - public static IImageProcessingContext Lomograph(this IImageProcessingContext source, Rectangle rectangle, GraphicsOptions options) - where TPixel : struct, IPixel - { - source.ApplyProcessor(new LomographProcessor(source.MemoryManager, options), rectangle); - return source; - } - } -} diff --git a/src/ImageSharp/Processing/ColorMatrix/Polaroid.cs b/src/ImageSharp/Processing/ColorMatrix/Polaroid.cs deleted file mode 100644 index d12cc76122..0000000000 --- a/src/ImageSharp/Processing/ColorMatrix/Polaroid.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; -using SixLabors.Primitives; - -namespace SixLabors.ImageSharp -{ - /// - /// Extension methods for the type. - /// - public static partial class ImageExtensions - { - /// - /// Alters the colors of the image recreating an old Polaroid camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// The . - public static IImageProcessingContext Polaroid(this IImageProcessingContext source) - where TPixel : struct, IPixel - { - return Polaroid(source, GraphicsOptions.Default); - } - - /// - /// Alters the colors of the image recreating an old Polaroid camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// - /// The structure that specifies the portion of the image object to alter. - /// - /// The . - public static IImageProcessingContext Polaroid(this IImageProcessingContext source, Rectangle rectangle) - where TPixel : struct, IPixel - { - return Polaroid(source, rectangle, GraphicsOptions.Default); - } - - /// - /// Alters the colors of the image recreating an old Polaroid camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// The options effecting pixel blending. - /// The . - public static IImageProcessingContext Polaroid(this IImageProcessingContext source, GraphicsOptions options) - where TPixel : struct, IPixel - { - source.ApplyProcessor(new PolaroidProcessor(source.MemoryManager, options)); - return source; - } - - /// - /// Alters the colors of the image recreating an old Polaroid camera effect. - /// - /// The pixel format. - /// The image this method extends. - /// - /// The structure that specifies the portion of the image object to alter. - /// - /// The options effecting pixel blending. - /// The . - public static IImageProcessingContext Polaroid(this IImageProcessingContext source, Rectangle rectangle, GraphicsOptions options) - where TPixel : struct, IPixel - { - source.ApplyProcessor(new PolaroidProcessor(source.MemoryManager, options), rectangle); - return source; - } - } -} diff --git a/src/ImageSharp/Processing/Convolution/BoxBlur.cs b/src/ImageSharp/Processing/Convolution/BoxBlurExtensions.cs similarity index 90% rename from src/ImageSharp/Processing/Convolution/BoxBlur.cs rename to src/ImageSharp/Processing/Convolution/BoxBlurExtensions.cs index b0c6ffc8d2..edb798fb41 100644 --- a/src/ImageSharp/Processing/Convolution/BoxBlur.cs +++ b/src/ImageSharp/Processing/Convolution/BoxBlurExtensions.cs @@ -1,17 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Convolution.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Convolution { /// - /// Extension methods for the type. + /// Adds box blurring extensions to the type. /// - public static partial class ImageExtensions + public static class BoxBlurExtensions { /// /// Applies a box blur to the image. @@ -21,7 +20,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BoxBlur(this IImageProcessingContext source) where TPixel : struct, IPixel - => source.ApplyProcessor(new BoxBlurProcessor(7)); + => source.ApplyProcessor(new BoxBlurProcessor()); /// /// Applies a box blur to the image. @@ -48,4 +47,4 @@ namespace SixLabors.ImageSharp where TPixel : struct, IPixel => source.ApplyProcessor(new BoxBlurProcessor(radius), rectangle); } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/DetectEdges.cs b/src/ImageSharp/Processing/Convolution/DetectEdgesExtensions.cs similarity index 74% rename from src/ImageSharp/Processing/Convolution/DetectEdges.cs rename to src/ImageSharp/Processing/Convolution/DetectEdgesExtensions.cs index 79e7ac6cf4..a2b2b244bd 100644 --- a/src/ImageSharp/Processing/Convolution/DetectEdges.cs +++ b/src/ImageSharp/Processing/Convolution/DetectEdgesExtensions.cs @@ -1,35 +1,31 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Convolution.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Convolution { /// - /// Extension methods for the type. + /// Adds edge detection extensions to the type. /// - public static partial class ImageExtensions + public static class DetectEdgesExtensions { /// /// Detects any edges within the image. Uses the filter - /// operating in Grayscale mode. + /// operating in grayscale mode. /// /// The pixel format. /// The image this method extends. /// The . public static IImageProcessingContext DetectEdges(this IImageProcessingContext source) where TPixel : struct, IPixel - { - return DetectEdges(source, new SobelProcessor { Grayscale = true }); - } + => DetectEdges(source, new SobelProcessor(true)); /// /// Detects any edges within the image. Uses the filter - /// operating in Grayscale mode. + /// operating in grayscale mode. /// /// The pixel format. /// The image this method extends. @@ -39,9 +35,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, Rectangle rectangle) where TPixel : struct, IPixel - { - return DetectEdges(source, rectangle, new SobelProcessor { Grayscale = true }); - } + => DetectEdges(source, rectangle, new SobelProcessor(true)); /// /// Detects any edges within the image. @@ -50,7 +44,7 @@ namespace SixLabors.ImageSharp /// The image this method extends. /// The filter for detecting edges. /// The . - public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, EdgeDetection filter) + public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, EdgeDetectionOperators filter) where TPixel : struct, IPixel => DetectEdges(source, GetProcessor(filter, true)); @@ -60,9 +54,9 @@ namespace SixLabors.ImageSharp /// The pixel format. /// The image this method extends. /// The filter for detecting edges. - /// Whether to convert the image to Grayscale first. Defaults to true. + /// Whether to convert the image to grayscale first. Defaults to true. /// The . - public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, EdgeDetection filter, bool grayscale) + public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, EdgeDetectionOperators filter, bool grayscale) where TPixel : struct, IPixel => DetectEdges(source, GetProcessor(filter, grayscale)); @@ -75,9 +69,9 @@ namespace SixLabors.ImageSharp /// /// The structure that specifies the portion of the image object to alter. /// - /// Whether to convert the image to Grayscale first. Defaults to true. + /// Whether to convert the image to grayscale first. Defaults to true. /// The . - public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, EdgeDetection filter, Rectangle rectangle, bool grayscale = true) + public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, EdgeDetectionOperators filter, Rectangle rectangle, bool grayscale = true) where TPixel : struct, IPixel => DetectEdges(source, rectangle, GetProcessor(filter, grayscale)); @@ -111,51 +105,51 @@ namespace SixLabors.ImageSharp return source; } - private static IEdgeDetectorProcessor GetProcessor(EdgeDetection filter, bool grayscale) + private static IEdgeDetectorProcessor GetProcessor(EdgeDetectionOperators filter, bool grayscale) where TPixel : struct, IPixel { IEdgeDetectorProcessor processor; switch (filter) { - case EdgeDetection.Kayyali: - processor = new KayyaliProcessor { Grayscale = grayscale }; + case EdgeDetectionOperators.Kayyali: + processor = new KayyaliProcessor(grayscale); break; - case EdgeDetection.Kirsch: - processor = new KirschProcessor { Grayscale = grayscale }; + case EdgeDetectionOperators.Kirsch: + processor = new KirschProcessor(grayscale); break; - case EdgeDetection.Lapacian3X3: - processor = new Laplacian3X3Processor { Grayscale = grayscale }; + case EdgeDetectionOperators.Laplacian3x3: + processor = new Laplacian3x3Processor(grayscale); break; - case EdgeDetection.Lapacian5X5: - processor = new Laplacian5X5Processor { Grayscale = grayscale }; + case EdgeDetectionOperators.Laplacian5x5: + processor = new Laplacian5x5Processor(grayscale); break; - case EdgeDetection.LaplacianOfGaussian: - processor = new LaplacianOfGaussianProcessor { Grayscale = grayscale }; + case EdgeDetectionOperators.LaplacianOfGaussian: + processor = new LaplacianOfGaussianProcessor(grayscale); break; - case EdgeDetection.Prewitt: - processor = new PrewittProcessor { Grayscale = grayscale }; + case EdgeDetectionOperators.Prewitt: + processor = new PrewittProcessor(grayscale); break; - case EdgeDetection.RobertsCross: - processor = new RobertsCrossProcessor { Grayscale = grayscale }; + case EdgeDetectionOperators.RobertsCross: + processor = new RobertsCrossProcessor(grayscale); break; - case EdgeDetection.Robinson: - processor = new RobinsonProcessor { Grayscale = grayscale }; + case EdgeDetectionOperators.Robinson: + processor = new RobinsonProcessor(grayscale); break; - case EdgeDetection.Scharr: - processor = new ScharrProcessor { Grayscale = grayscale }; + case EdgeDetectionOperators.Scharr: + processor = new ScharrProcessor(grayscale); break; default: - processor = new SobelProcessor { Grayscale = grayscale }; + processor = new SobelProcessor(grayscale); break; } diff --git a/src/ImageSharp/Processing/Convolution/Options/EdgeDetection.cs b/src/ImageSharp/Processing/Convolution/EdgeDetectionOperators.cs similarity index 83% rename from src/ImageSharp/Processing/Convolution/Options/EdgeDetection.cs rename to src/ImageSharp/Processing/Convolution/EdgeDetectionOperators.cs index b01bb945cf..55cbbeaf7d 100644 --- a/src/ImageSharp/Processing/Convolution/Options/EdgeDetection.cs +++ b/src/ImageSharp/Processing/Convolution/EdgeDetectionOperators.cs @@ -1,12 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Convolution { /// /// Enumerates the various types of defined edge detection filters. /// - public enum EdgeDetection + public enum EdgeDetectionOperators { /// /// The Kayyali operator filter. @@ -19,14 +19,14 @@ namespace SixLabors.ImageSharp.Processing Kirsch, /// - /// The Lapacian3X3 operator filter. + /// The Laplacian3X3 operator filter. /// - Lapacian3X3, + Laplacian3x3, /// - /// The Lapacian5X5 operator filter. + /// The Laplacian5X5 operator filter. /// - Lapacian5X5, + Laplacian5x5, /// /// The LaplacianOfGaussian operator filter. @@ -58,4 +58,4 @@ namespace SixLabors.ImageSharp.Processing /// Sobel } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/GaussianBlur.cs b/src/ImageSharp/Processing/Convolution/GaussianBlurExtensions.cs similarity index 89% rename from src/ImageSharp/Processing/Convolution/GaussianBlur.cs rename to src/ImageSharp/Processing/Convolution/GaussianBlurExtensions.cs index 9bca97242c..ae3eace640 100644 --- a/src/ImageSharp/Processing/Convolution/GaussianBlur.cs +++ b/src/ImageSharp/Processing/Convolution/GaussianBlurExtensions.cs @@ -1,18 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Convolution.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Convolution { /// - /// Extension methods for the type. + /// Adds Gaussian blurring extensions to the type. /// - public static partial class ImageExtensions + public static class GaussianBlurExtensions { /// /// Applies a Gaussian blur to the image. @@ -22,7 +20,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext GaussianBlur(this IImageProcessingContext source) where TPixel : struct, IPixel - => source.ApplyProcessor(new GaussianBlurProcessor(3f)); + => source.ApplyProcessor(new GaussianBlurProcessor()); /// /// Applies a Gaussian blur to the image. diff --git a/src/ImageSharp/Processing/Convolution/GaussianSharpen.cs b/src/ImageSharp/Processing/Convolution/GaussianSharpenExtensions.cs similarity index 89% rename from src/ImageSharp/Processing/Convolution/GaussianSharpen.cs rename to src/ImageSharp/Processing/Convolution/GaussianSharpenExtensions.cs index 1cea2dae9b..334a02b79b 100644 --- a/src/ImageSharp/Processing/Convolution/GaussianSharpen.cs +++ b/src/ImageSharp/Processing/Convolution/GaussianSharpenExtensions.cs @@ -1,18 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Convolution.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Convolution { /// - /// Extension methods for the type. + /// Adds Gaussian sharpening extensions to the type. /// - public static partial class ImageExtensions + public static class GaussianSharpenExtensions { /// /// Applies a Gaussian sharpening filter to the image. @@ -22,7 +20,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext GaussianSharpen(this IImageProcessingContext source) where TPixel : struct, IPixel - => source.ApplyProcessor(new GaussianSharpenProcessor(3f)); + => source.ApplyProcessor(new GaussianSharpenProcessor()); /// /// Applies a Gaussian sharpening filter to the image. diff --git a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/BoxBlurProcessor.cs similarity index 91% rename from src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/BoxBlurProcessor.cs index 8056141a09..df3d56bdae 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/BoxBlurProcessor.cs @@ -1,15 +1,15 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// - /// Applies a Box blur sampler to the image. + /// Applies box blur processing to the image. /// /// The pixel format. internal class BoxBlurProcessor : ImageProcessor @@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Fast2DArray KernelY { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { new Convolution2PassProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle, configuration); } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs similarity index 95% rename from src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs index 2c13ead162..4e46984677 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs @@ -12,7 +12,7 @@ using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Processors { /// - /// Defines a sampler that uses two one-dimensional matrices to perform convolution against an image. + /// Defines a processor that uses two one-dimensional matrices to perform convolution against an image. /// /// The pixel format. internal class Convolution2DProcessor : ImageProcessor @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Fast2DArray KernelY { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { int kernelYHeight = this.KernelY.Height; int kernelYWidth = this.KernelY.Width; diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs similarity index 95% rename from src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs index 0d87aa1dc4..3ea025512c 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs @@ -13,7 +13,7 @@ using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Processors { /// - /// Defines a sampler that uses two one-dimensional matrices to perform two-pass convolution against an image. + /// Defines a processor that uses two one-dimensional matrices to perform two-pass convolution against an image. /// /// The pixel format. internal class Convolution2PassProcessor : ImageProcessor @@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Fast2DArray KernelY { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { ParallelOptions parallelOptions = configuration.ParallelOptions; diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs similarity index 94% rename from src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs index 2f369113d9..2eff3bf213 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs @@ -13,7 +13,7 @@ using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Processors { /// - /// Defines a sampler that uses a 2 dimensional matrix to perform convolution against an image. + /// Defines a processor that uses a 2 dimensional matrix to perform convolution against an image. /// /// The pixel format. internal class ConvolutionProcessor : ImageProcessor @@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Fast2DArray KernelXY { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { int kernelLength = this.KernelXY.Height; int radius = kernelLength >> 1; diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetector2DProcessor.cs similarity index 69% rename from src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/EdgeDetector2DProcessor.cs index 741a6e308c..74a0194452 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetector2DProcessor.cs @@ -1,15 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Filters.Processors; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// - /// Defines a sampler that detects edges within an image using two one-dimensional matrices. + /// Defines a processor that detects edges within an image using two one-dimensional matrices. /// /// The pixel format. internal abstract class EdgeDetector2DProcessor : ImageProcessor, IEdgeDetectorProcessor @@ -20,10 +21,12 @@ namespace SixLabors.ImageSharp.Processing.Processors /// /// The horizontal gradient operator. /// The vertical gradient operator. - protected EdgeDetector2DProcessor(Fast2DArray kernelX, Fast2DArray kernelY) + /// Whether to convert the image to grayscale before performing edge detection. + protected EdgeDetector2DProcessor(Fast2DArray kernelX, Fast2DArray kernelY, bool grayscale) { this.KernelX = kernelX; this.KernelY = kernelY; + this.Grayscale = grayscale; } /// @@ -40,13 +43,13 @@ namespace SixLabors.ImageSharp.Processing.Processors public bool Grayscale { get; set; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { new Convolution2DProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle, configuration); } /// - protected override void BeforeApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void BeforeFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { if (this.Grayscale) { diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorCompassProcessor.cs similarity index 83% rename from src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorCompassProcessor.cs index 0ffd7d48f5..df26c23b82 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorCompassProcessor.cs @@ -4,20 +4,30 @@ using System; using System.Numerics; using System.Threading.Tasks; -using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Filters.Processors; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// - /// Defines a sampler that detects edges within an image using a eight two dimensional matrices. + /// Defines a processor that detects edges within an image using a eight two dimensional matrices. /// /// The pixel format. internal abstract class EdgeDetectorCompassProcessor : ImageProcessor, IEdgeDetectorProcessor where TPixel : struct, IPixel { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + protected EdgeDetectorCompassProcessor(bool grayscale) + { + this.Grayscale = grayscale; + } + /// /// Gets the North gradient operator /// @@ -59,10 +69,10 @@ namespace SixLabors.ImageSharp.Processing.Processors public abstract Fast2DArray NorthEast { get; } /// - public bool Grayscale { get; set; } + public bool Grayscale { get; } /// - protected override void BeforeApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void BeforeFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { if (this.Grayscale) { @@ -71,7 +81,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { Fast2DArray[] kernels = { this.North, this.NorthWest, this.West, this.SouthWest, this.South, this.SouthEast, this.East, this.NorthEast }; diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorProcessor.cs similarity index 64% rename from src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorProcessor.cs index e5c5179716..cd2e7d76ca 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorProcessor.cs @@ -1,15 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Filters.Processors; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// - /// Defines a sampler that detects edges within an image using a single two dimensional matrix. + /// Defines a processor that detects edges within an image using a single two dimensional matrix. /// /// The pixel format. internal abstract class EdgeDetectorProcessor : ImageProcessor, IEdgeDetectorProcessor @@ -19,13 +20,15 @@ namespace SixLabors.ImageSharp.Processing.Processors /// Initializes a new instance of the class. /// /// The 2d gradient operator. - protected EdgeDetectorProcessor(Fast2DArray kernelXY) + /// Whether to convert the image to grayscale before performing edge detection. + protected EdgeDetectorProcessor(Fast2DArray kernelXY, bool grayscale) { this.KernelXY = kernelXY; + this.Grayscale = grayscale; } /// - public bool Grayscale { get; set; } + public bool Grayscale { get; } /// /// Gets the 2d gradient operator. @@ -33,7 +36,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Fast2DArray KernelXY { get; } /// - protected override void BeforeApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void BeforeFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { if (this.Grayscale) { @@ -42,7 +45,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { new ConvolutionProcessor(this.KernelXY).Apply(source, sourceRectangle, configuration); } diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs similarity index 88% rename from src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs index c897efeed8..3ce321cd39 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs @@ -4,12 +4,13 @@ using System; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// - /// Applies a Gaussian blur sampler to the image. + /// Applies Gaussian blur processing to the image. /// /// The pixel format. internal class GaussianBlurProcessor : ImageProcessor @@ -20,11 +21,6 @@ namespace SixLabors.ImageSharp.Processing.Processors /// private readonly int kernelSize; - /// - /// The spread of the blur. - /// - private readonly float sigma; - /// /// Initializes a new instance of the class. /// @@ -32,7 +28,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public GaussianBlurProcessor(float sigma = 3f) { this.kernelSize = ((int)Math.Ceiling(sigma) * 2) + 1; - this.sigma = sigma; + this.Sigma = sigma; this.KernelX = this.CreateGaussianKernel(true); this.KernelY = this.CreateGaussianKernel(false); } @@ -46,7 +42,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public GaussianBlurProcessor(int radius) { this.kernelSize = (radius * 2) + 1; - this.sigma = radius; + this.Sigma = radius; this.KernelX = this.CreateGaussianKernel(true); this.KernelY = this.CreateGaussianKernel(false); } @@ -64,15 +60,15 @@ namespace SixLabors.ImageSharp.Processing.Processors public GaussianBlurProcessor(float sigma, int radius) { this.kernelSize = (radius * 2) + 1; - this.sigma = sigma; + this.Sigma = sigma; this.KernelX = this.CreateGaussianKernel(true); this.KernelY = this.CreateGaussianKernel(false); } /// - /// Gets the sigma + /// Gets the sigma value representing the weight of the blur /// - public float Sigma => this.sigma; + public float Sigma { get; } /// /// Gets the horizontal gradient operator. @@ -85,7 +81,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Fast2DArray KernelY { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { new Convolution2PassProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle, configuration); } @@ -98,7 +94,7 @@ namespace SixLabors.ImageSharp.Processing.Processors private Fast2DArray CreateGaussianKernel(bool horizontal) { int size = this.kernelSize; - float weight = this.sigma; + float weight = this.Sigma; Fast2DArray kernel = horizontal ? new Fast2DArray(size, 1) : new Fast2DArray(1, size); diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs similarity index 89% rename from src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs index b960e9075f..cff0767b1d 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs @@ -4,12 +4,13 @@ using System; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// - /// Applies a Gaussian sharpening sampler to the image. + /// Applies Gaussian sharpening processing to the image. /// /// The pixel format. internal class GaussianSharpenProcessor : ImageProcessor @@ -20,11 +21,6 @@ namespace SixLabors.ImageSharp.Processing.Processors /// private readonly int kernelSize; - /// - /// The spread of the blur. - /// - private readonly float sigma; - /// /// Initializes a new instance of the class. /// @@ -34,7 +30,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public GaussianSharpenProcessor(float sigma = 3f) { this.kernelSize = ((int)Math.Ceiling(sigma) * 2) + 1; - this.sigma = sigma; + this.Sigma = sigma; this.KernelX = this.CreateGaussianKernel(true); this.KernelY = this.CreateGaussianKernel(false); } @@ -48,7 +44,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public GaussianSharpenProcessor(int radius) { this.kernelSize = (radius * 2) + 1; - this.sigma = radius; + this.Sigma = radius; this.KernelX = this.CreateGaussianKernel(true); this.KernelY = this.CreateGaussianKernel(false); } @@ -66,15 +62,15 @@ namespace SixLabors.ImageSharp.Processing.Processors public GaussianSharpenProcessor(float sigma, int radius) { this.kernelSize = (radius * 2) + 1; - this.sigma = sigma; + this.Sigma = sigma; this.KernelX = this.CreateGaussianKernel(true); this.KernelY = this.CreateGaussianKernel(false); } /// - /// Gets the sigma + /// Gets the sigma value representing the weight of the blur /// - public float Sigma => this.sigma; + public float Sigma { get; } /// /// Gets the horizontal gradient operator. @@ -87,7 +83,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Fast2DArray KernelY { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { new Convolution2PassProcessor(this.KernelX, this.KernelY).Apply(source, sourceRectangle, configuration); } @@ -100,7 +96,7 @@ namespace SixLabors.ImageSharp.Processing.Processors private Fast2DArray CreateGaussianKernel(bool horizontal) { int size = this.kernelSize; - float weight = this.sigma; + float weight = this.Sigma; Fast2DArray kernel = horizontal ? new Fast2DArray(size, 1) : new Fast2DArray(1, size); @@ -159,7 +155,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } } - // Normalise kernel so that the sum of all weights equals 1 + // Normalize kernel so that the sum of all weights equals 1 if (horizontal) { for (int i = 0; i < size; i++) diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/IEdgeDetectorProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/IEdgeDetectorProcessor.cs similarity index 77% rename from src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/IEdgeDetectorProcessor.cs rename to src/ImageSharp/Processing/Convolution/Processors/IEdgeDetectorProcessor.cs index 6208a24a46..e43aff70b8 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/IEdgeDetectorProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/IEdgeDetectorProcessor.cs @@ -1,10 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// /// Provides properties and methods allowing the detection of edges within an image. @@ -21,8 +20,8 @@ namespace SixLabors.ImageSharp.Processing public interface IEdgeDetectorProcessor { /// - /// Gets or sets a value indicating whether to convert the image to grayscale before performing edge detection. + /// Gets a value indicating whether to convert the image to grayscale before performing edge detection. /// - bool Grayscale { get; set; } + bool Grayscale { get; } } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/KayyaliKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/KayyaliKernels.cs new file mode 100644 index 0000000000..b18bd52af2 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/KayyaliKernels.cs @@ -0,0 +1,35 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains the kernels used for Kayyali edge detection + /// + internal static class KayyaliKernels + { + /// + /// Gets the horizontal gradient operator. + /// + public static Fast2DArray KayyaliX => + new float[,] + { + { 6, 0, -6 }, + { 0, 0, 0 }, + { -6, 0, 6 } + }; + + /// + /// Gets the vertical gradient operator. + /// + public static Fast2DArray KayyaliY => + new float[,] + { + { -6, 0, 6 }, + { 0, 0, 0 }, + { 6, 0, -6 } + }; + } +} diff --git a/src/ImageSharp/Processing/Convolution/Processors/KayyaliProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/KayyaliProcessor.cs new file mode 100644 index 0000000000..357c6c3970 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/KayyaliProcessor.cs @@ -0,0 +1,24 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Kayyali operator filter. + /// + /// The pixel format. + internal class KayyaliProcessor : EdgeDetector2DProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public KayyaliProcessor(bool grayscale) + : base(KayyaliKernels.KayyaliX, KayyaliKernels.KayyaliY, grayscale) + { + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/KirschProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/KirschProcessor.cs new file mode 100644 index 0000000000..3ae333e18e --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/KirschProcessor.cs @@ -0,0 +1,49 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Kirsch operator filter. + /// + /// The pixel format. + internal class KirschProcessor : EdgeDetectorCompassProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public KirschProcessor(bool grayscale) + : base(grayscale) + { + } + + /// + public override Fast2DArray North => KirshKernels.KirschNorth; + + /// + public override Fast2DArray NorthWest => KirshKernels.KirschNorthWest; + + /// + public override Fast2DArray West => KirshKernels.KirschWest; + + /// + public override Fast2DArray SouthWest => KirshKernels.KirschSouthWest; + + /// + public override Fast2DArray South => KirshKernels.KirschSouth; + + /// + public override Fast2DArray SouthEast => KirshKernels.KirschSouthEast; + + /// + public override Fast2DArray East => KirshKernels.KirschEast; + + /// + public override Fast2DArray NorthEast => KirshKernels.KirschNorthEast; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/KirshKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/KirshKernels.cs new file mode 100644 index 0000000000..99c327055f --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/KirshKernels.cs @@ -0,0 +1,101 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains the eight matrices used for Kirsh edge detection + /// + internal static class KirshKernels + { + /// + /// Gets the North gradient operator + /// + public static Fast2DArray KirschNorth => + new float[,] + { + { 5, 5, 5 }, + { -3, 0, -3 }, + { -3, -3, -3 } + }; + + /// + /// Gets the NorthWest gradient operator + /// + public static Fast2DArray KirschNorthWest => + new float[,] + { + { 5, 5, -3 }, + { 5, 0, -3 }, + { -3, -3, -3 } + }; + + /// + /// Gets the West gradient operator + /// + public static Fast2DArray KirschWest => + new float[,] + { + { 5, -3, -3 }, + { 5, 0, -3 }, + { 5, -3, -3 } + }; + + /// + /// Gets the SouthWest gradient operator + /// + public static Fast2DArray KirschSouthWest => + new float[,] + { + { -3, -3, -3 }, + { 5, 0, -3 }, + { 5, 5, -3 } + }; + + /// + /// Gets the South gradient operator + /// + public static Fast2DArray KirschSouth => + new float[,] + { + { -3, -3, -3 }, + { -3, 0, -3 }, + { 5, 5, 5 } + }; + + /// + /// Gets the SouthEast gradient operator + /// + public static Fast2DArray KirschSouthEast => + new float[,] + { + { -3, -3, -3 }, + { -3, 0, 5 }, + { -3, 5, 5 } + }; + + /// + /// Gets the East gradient operator + /// + public static Fast2DArray KirschEast => + new float[,] + { + { -3, -3, 5 }, + { -3, 0, 5 }, + { -3, -3, 5 } + }; + + /// + /// Gets the NorthEast gradient operator + /// + public static Fast2DArray KirschNorthEast => + new float[,] + { + { -3, 5, 5 }, + { -3, 0, 5 }, + { -3, -3, -3 } + }; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/Laplacian3x3Processor.cs b/src/ImageSharp/Processing/Convolution/Processors/Laplacian3x3Processor.cs new file mode 100644 index 0000000000..657a93c816 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/Laplacian3x3Processor.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Laplacian 3x3 operator filter. + /// + /// + /// The pixel format. + internal class Laplacian3x3Processor : EdgeDetectorProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public Laplacian3x3Processor(bool grayscale) + : base(LaplacianKernels.Laplacian3x3, grayscale) + { + } + } +} diff --git a/src/ImageSharp/Processing/Convolution/Processors/Laplacian5x5Processor.cs b/src/ImageSharp/Processing/Convolution/Processors/Laplacian5x5Processor.cs new file mode 100644 index 0000000000..5b44773add --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/Laplacian5x5Processor.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Laplacian 5x5 operator filter. + /// + /// + /// The pixel format. + internal class Laplacian5x5Processor : EdgeDetectorProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public Laplacian5x5Processor(bool grayscale) + : base(LaplacianKernels.Laplacian5x5, grayscale) + { + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernelFactory.cs b/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernelFactory.cs new file mode 100644 index 0000000000..e28da14b55 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernelFactory.cs @@ -0,0 +1,40 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// A factory for creating Laplacian kernel matrices. + /// + internal static class LaplacianKernelFactory + { + /// + /// Creates a Laplacian matrix, 2nd derivative, of an arbitrary length. + /// + /// + /// The length of the matrix sides + /// The + public static Fast2DArray CreateKernel(uint length) + { + Guard.MustBeGreaterThanOrEqualTo(length, 3u, nameof(length)); + Guard.IsFalse(length % 2 == 0, nameof(length), "The kernel length must be an odd number."); + + var kernel = new Fast2DArray((int)length); + + for (int y = 0; y < kernel.Height; y++) + { + for (int x = 0; x < kernel.Width; x++) + { + kernel[x, y] = -1; + } + } + + int mid = (int)(length / 2); + kernel[mid, mid] = (length * length) - 1; + + return kernel; + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernels.cs new file mode 100644 index 0000000000..611982b9a5 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernels.cs @@ -0,0 +1,36 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains Laplacian kernels of different sizes + /// + internal static class LaplacianKernels + { + /// + /// Gets the 3x3 Laplacian kernel + /// + public static Fast2DArray Laplacian3x3 => LaplacianKernelFactory.CreateKernel(3); + + /// + /// Gets the 5x5 Laplacian kernel + /// + public static Fast2DArray Laplacian5x5 => LaplacianKernelFactory.CreateKernel(5); + + /// + /// Gets the Laplacian of Gaussian kernel. + /// + public static Fast2DArray LaplacianOfGaussianXY => + new float[,] + { + { 0, 0, -1, 0, 0 }, + { 0, -1, -2, -1, 0 }, + { -1, -2, 16, -2, -1 }, + { 0, -1, -2, -1, 0 }, + { 0, 0, -1, 0, 0 } + }; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/LaplacianOfGaussianProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/LaplacianOfGaussianProcessor.cs new file mode 100644 index 0000000000..e65e0d2152 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/LaplacianOfGaussianProcessor.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Laplacian of Gaussian operator filter. + /// + /// + /// The pixel format. + internal class LaplacianOfGaussianProcessor : EdgeDetectorProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public LaplacianOfGaussianProcessor(bool grayscale) + : base(LaplacianKernels.LaplacianOfGaussianXY, grayscale) + { + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/PrewittKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/PrewittKernels.cs new file mode 100644 index 0000000000..64bce4f8cc --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/PrewittKernels.cs @@ -0,0 +1,35 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains the kernels used for Prewitt edge detection + /// + internal static class PrewittKernels + { + /// + /// Gets the horizontal gradient operator. + /// + public static Fast2DArray PrewittX => + new float[,] + { + { -1, 0, 1 }, + { -1, 0, 1 }, + { -1, 0, 1 } + }; + + /// + /// Gets the vertical gradient operator. + /// + public static Fast2DArray PrewittY => + new float[,] + { + { 1, 1, 1 }, + { 0, 0, 0 }, + { -1, -1, -1 } + }; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/PrewittProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/PrewittProcessor.cs new file mode 100644 index 0000000000..5683d6f609 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/PrewittProcessor.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Prewitt operator filter. + /// + /// + /// The pixel format. + internal class PrewittProcessor : EdgeDetector2DProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public PrewittProcessor(bool grayscale) + : base(PrewittKernels.PrewittX, PrewittKernels.PrewittY, grayscale) + { + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossKernels.cs new file mode 100644 index 0000000000..63d96c79bd --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossKernels.cs @@ -0,0 +1,33 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains the kernels used for RobertsCross edge detection + /// + internal static class RobertsCrossKernels + { + /// + /// Gets the horizontal gradient operator. + /// + public static Fast2DArray RobertsCrossX => + new float[,] + { + { 1, 0 }, + { 0, -1 } + }; + + /// + /// Gets the vertical gradient operator. + /// + public static Fast2DArray RobertsCrossY => + new float[,] + { + { 0, 1 }, + { -1, 0 } + }; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossProcessor.cs new file mode 100644 index 0000000000..38d1fffc9a --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossProcessor.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Roberts Cross operator filter. + /// + /// + /// The pixel format. + internal class RobertsCrossProcessor : EdgeDetector2DProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public RobertsCrossProcessor(bool grayscale) + : base(RobertsCrossKernels.RobertsCrossX, RobertsCrossKernels.RobertsCrossY, grayscale) + { + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/RobinsonKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/RobinsonKernels.cs new file mode 100644 index 0000000000..e102023290 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/RobinsonKernels.cs @@ -0,0 +1,101 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains the kernels used for Robinson edge detection + /// + internal static class RobinsonKernels + { + /// + /// Gets the North gradient operator + /// + public static Fast2DArray RobinsonNorth => + new float[,] + { + { 1, 2, 1 }, + { 0, 0, 0 }, + { -1, -2, -1 } + }; + + /// + /// Gets the NorthWest gradient operator + /// + public static Fast2DArray RobinsonNorthWest => + new float[,] + { + { 2, 1, 0 }, + { 1, 0, -1 }, + { 0, -1, -2 } + }; + + /// + /// Gets the West gradient operator + /// + public static Fast2DArray RobinsonWest => + new float[,] + { + { 1, 0, -1 }, + { 2, 0, -2 }, + { 1, 0, -1 } + }; + + /// + /// Gets the SouthWest gradient operator + /// + public static Fast2DArray RobinsonSouthWest => + new float[,] + { + { 0, -1, -2 }, + { 1, 0, -1 }, + { 2, 1, 0 } + }; + + /// + /// Gets the South gradient operator + /// + public static Fast2DArray RobinsonSouth => + new float[,] + { + { -1, -2, -1 }, + { 0, 0, 0 }, + { 1, 2, 1 } + }; + + /// + /// Gets the SouthEast gradient operator + /// + public static Fast2DArray RobinsonSouthEast => + new float[,] + { + { -2, -1, 0 }, + { -1, 0, 1 }, + { 0, 1, 2 } + }; + + /// + /// Gets the East gradient operator + /// + public static Fast2DArray RobinsonEast => + new float[,] + { + { -1, 0, 1 }, + { -2, 0, 2 }, + { -1, 0, 1 } + }; + + /// + /// Gets the NorthEast gradient operator + /// + public static Fast2DArray RobinsonNorthEast => + new float[,] + { + { 0, 1, 2 }, + { -1, 0, 1 }, + { -2, -1, 0 } + }; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/RobinsonProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/RobinsonProcessor.cs new file mode 100644 index 0000000000..fac0c52e5a --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/RobinsonProcessor.cs @@ -0,0 +1,50 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Robinson operator filter. + /// + /// + /// The pixel format. + internal class RobinsonProcessor : EdgeDetectorCompassProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public RobinsonProcessor(bool grayscale) + : base(grayscale) + { + } + + /// + public override Fast2DArray North => RobinsonKernels.RobinsonNorth; + + /// + public override Fast2DArray NorthWest => RobinsonKernels.RobinsonNorthWest; + + /// + public override Fast2DArray West => RobinsonKernels.RobinsonWest; + + /// + public override Fast2DArray SouthWest => RobinsonKernels.RobinsonSouthWest; + + /// + public override Fast2DArray South => RobinsonKernels.RobinsonSouth; + + /// + public override Fast2DArray SouthEast => RobinsonKernels.RobinsonSouthEast; + + /// + public override Fast2DArray East => RobinsonKernels.RobinsonEast; + + /// + public override Fast2DArray NorthEast => RobinsonKernels.RobinsonNorthEast; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/ScharrKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/ScharrKernels.cs new file mode 100644 index 0000000000..cf8b9925ad --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/ScharrKernels.cs @@ -0,0 +1,35 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains the kernels used for Scharr edge detection + /// + internal static class ScharrKernels + { + /// + /// Gets the horizontal gradient operator. + /// + public static Fast2DArray ScharrX => + new float[,] + { + { -3, 0, 3 }, + { -10, 0, 10 }, + { -3, 0, 3 } + }; + + /// + /// Gets the vertical gradient operator. + /// + public static Fast2DArray ScharrY => + new float[,] + { + { 3, 10, 3 }, + { 0, 0, 0 }, + { -3, -10, -3 } + }; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/ScharrProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/ScharrProcessor.cs new file mode 100644 index 0000000000..c101d092de --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/ScharrProcessor.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Applies edge detection processing to the image using the Scharr operator filter. + /// + /// + /// The pixel format. + internal class ScharrProcessor : EdgeDetector2DProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public ScharrProcessor(bool grayscale) + : base(ScharrKernels.ScharrX, ScharrKernels.ScharrY, grayscale) + { + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/SobelKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/SobelKernels.cs new file mode 100644 index 0000000000..691bd66149 --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/SobelKernels.cs @@ -0,0 +1,35 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// Contains the kernels used for Sobel edge detection + /// + internal static class SobelKernels + { + /// + /// Gets the horizontal gradient operator. + /// + public static Fast2DArray SobelX => + new float[,] + { + { -1, 0, 1 }, + { -2, 0, 2 }, + { -1, 0, 1 } + }; + + /// + /// Gets the vertical gradient operator. + /// + public static Fast2DArray SobelY => + new float[,] + { + { -1, -2, -1 }, + { 0, 0, 0 }, + { 1, 2, 1 } + }; + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/SobelProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/SobelProcessor.cs new file mode 100644 index 0000000000..bf97c67d7f --- /dev/null +++ b/src/ImageSharp/Processing/Convolution/Processors/SobelProcessor.cs @@ -0,0 +1,26 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Convolution.Processors +{ + /// + /// The Sobel operator filter. + /// + /// + /// The pixel format. + internal class SobelProcessor : EdgeDetector2DProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// Whether to convert the image to grayscale before performing edge detection. + public SobelProcessor(bool grayscale) + : base(SobelKernels.SobelX, SobelKernels.SobelY, grayscale) + { + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Dithering/Diffuse.cs b/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs similarity index 95% rename from src/ImageSharp/Processing/Dithering/Diffuse.cs rename to src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs index e6b82d3134..01f138b097 100644 --- a/src/ImageSharp/Processing/Dithering/Diffuse.cs +++ b/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs @@ -3,15 +3,15 @@ using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Dithering.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Dithering { /// - /// Extension methods for the type. + /// Adds diffusion extensions to the type. /// - public static partial class ImageExtensions + public static class DiffuseExtensions { /// /// Dithers the image reducing it to a web-safe palette using error diffusion. @@ -81,4 +81,4 @@ namespace SixLabors.ImageSharp return source; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Dithering/Dither.cs b/src/ImageSharp/Processing/Dithering/DitherExtensions.cs similarity index 94% rename from src/ImageSharp/Processing/Dithering/Dither.cs rename to src/ImageSharp/Processing/Dithering/DitherExtensions.cs index 85fdef24b5..f3debe8cbf 100644 --- a/src/ImageSharp/Processing/Dithering/Dither.cs +++ b/src/ImageSharp/Processing/Dithering/DitherExtensions.cs @@ -3,15 +3,15 @@ using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Dithering.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Dithering { /// - /// Extension methods for the type. + /// Adds dithering extensions to the type. /// - public static partial class ImageExtensions + public static class DitherExtensions { /// /// Dithers the image reducing it to a web-safe palette using ordered dithering. @@ -77,4 +77,4 @@ namespace SixLabors.ImageSharp return source; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Dithering/ErrorDiffusionPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs similarity index 96% rename from src/ImageSharp/Processing/Processors/Dithering/ErrorDiffusionPaletteProcessor.cs rename to src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs index 152959cb73..4e2a2cb790 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/ErrorDiffusionPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs @@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Dithering.Processors { /// /// An that dithers an image using error diffusion. @@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public float Threshold { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { float threshold = this.Threshold * 255F; var rgba = default(Rgba32); diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs similarity index 95% rename from src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs rename to src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs index 4fc59585a9..213f7ca908 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs @@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Dithering.Processors { /// /// An that dithers an image using error diffusion. @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public IOrderedDither Dither { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { var rgba = default(Rgba32); bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8); diff --git a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs b/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs similarity index 95% rename from src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs rename to src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs index 4e6b7bec0e..782d33b533 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs @@ -6,7 +6,7 @@ using System.Numerics; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Dithering.Processors { /// /// The base class for dither and diffusion processors that consume a palette. @@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// Initializes a new instance of the class. /// /// The palette to select substitute colors from. - public PaletteDitherProcessorBase(TPixel[] palette) + protected PaletteDitherProcessorBase(TPixel[] palette) { Guard.NotNull(palette, nameof(palette)); this.Palette = palette; diff --git a/src/ImageSharp/Processing/Processors/Dithering/PixelPair.cs b/src/ImageSharp/Processing/Dithering/Processors/PixelPair.cs similarity index 96% rename from src/ImageSharp/Processing/Processors/Dithering/PixelPair.cs rename to src/ImageSharp/Processing/Dithering/Processors/PixelPair.cs index 07045bb5ab..127c0be6d0 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/PixelPair.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/PixelPair.cs @@ -4,7 +4,7 @@ using System; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Dithering.Processors { /// /// Represents a composite pair of pixels. Used for caching color distance lookups. diff --git a/src/ImageSharp/Processing/Effects/OilPainting.cs b/src/ImageSharp/Processing/Effects/OilPaintExtensions.cs similarity index 86% rename from src/ImageSharp/Processing/Effects/OilPainting.cs rename to src/ImageSharp/Processing/Effects/OilPaintExtensions.cs index 0494c9a8b9..a04bbec4e5 100644 --- a/src/ImageSharp/Processing/Effects/OilPainting.cs +++ b/src/ImageSharp/Processing/Effects/OilPaintExtensions.cs @@ -1,17 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Effects.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Effects { /// - /// Extension methods for the type. + /// Adds oil painting effect extensions to the type. /// - public static partial class ImageExtensions + public static class OilPaintExtensions { /// /// Alters the colors of the image recreating an oil painting effect with levels and brushSize @@ -22,9 +21,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext OilPaint(this IImageProcessingContext source) where TPixel : struct, IPixel - { - return OilPaint(source, 10, 15); - } + => OilPaint(source, 10, 15); /// /// Alters the colors of the image recreating an oil painting effect with levels and brushSize @@ -38,9 +35,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext OilPaint(this IImageProcessingContext source, Rectangle rectangle) where TPixel : struct, IPixel - { - return OilPaint(source, 10, 15, rectangle); - } + => OilPaint(source, 10, 15, rectangle); /// /// Alters the colors of the image recreating an oil painting effect. @@ -52,7 +47,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext OilPaint(this IImageProcessingContext source, int levels, int brushSize) where TPixel : struct, IPixel - => source.ApplyProcessor(new OilPaintingProcessor(levels, brushSize)); + => source.ApplyProcessor(new OilPaintingProcessor(levels, brushSize)); /// /// Alters the colors of the image recreating an oil painting effect. @@ -67,6 +62,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext OilPaint(this IImageProcessingContext source, int levels, int brushSize, Rectangle rectangle) where TPixel : struct, IPixel - => source.ApplyProcessor(new OilPaintingProcessor(levels, brushSize), rectangle); + => source.ApplyProcessor(new OilPaintingProcessor(levels, brushSize), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Effects/Pixelate.cs b/src/ImageSharp/Processing/Effects/PixelateExtensions.cs similarity index 81% rename from src/ImageSharp/Processing/Effects/Pixelate.cs rename to src/ImageSharp/Processing/Effects/PixelateExtensions.cs index 29e348f6e6..d6fcfe6f15 100644 --- a/src/ImageSharp/Processing/Effects/Pixelate.cs +++ b/src/ImageSharp/Processing/Effects/PixelateExtensions.cs @@ -1,17 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Effects.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Effects { /// - /// Extension methods for the type. + /// Adds pixelation effect extensions to the type. /// - public static partial class ImageExtensions + public static class PixelateExtensions { /// /// Pixelates an image with the given pixel size. @@ -21,7 +20,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Pixelate(this IImageProcessingContext source) where TPixel : struct, IPixel - => source.ApplyProcessor(new PixelateProcessor(4)); + => Pixelate(source, 4); /// /// Pixelates an image with the given pixel size. @@ -32,7 +31,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Pixelate(this IImageProcessingContext source, int size) where TPixel : struct, IPixel - => source.ApplyProcessor(new PixelateProcessor(size)); + => source.ApplyProcessor(new PixelateProcessor(size)); /// /// Pixelates an image with the given pixel size. @@ -46,6 +45,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Pixelate(this IImageProcessingContext source, int size, Rectangle rectangle) where TPixel : struct, IPixel - => source.ApplyProcessor(new PixelateProcessor(size), rectangle); + => source.ApplyProcessor(new PixelateProcessor(size), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs b/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs similarity index 95% rename from src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs rename to src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs index c199a32c8a..aafc2df888 100644 --- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs +++ b/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs @@ -10,10 +10,10 @@ using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Effects.Processors { /// - /// An to apply an oil painting effect to an . + /// Applies oil painting effect processing to the image. /// /// Adapted from by Dewald Esterhuizen. /// The pixel format. @@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public int BrushSize { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { if (this.BrushSize <= 0 || this.BrushSize > source.Height || this.BrushSize > source.Width) { diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs b/src/ImageSharp/Processing/Effects/Processors/PixelateProcessor.cs similarity index 93% rename from src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs rename to src/ImageSharp/Processing/Effects/Processors/PixelateProcessor.cs index 0ab21f65ac..23f81e05e4 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs +++ b/src/ImageSharp/Processing/Effects/Processors/PixelateProcessor.cs @@ -9,10 +9,10 @@ using SixLabors.ImageSharp.Common; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Effects.Processors { /// - /// An to pixelate the colors of an . + /// Applies a pixelation effect processing to the image. /// /// The pixel format. internal class PixelateProcessor : ImageProcessor @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public int Size { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { if (this.Size <= 0 || this.Size > source.Height || this.Size > source.Width) { diff --git a/src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs b/src/ImageSharp/Processing/Filters/BlackWhiteExtensions.cs similarity index 75% rename from src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs rename to src/ImageSharp/Processing/Filters/BlackWhiteExtensions.cs index d64db34bad..f30cefb860 100644 --- a/src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs +++ b/src/ImageSharp/Processing/Filters/BlackWhiteExtensions.cs @@ -2,15 +2,15 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of black and white toning to the type. /// - public static partial class ImageExtensions + public static class BlackWhiteExtensions { /// /// Applies black and white toning to the image. @@ -20,10 +20,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BlackWhite(this IImageProcessingContext source) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BlackWhiteProcessor()); - return source; - } + => source.ApplyProcessor(new BlackWhiteProcessor()); /// /// Applies black and white toning to the image. @@ -36,9 +33,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext BlackWhite(this IImageProcessingContext source, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new BlackWhiteProcessor(), rectangle); - return source; - } + => source.ApplyProcessor(new BlackWhiteProcessor(), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/ColorMatrix/Brightness.cs b/src/ImageSharp/Processing/Filters/BrightnessExtensions.cs similarity index 83% rename from src/ImageSharp/Processing/ColorMatrix/Brightness.cs rename to src/ImageSharp/Processing/Filters/BrightnessExtensions.cs index 34b5347841..a36d588d5d 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Brightness.cs +++ b/src/ImageSharp/Processing/Filters/BrightnessExtensions.cs @@ -1,17 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the alteration of the brightness component to the type. /// - public static partial class ImageExtensions + public static class BrightnessExtensions { /// /// Alters the brightness component of the image. @@ -26,7 +25,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Brightness(this IImageProcessingContext source, float amount) where TPixel : struct, IPixel - => source.ApplyProcessor(new BrightnessProcessor(amount)); + => source.ApplyProcessor(new BrightnessProcessor(amount)); /// /// Alters the brightness component of the image. @@ -44,6 +43,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Brightness(this IImageProcessingContext source, float amount, Rectangle rectangle) where TPixel : struct, IPixel - => source.ApplyProcessor(new BrightnessProcessor(amount), rectangle); + => source.ApplyProcessor(new BrightnessProcessor(amount), rectangle); } } diff --git a/src/ImageSharp/Processing/ColorMatrix/Options/ColorBlindness.cs b/src/ImageSharp/Processing/Filters/ColorBlindness.cs similarity index 95% rename from src/ImageSharp/Processing/ColorMatrix/Options/ColorBlindness.cs rename to src/ImageSharp/Processing/Filters/ColorBlindness.cs index 1b92029f6b..41d468f340 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Options/ColorBlindness.cs +++ b/src/ImageSharp/Processing/Filters/ColorBlindness.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Filters { /// /// Enumerates the various types of defined color blindness filters. diff --git a/src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs b/src/ImageSharp/Processing/Filters/ColorBlindnessExtensions.cs similarity index 77% rename from src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs rename to src/ImageSharp/Processing/Filters/ColorBlindnessExtensions.cs index ebfa9ffdcd..6a0caf3b45 100644 --- a/src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs +++ b/src/ImageSharp/Processing/Filters/ColorBlindnessExtensions.cs @@ -1,18 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that simulate the effects of various color blindness disorders to the type. /// - public static partial class ImageExtensions + public static class ColorBlindnessExtensions { /// /// Applies the given colorblindness simulator to the image. @@ -50,19 +48,19 @@ namespace SixLabors.ImageSharp { switch (colorBlindness) { - case ImageSharp.Processing.ColorBlindness.Achromatomaly: + case Filters.ColorBlindness.Achromatomaly: return new AchromatomalyProcessor(); - case ImageSharp.Processing.ColorBlindness.Achromatopsia: + case Filters.ColorBlindness.Achromatopsia: return new AchromatopsiaProcessor(); - case ImageSharp.Processing.ColorBlindness.Deuteranomaly: + case Filters.ColorBlindness.Deuteranomaly: return new DeuteranomalyProcessor(); - case ImageSharp.Processing.ColorBlindness.Deuteranopia: + case Filters.ColorBlindness.Deuteranopia: return new DeuteranopiaProcessor(); - case ImageSharp.Processing.ColorBlindness.Protanomaly: + case Filters.ColorBlindness.Protanomaly: return new ProtanomalyProcessor(); - case ImageSharp.Processing.ColorBlindness.Protanopia: + case Filters.ColorBlindness.Protanopia: return new ProtanopiaProcessor(); - case ImageSharp.Processing.ColorBlindness.Tritanomaly: + case Filters.ColorBlindness.Tritanomaly: return new TritanomalyProcessor(); default: return new TritanopiaProcessor(); diff --git a/src/ImageSharp/Processing/ColorMatrix/Contrast.cs b/src/ImageSharp/Processing/Filters/ContrastExtensions.cs similarity index 83% rename from src/ImageSharp/Processing/ColorMatrix/Contrast.cs rename to src/ImageSharp/Processing/Filters/ContrastExtensions.cs index e0f388e287..16225039c3 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Contrast.cs +++ b/src/ImageSharp/Processing/Filters/ContrastExtensions.cs @@ -2,15 +2,15 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the alteration of the contrast component to the type. /// - public static partial class ImageExtensions + public static class ContrastExtensions { /// /// Alters the contrast component of the image. @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Contrast(this IImageProcessingContext source, float amount) where TPixel : struct, IPixel - => source.ApplyProcessor(new ContrastProcessor(amount)); + => source.ApplyProcessor(new ContrastProcessor(amount)); /// /// Alters the contrast component of the image. @@ -43,6 +43,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Contrast(this IImageProcessingContext source, float amount, Rectangle rectangle) where TPixel : struct, IPixel - => source.ApplyProcessor(new ContrastProcessor(amount), rectangle); + => source.ApplyProcessor(new ContrastProcessor(amount), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/ColorMatrix/Filter.cs b/src/ImageSharp/Processing/Filters/FilterExtensions.cs similarity index 77% rename from src/ImageSharp/Processing/ColorMatrix/Filter.cs rename to src/ImageSharp/Processing/Filters/FilterExtensions.cs index 7eb684978a..ae8bbda030 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Filter.cs +++ b/src/ImageSharp/Processing/Filters/FilterExtensions.cs @@ -3,15 +3,15 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of composable filters to the type. /// - public static partial class ImageExtensions + public static class FilterExtensions { /// /// Filters an image but the given color matrix @@ -22,10 +22,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Filter(this IImageProcessingContext source, Matrix4x4 matrix) where TPixel : struct, IPixel - { - source.ApplyProcessor(new FilterProcessor(matrix)); - return source; - } + => source.ApplyProcessor(new FilterProcessor(matrix)); /// /// Filters an image but the given color matrix @@ -39,9 +36,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Filter(this IImageProcessingContext source, Matrix4x4 matrix, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new FilterProcessor(matrix), rectangle); - return source; - } + => source.ApplyProcessor(new FilterProcessor(matrix), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/ColorMatrix/Grayscale.cs b/src/ImageSharp/Processing/Filters/GrayscaleExtensions.cs similarity index 86% rename from src/ImageSharp/Processing/ColorMatrix/Grayscale.cs rename to src/ImageSharp/Processing/Filters/GrayscaleExtensions.cs index ee43d5b016..be5b69eed9 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Grayscale.cs +++ b/src/ImageSharp/Processing/Filters/GrayscaleExtensions.cs @@ -2,29 +2,28 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of grayscale toning to the type. /// - public static partial class ImageExtensions + public static class GrayscaleExtensions { /// - /// Applies Grayscale toning to the image. + /// Applies grayscale toning to the image. /// /// The pixel format. /// The image this method extends. /// The . public static IImageProcessingContext Grayscale(this IImageProcessingContext source) where TPixel : struct, IPixel - => Grayscale(source, GrayscaleMode.Bt709); + => Grayscale(source, GrayscaleMode.Bt709); /// - /// Applies Grayscale toning to the image using the given amount. + /// Applies grayscale toning to the image using the given amount. /// /// The pixel format. /// The image this method extends. @@ -32,7 +31,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Grayscale(this IImageProcessingContext source, float amount) where TPixel : struct, IPixel - => Grayscale(source, GrayscaleMode.Bt709, amount); + => Grayscale(source, GrayscaleMode.Bt709, amount); /// /// Applies grayscale toning to the image with the given . @@ -43,7 +42,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Grayscale(this IImageProcessingContext source, GrayscaleMode mode) where TPixel : struct, IPixel - => Grayscale(source, mode, 1F); + => Grayscale(source, mode, 1F); /// /// Applies grayscale toning to the image with the given using the given amount. @@ -65,7 +64,7 @@ namespace SixLabors.ImageSharp } /// - /// Applies Grayscale toning to the image. + /// Applies grayscale toning to the image. /// /// The pixel format. /// The image this method extends. @@ -75,10 +74,10 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Grayscale(this IImageProcessingContext source, Rectangle rectangle) where TPixel : struct, IPixel - => Grayscale(source, 1F, rectangle); + => Grayscale(source, 1F, rectangle); /// - /// Applies Grayscale toning to the image using the given amount. + /// Applies grayscale toning to the image using the given amount. /// /// The pixel format. /// The image this method extends. @@ -89,10 +88,10 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Grayscale(this IImageProcessingContext source, float amount, Rectangle rectangle) where TPixel : struct, IPixel - => Grayscale(source, GrayscaleMode.Bt709, amount, rectangle); + => Grayscale(source, GrayscaleMode.Bt709, amount, rectangle); /// - /// Applies Grayscale toning to the image. + /// Applies grayscale toning to the image. /// /// The pixel format. /// The image this method extends. @@ -103,10 +102,10 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Grayscale(this IImageProcessingContext source, GrayscaleMode mode, Rectangle rectangle) where TPixel : struct, IPixel - => Grayscale(source, mode, 1F, rectangle); + => Grayscale(source, mode, 1F, rectangle); /// - /// Applies Grayscale toning to the image using the given amount. + /// Applies grayscale toning to the image using the given amount. /// /// The pixel format. /// The image this method extends. diff --git a/src/ImageSharp/Processing/ColorMatrix/Options/GrayscaleMode.cs b/src/ImageSharp/Processing/Filters/GrayscaleMode.cs similarity index 77% rename from src/ImageSharp/Processing/ColorMatrix/Options/GrayscaleMode.cs rename to src/ImageSharp/Processing/Filters/GrayscaleMode.cs index 370071b7ab..db30e67ff4 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Options/GrayscaleMode.cs +++ b/src/ImageSharp/Processing/Filters/GrayscaleMode.cs @@ -1,10 +1,10 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Enumerates the various types of defined Grayscale filters. + /// Enumerates the various types of defined grayscale filters. /// public enum GrayscaleMode { @@ -18,4 +18,4 @@ namespace SixLabors.ImageSharp.Processing /// Bt601 } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/ColorMatrix/Hue.cs b/src/ImageSharp/Processing/Filters/HueExtensions.cs similarity index 75% rename from src/ImageSharp/Processing/ColorMatrix/Hue.cs rename to src/ImageSharp/Processing/Filters/HueExtensions.cs index 76af10c369..1b730d7f02 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Hue.cs +++ b/src/ImageSharp/Processing/Filters/HueExtensions.cs @@ -1,18 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the alteration of the hue component to the type. /// - public static partial class ImageExtensions + public static class HueExtensions { /// /// Alters the hue component of the image. @@ -23,10 +21,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Hue(this IImageProcessingContext source, float degrees) where TPixel : struct, IPixel - { - source.ApplyProcessor(new HueProcessor(degrees)); - return source; - } + => source.ApplyProcessor(new HueProcessor(degrees)); /// /// Alters the hue component of the image. @@ -40,9 +35,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Hue(this IImageProcessingContext source, float degrees, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new HueProcessor(degrees), rectangle); - return source; - } + => source.ApplyProcessor(new HueProcessor(degrees), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Effects/Invert.cs b/src/ImageSharp/Processing/Filters/InvertExtensions.cs similarity index 76% rename from src/ImageSharp/Processing/Effects/Invert.cs rename to src/ImageSharp/Processing/Filters/InvertExtensions.cs index 7dd9ed3dd7..784b37c56e 100644 --- a/src/ImageSharp/Processing/Effects/Invert.cs +++ b/src/ImageSharp/Processing/Filters/InvertExtensions.cs @@ -1,17 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the inversion of colors to the type. /// - public static partial class ImageExtensions + public static class InvertExtensions { /// /// Inverts the colors of the image. @@ -21,7 +20,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Invert(this IImageProcessingContext source) where TPixel : struct, IPixel - => source.ApplyProcessor(new InvertProcessor(1F)); + => source.ApplyProcessor(new InvertProcessor(1F)); /// /// Inverts the colors of the image. @@ -34,6 +33,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Invert(this IImageProcessingContext source, Rectangle rectangle) where TPixel : struct, IPixel - => source.ApplyProcessor(new InvertProcessor(1F), rectangle); + => source.ApplyProcessor(new InvertProcessor(1F), rectangle); } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs b/src/ImageSharp/Processing/Filters/KodachromeExtensions.cs similarity index 74% rename from src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs rename to src/ImageSharp/Processing/Filters/KodachromeExtensions.cs index d7845320ad..94f1acc0c0 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs +++ b/src/ImageSharp/Processing/Filters/KodachromeExtensions.cs @@ -1,18 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the recreation of an old Kodachrome camera effect to the type. /// - public static partial class ImageExtensions + public static class KodachromeExtensions { /// /// Alters the colors of the image recreating an old Kodachrome camera effect. @@ -22,10 +20,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Kodachrome(this IImageProcessingContext source) where TPixel : struct, IPixel - { - source.ApplyProcessor(new KodachromeProcessor()); - return source; - } + => source.ApplyProcessor(new KodachromeProcessor()); /// /// Alters the colors of the image recreating an old Kodachrome camera effect. @@ -38,9 +33,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Kodachrome(this IImageProcessingContext source, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new KodachromeProcessor(), rectangle); - return source; - } + => source.ApplyProcessor(new KodachromeProcessor(), rectangle); } } diff --git a/src/ImageSharp/Processing/Filters/LomographExtensions.cs b/src/ImageSharp/Processing/Filters/LomographExtensions.cs new file mode 100644 index 0000000000..ed9e1cc297 --- /dev/null +++ b/src/ImageSharp/Processing/Filters/LomographExtensions.cs @@ -0,0 +1,38 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Filters.Processors; +using SixLabors.Primitives; + +namespace SixLabors.ImageSharp.Processing.Filters +{ + /// + /// Adds extensions that allow the recreation of an old Lomograph camera effect to the type. + /// + public static class LomographExtensions + { + /// + /// Alters the colors of the image recreating an old Lomograph camera effect. + /// + /// The pixel format. + /// The image this method extends. + /// The . + public static IImageProcessingContext Lomograph(this IImageProcessingContext source) + where TPixel : struct, IPixel + => source.ApplyProcessor(new LomographProcessor()); + + /// + /// Alters the colors of the image recreating an old Lomograph camera effect. + /// + /// The pixel format. + /// The image this method extends. + /// + /// The structure that specifies the portion of the image object to alter. + /// + /// The . + public static IImageProcessingContext Lomograph(this IImageProcessingContext source, Rectangle rectangle) + where TPixel : struct, IPixel + => source.ApplyProcessor(new LomographProcessor(), rectangle); + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/ColorMatrix/MatrixFilters.cs b/src/ImageSharp/Processing/Filters/MatrixFilters.cs similarity index 98% rename from src/ImageSharp/Processing/ColorMatrix/MatrixFilters.cs rename to src/ImageSharp/Processing/Filters/MatrixFilters.cs index 8cbc21b2a6..2f5883fc9c 100644 --- a/src/ImageSharp/Processing/ColorMatrix/MatrixFilters.cs +++ b/src/ImageSharp/Processing/Filters/MatrixFilters.cs @@ -4,10 +4,10 @@ using System; using System.Numerics; -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Provides extensions methods for the struct + /// A collection of known values for composing filters /// public static class MatrixFilters { @@ -253,7 +253,7 @@ namespace SixLabors.ImageSharp.Processing } /// - /// Create a greyscale filter matrix using the given amount using the formula as specified by ITU-R Recommendation BT.601. + /// Create a grayscale filter matrix using the given amount using the formula as specified by ITU-R Recommendation BT.601. /// /// /// The proportion of the conversion. Must be between 0 and 1. @@ -280,7 +280,7 @@ namespace SixLabors.ImageSharp.Processing } /// - /// Create a greyscale filter matrix using the given amount using the formula as specified by ITU-R Recommendation BT.709. + /// Create a grayscale filter matrix using the given amount using the formula as specified by ITU-R Recommendation BT.709. /// /// /// The proportion of the conversion. Must be between 0 and 1. diff --git a/src/ImageSharp/Processing/ColorMatrix/Opacity.cs b/src/ImageSharp/Processing/Filters/OpacityExtensions.cs similarity index 78% rename from src/ImageSharp/Processing/ColorMatrix/Opacity.cs rename to src/ImageSharp/Processing/Filters/OpacityExtensions.cs index b59c068905..e263fef4ee 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Opacity.cs +++ b/src/ImageSharp/Processing/Filters/OpacityExtensions.cs @@ -1,17 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the alteration of the opacity component to the type. /// - public static partial class ImageExtensions + public static class OpacityExtensions { /// /// Multiplies the alpha component of the image. @@ -22,7 +21,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Opacity(this IImageProcessingContext source, float amount) where TPixel : struct, IPixel - => source.ApplyProcessor(new OpacityProcessor(amount)); + => source.ApplyProcessor(new OpacityProcessor(amount)); /// /// Multiplies the alpha component of the image. @@ -36,6 +35,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Opacity(this IImageProcessingContext source, float amount, Rectangle rectangle) where TPixel : struct, IPixel - => source.ApplyProcessor(new OpacityProcessor(amount), rectangle); + => source.ApplyProcessor(new OpacityProcessor(amount), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Filters/PolaroidExtensions.cs b/src/ImageSharp/Processing/Filters/PolaroidExtensions.cs new file mode 100644 index 0000000000..37f06f9cf0 --- /dev/null +++ b/src/ImageSharp/Processing/Filters/PolaroidExtensions.cs @@ -0,0 +1,38 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Filters.Processors; +using SixLabors.Primitives; + +namespace SixLabors.ImageSharp.Processing.Filters +{ + /// + /// Adds extensions that allow the recreation of an old Polaroid camera effect to the type. + /// + public static class PolaroidExtensions + { + /// + /// Alters the colors of the image recreating an old Polaroid camera effect. + /// + /// The pixel format. + /// The image this method extends. + /// The . + public static IImageProcessingContext Polaroid(this IImageProcessingContext source) + where TPixel : struct, IPixel + => source.ApplyProcessor(new PolaroidProcessor()); + + /// + /// Alters the colors of the image recreating an old Polaroid camera effect. + /// + /// The pixel format. + /// The image this method extends. + /// + /// The structure that specifies the portion of the image object to alter. + /// + /// The . + public static IImageProcessingContext Polaroid(this IImageProcessingContext source, Rectangle rectangle) + where TPixel : struct, IPixel + => source.ApplyProcessor(new PolaroidProcessor(), rectangle); + } +} diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/AchromatomalyProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/AchromatomalyProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/AchromatomalyProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/AchromatomalyProcessor.cs index 8d9bf98579..55c6220308 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/AchromatomalyProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/AchromatomalyProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Achromatomaly (Color desensitivity) color blindness. diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/AchromatopsiaProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/AchromatopsiaProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/AchromatopsiaProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/AchromatopsiaProcessor.cs index f19c55933d..95f9e893be 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/AchromatopsiaProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/AchromatopsiaProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Achromatopsia (Monochrome) color blindness. diff --git a/src/ImageSharp/Processing/Processors/Filters/BlackWhiteProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/BlackWhiteProcessor.cs similarity index 91% rename from src/ImageSharp/Processing/Processors/Filters/BlackWhiteProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/BlackWhiteProcessor.cs index 30fcfab4fd..f6a420257e 100644 --- a/src/ImageSharp/Processing/Processors/Filters/BlackWhiteProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/BlackWhiteProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a black and white filter matrix to the image diff --git a/src/ImageSharp/Processing/Processors/Filters/BrightnessProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/BrightnessProcessor.cs similarity index 85% rename from src/ImageSharp/Processing/Processors/Filters/BrightnessProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/BrightnessProcessor.cs index b1a68a9c91..c6f758634d 100644 --- a/src/ImageSharp/Processing/Processors/Filters/BrightnessProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/BrightnessProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a brightness filter matrix using the given amount. @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// Initializes a new instance of the class. /// /// - /// A value of 0 will create an image that is completely black. A value of 1 leaves the input unchanged. + /// A value of 0 will create an image that is completely black. A value of 1 leaves the input unchanged. /// Other values are linear multipliers on the effect. Values of an amount over 1 are allowed, providing brighter results. /// /// The proportion of the conversion. Must be greater than or equal to 0. diff --git a/src/ImageSharp/Processing/Processors/Filters/ContrastProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/ContrastProcessor.cs similarity index 85% rename from src/ImageSharp/Processing/Processors/Filters/ContrastProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/ContrastProcessor.cs index 8ebeb939fb..3a8022703c 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ContrastProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/ContrastProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a contrast filter matrix using the given amount. @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// Initializes a new instance of the class. /// /// - /// A value of 0 will create an image that is completely gray. A value of 1 leaves the input unchanged. + /// A value of 0 will create an image that is completely gray. A value of 1 leaves the input unchanged. /// Other values are linear multipliers on the effect. Values of an amount over 1 are allowed, providing results with more contrast. /// /// The proportion of the conversion. Must be greater than or equal to 0. diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/DeuteranomalyProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/DeuteranomalyProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/DeuteranomalyProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/DeuteranomalyProcessor.cs index 20a1d4ab46..31ea79afe2 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/DeuteranomalyProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/DeuteranomalyProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Deuteranomaly (Green-Weak) color blindness. diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/DeuteranopiaProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/DeuteranopiaProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/DeuteranopiaProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/DeuteranopiaProcessor.cs index e5e0225718..5ed7e85408 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/DeuteranopiaProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/DeuteranopiaProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Deuteranopia (Green-Blind) color blindness. diff --git a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/FilterProcessor.cs similarity index 91% rename from src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/FilterProcessor.cs index 30fe8c6b6f..fb094d7bd0 100644 --- a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/FilterProcessor.cs @@ -9,7 +9,7 @@ using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Provides methods that accept a matrix to apply freeform filters to images. @@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Matrix4x4 Matrix { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { var interest = Rectangle.Intersect(sourceRectangle, source.Bounds()); int startY = interest.Y; diff --git a/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt601Processor.cs b/src/ImageSharp/Processing/Filters/Processors/GrayscaleBt601Processor.cs similarity index 88% rename from src/ImageSharp/Processing/Processors/Filters/GrayscaleBt601Processor.cs rename to src/ImageSharp/Processing/Filters/Processors/GrayscaleBt601Processor.cs index 7ea52dcb92..fa483752c5 100644 --- a/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt601Processor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/GrayscaleBt601Processor.cs @@ -3,10 +3,10 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// - /// Applies a greyscale filter matrix using the given amount and the formula as specified by ITU-R Recommendation BT.601 + /// Applies a grayscale filter matrix using the given amount and the formula as specified by ITU-R Recommendation BT.601 /// /// The pixel format. internal class GrayscaleBt601Processor : FilterProcessor diff --git a/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt709Processor.cs b/src/ImageSharp/Processing/Filters/Processors/GrayscaleBt709Processor.cs similarity index 94% rename from src/ImageSharp/Processing/Processors/Filters/GrayscaleBt709Processor.cs rename to src/ImageSharp/Processing/Filters/Processors/GrayscaleBt709Processor.cs index fcd7b2e8f5..396ad7d903 100644 --- a/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt709Processor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/GrayscaleBt709Processor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a grayscale filter matrix using the given amount and the formula as specified by ITU-R Recommendation BT.709 diff --git a/src/ImageSharp/Processing/Processors/Filters/HueProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/HueProcessor.cs similarity index 93% rename from src/ImageSharp/Processing/Processors/Filters/HueProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/HueProcessor.cs index 302314db40..31adf21259 100644 --- a/src/ImageSharp/Processing/Processors/Filters/HueProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/HueProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a hue filter matrix using the given angle of rotation in degrees diff --git a/src/ImageSharp/Processing/Processors/Filters/InvertProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/InvertProcessor.cs similarity index 93% rename from src/ImageSharp/Processing/Processors/Filters/InvertProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/InvertProcessor.cs index e258e9d96e..e5175ca69b 100644 --- a/src/ImageSharp/Processing/Processors/Filters/InvertProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/InvertProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a filter matrix that inverts the colors of an image diff --git a/src/ImageSharp/Processing/Processors/Filters/KodachromeProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/KodachromeProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/KodachromeProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/KodachromeProcessor.cs index 6f27a04538..19f55507c4 100644 --- a/src/ImageSharp/Processing/Processors/Filters/KodachromeProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/KodachromeProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a filter matrix recreating an old Kodachrome camera effect matrix to the image diff --git a/src/ImageSharp/Processing/Filters/Processors/LomographProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/LomographProcessor.cs new file mode 100644 index 0000000000..5ee6b4bc1a --- /dev/null +++ b/src/ImageSharp/Processing/Filters/Processors/LomographProcessor.cs @@ -0,0 +1,33 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors.Overlays; +using SixLabors.Primitives; + +namespace SixLabors.ImageSharp.Processing.Filters.Processors +{ + /// + /// Converts the colors of the image recreating an old Lomograph effect. + /// + /// The pixel format. + internal class LomographProcessor : FilterProcessor + where TPixel : struct, IPixel + { + private static readonly TPixel VeryDarkGreen = ColorBuilder.FromRGBA(0, 10, 0, 255); + + /// + /// Initializes a new instance of the class. + /// + public LomographProcessor() + : base(MatrixFilters.LomographFilter) + { + } + + /// + protected override void AfterFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + { + new VignetteProcessor(VeryDarkGreen).Apply(source, sourceRectangle, configuration); + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Filters/OpacityProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/OpacityProcessor.cs similarity index 93% rename from src/ImageSharp/Processing/Processors/Filters/OpacityProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/OpacityProcessor.cs index 1c0d2600ea..db9af9546c 100644 --- a/src/ImageSharp/Processing/Processors/Filters/OpacityProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/OpacityProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies an opacity filter matrix using the given amount. diff --git a/src/ImageSharp/Processing/Filters/Processors/PolaroidProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/PolaroidProcessor.cs new file mode 100644 index 0000000000..0a84eab8ba --- /dev/null +++ b/src/ImageSharp/Processing/Filters/Processors/PolaroidProcessor.cs @@ -0,0 +1,35 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors.Overlays; +using SixLabors.Primitives; + +namespace SixLabors.ImageSharp.Processing.Filters.Processors +{ + /// + /// Converts the colors of the image recreating an old Polaroid effect. + /// + /// The pixel format. + internal class PolaroidProcessor : FilterProcessor + where TPixel : struct, IPixel + { + private static readonly TPixel VeryDarkOrange = ColorBuilder.FromRGB(102, 34, 0); + private static readonly TPixel LightOrange = ColorBuilder.FromRGBA(255, 153, 102, 128); + + /// + /// Initializes a new instance of the class. + /// + public PolaroidProcessor() + : base(MatrixFilters.PolaroidFilter) + { + } + + /// + protected override void AfterFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + { + new VignetteProcessor(VeryDarkOrange).Apply(source, sourceRectangle, configuration); + new GlowProcessor(LightOrange, source.Width / 4F).Apply(source, sourceRectangle, configuration); + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/ProtanomalyProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/ProtanomalyProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/ProtanomalyProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/ProtanomalyProcessor.cs index b7b61d5e59..4801391227 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/ProtanomalyProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/ProtanomalyProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Protanomaly (Red-Weak) color blindness. diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/ProtanopiaProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/ProtanopiaProcessor.cs similarity index 90% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/ProtanopiaProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/ProtanopiaProcessor.cs index 54753f5b57..43f1c14ea8 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/ProtanopiaProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/ProtanopiaProcessor.cs @@ -1,10 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Numerics; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Protanopia (Red-Blind) color blindness. diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/README.md b/src/ImageSharp/Processing/Filters/Processors/README.md similarity index 100% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/README.md rename to src/ImageSharp/Processing/Filters/Processors/README.md diff --git a/src/ImageSharp/Processing/Processors/Filters/SaturateProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/SaturateProcessor.cs similarity index 86% rename from src/ImageSharp/Processing/Processors/Filters/SaturateProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/SaturateProcessor.cs index 44b3fe3ced..9a48cb2b51 100644 --- a/src/ImageSharp/Processing/Processors/Filters/SaturateProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/SaturateProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a saturation filter matrix using the given amount. @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// Initializes a new instance of the class. /// /// - /// A value of 0 is completely un-saturated. A value of 1 leaves the input unchanged. + /// A value of 0 is completely un-saturated. A value of 1 leaves the input unchanged. /// Other values are linear multipliers on the effect. Values of amount over 1 are allowed, providing super-saturated results /// /// The proportion of the conversion. Must be greater than or equal to 0. diff --git a/src/ImageSharp/Processing/Processors/Filters/SepiaProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/SepiaProcessor.cs similarity index 93% rename from src/ImageSharp/Processing/Processors/Filters/SepiaProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/SepiaProcessor.cs index b30d0fe052..2b3bf105bf 100644 --- a/src/ImageSharp/Processing/Processors/Filters/SepiaProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/SepiaProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Applies a sepia filter matrix using the given amount. diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/TritanomalyProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/TritanomalyProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/TritanomalyProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/TritanomalyProcessor.cs index 57f4d4fa83..cd2e382178 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/TritanomalyProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/TritanomalyProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Tritanomaly (Blue-Weak) color blindness. diff --git a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/TritanopiaProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/TritanopiaProcessor.cs similarity index 92% rename from src/ImageSharp/Processing/Processors/Filters/ColorBlindness/TritanopiaProcessor.cs rename to src/ImageSharp/Processing/Filters/Processors/TritanopiaProcessor.cs index b03a18cf76..ce4a079a27 100644 --- a/src/ImageSharp/Processing/Processors/Filters/ColorBlindness/TritanopiaProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/TritanopiaProcessor.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Filters.Processors { /// /// Converts the colors of the image recreating Tritanopia (Blue-Blind) color blindness. diff --git a/src/ImageSharp/Processing/ColorMatrix/Saturate.cs b/src/ImageSharp/Processing/Filters/SaturateExtensions.cs similarity index 82% rename from src/ImageSharp/Processing/ColorMatrix/Saturate.cs rename to src/ImageSharp/Processing/Filters/SaturateExtensions.cs index c7dd395aa3..282bdef64c 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Saturate.cs +++ b/src/ImageSharp/Processing/Filters/SaturateExtensions.cs @@ -2,15 +2,15 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the alteration of the saturation component to the type. /// - public static partial class ImageExtensions + public static class SaturateExtensions { /// /// Alters the saturation component of the image. @@ -25,10 +25,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Saturate(this IImageProcessingContext source, float amount) where TPixel : struct, IPixel - { - source.ApplyProcessor(new SaturateProcessor(amount)); - return source; - } + => source.ApplyProcessor(new SaturateProcessor(amount)); /// /// Alters the saturation component of the image. @@ -46,9 +43,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Saturate(this IImageProcessingContext source, float amount, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new SaturateProcessor(amount), rectangle); - return source; - } + => source.ApplyProcessor(new SaturateProcessor(amount), rectangle); } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/ColorMatrix/Sepia.cs b/src/ImageSharp/Processing/Filters/SepiaExtensions.cs similarity index 91% rename from src/ImageSharp/Processing/ColorMatrix/Sepia.cs rename to src/ImageSharp/Processing/Filters/SepiaExtensions.cs index 0d686f4dba..09d8c36843 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Sepia.cs +++ b/src/ImageSharp/Processing/Filters/SepiaExtensions.cs @@ -2,15 +2,15 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Filters.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Filters { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of sepia toning to the type. /// - public static partial class ImageExtensions + public static class SepiaExtensions { /// /// Applies sepia toning to the image. diff --git a/src/ImageSharp/Processing/Effects/BackgroundColor.cs b/src/ImageSharp/Processing/Overlays/BackgroundColor.cs similarity index 100% rename from src/ImageSharp/Processing/Effects/BackgroundColor.cs rename to src/ImageSharp/Processing/Overlays/BackgroundColor.cs diff --git a/src/ImageSharp/Processing/Overlays/Glow.cs b/src/ImageSharp/Processing/Overlays/Glow.cs index 0c3552b4d2..af80666d6f 100644 --- a/src/ImageSharp/Processing/Overlays/Glow.cs +++ b/src/ImageSharp/Processing/Overlays/Glow.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Processors.Overlays; using SixLabors.Primitives; namespace SixLabors.ImageSharp @@ -157,7 +158,7 @@ namespace SixLabors.ImageSharp /// The . private static IImageProcessingContext Glow(this IImageProcessingContext source, TPixel color, ValueSize radius, Rectangle rectangle, GraphicsOptions options) where TPixel : struct, IPixel - => source.ApplyProcessor(new GlowProcessor(source.MemoryManager, color, radius, options), rectangle); + => source.ApplyProcessor(new GlowProcessor(color, radius, options), rectangle); /// /// Applies a radial glow effect to an image. @@ -170,6 +171,6 @@ namespace SixLabors.ImageSharp /// The . private static IImageProcessingContext Glow(this IImageProcessingContext source, TPixel color, ValueSize radius, GraphicsOptions options) where TPixel : struct, IPixel - => source.ApplyProcessor(new GlowProcessor(source.MemoryManager, color, radius, options)); + => source.ApplyProcessor(new GlowProcessor(color, radius, options)); } } diff --git a/src/ImageSharp/Processing/Overlays/Vignette.cs b/src/ImageSharp/Processing/Overlays/Vignette.cs index 4b9f2f866c..ba2424d77a 100644 --- a/src/ImageSharp/Processing/Overlays/Vignette.cs +++ b/src/ImageSharp/Processing/Overlays/Vignette.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Processors.Overlays; using SixLabors.Primitives; namespace SixLabors.ImageSharp @@ -151,10 +152,10 @@ namespace SixLabors.ImageSharp private static IImageProcessingContext VignetteInternal(this IImageProcessingContext source, TPixel color, ValueSize radiusX, ValueSize radiusY, Rectangle rectangle, GraphicsOptions options) where TPixel : struct, IPixel - => source.ApplyProcessor(new VignetteProcessor(source.MemoryManager, color, radiusX, radiusY, options), rectangle); + => source.ApplyProcessor(new VignetteProcessor(color, radiusX, radiusY, options), rectangle); private static IImageProcessingContext VignetteInternal(this IImageProcessingContext source, TPixel color, ValueSize radiusX, ValueSize radiusY, GraphicsOptions options) where TPixel : struct, IPixel - => source.ApplyProcessor(new VignetteProcessor(source.MemoryManager, color, radiusX, radiusY, options)); + => source.ApplyProcessor(new VignetteProcessor(color, radiusX, radiusY, options)); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs b/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs index 7257bd6643..a089ffe1a1 100644 --- a/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs @@ -35,9 +35,9 @@ namespace SixLabors.ImageSharp.Processing ImageFrame sourceFrame = source.Frames[i]; ImageFrame clonedFrame = clone.Frames[i]; - this.BeforeApply(sourceFrame, clonedFrame, sourceRectangle, configuration); - this.OnApply(sourceFrame, clonedFrame, sourceRectangle, configuration); - this.AfterApply(sourceFrame, clonedFrame, sourceRectangle, configuration); + this.BeforeFrameApply(sourceFrame, clonedFrame, sourceRectangle, configuration); + this.OnFrameApply(sourceFrame, clonedFrame, sourceRectangle, configuration); + this.AfterFrameApply(sourceFrame, clonedFrame, sourceRectangle, configuration); } this.AfterImageApply(source, clone, sourceRectangle); @@ -96,36 +96,33 @@ namespace SixLabors.ImageSharp.Processing /// /// This method is called before the process is applied to prepare the processor. - /// TODO: We should probably name this 'BeforeFrameApply' /// /// The source image. Cannot be null. /// The cloned/destination image. Cannot be null. /// The structure that specifies the portion of the image object to draw. /// The configuration. - protected virtual void BeforeApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) + protected virtual void BeforeFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) { } /// /// Applies the process to the specified portion of the specified at the specified location /// and with the specified size. - /// TODO: We should probably name this 'ApplyToFrame' /// /// The source image. Cannot be null. /// The cloned/destination image. Cannot be null. /// The structure that specifies the portion of the image object to draw. /// The configuration. - protected abstract void OnApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration); + protected abstract void OnFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration); /// /// This method is called after the process is applied to prepare the processor. - /// TODO: We should probably name this 'AfterFrameApply' /// /// The source image. Cannot be null. /// The cloned/destination image. Cannot be null. /// The structure that specifies the portion of the image object to draw. /// The configuration. - protected virtual void AfterApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) + protected virtual void AfterFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) { } diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs deleted file mode 100644 index 8e4cdd6b5a..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Kayyali operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class KayyaliProcessor : EdgeDetector2DProcessor - where TPixel : struct, IPixel - { - /// - /// The horizontal gradient operator. - /// - private static readonly Fast2DArray KayyaliX = - new float[,] - { - { 6, 0, -6 }, - { 0, 0, 0 }, - { -6, 0, 6 } - }; - - /// - /// The vertical gradient operator. - /// - private static readonly Fast2DArray KayyaliY = - new float[,] - { - { -6, 0, 6 }, - { 0, 0, 0 }, - { 6, 0, -6 } - }; - - /// - /// Initializes a new instance of the class. - /// - public KayyaliProcessor() - : base(KayyaliX, KayyaliY) - { - } - } -} diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs deleted file mode 100644 index c0a3b35954..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Kirsch operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class KirschProcessor : EdgeDetectorCompassProcessor - where TPixel : struct, IPixel - { - /// - /// The North gradient operator - /// - private static readonly Fast2DArray KirschNorth = - new float[,] - { - { 5, 5, 5 }, - { -3, 0, -3 }, - { -3, -3, -3 } - }; - - /// - /// The NorthWest gradient operator - /// - private static readonly Fast2DArray KirschNorthWest = - new float[,] - { - { 5, 5, -3 }, - { 5, 0, -3 }, - { -3, -3, -3 } - }; - - /// - /// The West gradient operator - /// - private static readonly Fast2DArray KirschWest = - new float[,] - { - { 5, -3, -3 }, - { 5, 0, -3 }, - { 5, -3, -3 } - }; - - /// - /// The SouthWest gradient operator - /// - private static readonly Fast2DArray KirschSouthWest = - new float[,] - { - { -3, -3, -3 }, - { 5, 0, -3 }, - { 5, 5, -3 } - }; - - /// - /// The South gradient operator - /// - private static readonly Fast2DArray KirschSouth = - new float[,] - { - { -3, -3, -3 }, - { -3, 0, -3 }, - { 5, 5, 5 } - }; - - /// - /// The SouthEast gradient operator - /// - private static readonly Fast2DArray KirschSouthEast = - new float[,] - { - { -3, -3, -3 }, - { -3, 0, 5 }, - { -3, 5, 5 } - }; - - /// - /// The East gradient operator - /// - private static readonly Fast2DArray KirschEast = - new float[,] - { - { -3, -3, 5 }, - { -3, 0, 5 }, - { -3, -3, 5 } - }; - - /// - /// The NorthEast gradient operator - /// - private static readonly Fast2DArray KirschNorthEast = - new float[,] - { - { -3, 5, 5 }, - { -3, 0, 5 }, - { -3, -3, -3 } - }; - - /// - public override Fast2DArray North => KirschNorth; - - /// - public override Fast2DArray NorthWest => KirschNorthWest; - - /// - public override Fast2DArray West => KirschWest; - - /// - public override Fast2DArray SouthWest => KirschSouthWest; - - /// - public override Fast2DArray South => KirschSouth; - - /// - public override Fast2DArray SouthEast => KirschSouthEast; - - /// - public override Fast2DArray East => KirschEast; - - /// - public override Fast2DArray NorthEast => KirschNorthEast; - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs deleted file mode 100644 index 1b5c563187..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Laplacian 3 x 3 operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class Laplacian3X3Processor : EdgeDetectorProcessor - where TPixel : struct, IPixel - { - /// - /// The 2d gradient operator. - /// - private static readonly Fast2DArray Laplacian3X3XY = - new float[,] - { - { -1, -1, -1 }, - { -1, 8, -1 }, - { -1, -1, -1 } - }; - - /// - /// Initializes a new instance of the class. - /// - public Laplacian3X3Processor() - : base(Laplacian3X3XY) - { - } - } -} diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs deleted file mode 100644 index 11438fe8db..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Laplacian 5 x 5 operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class Laplacian5X5Processor : EdgeDetectorProcessor - where TPixel : struct, IPixel - { - /// - /// The 2d gradient operator. - /// - private static readonly Fast2DArray Laplacian5X5XY = - new float[,] - { - { -1, -1, -1, -1, -1 }, - { -1, -1, -1, -1, -1 }, - { -1, -1, 24, -1, -1 }, - { -1, -1, -1, -1, -1 }, - { -1, -1, -1, -1, -1 } - }; - - /// - /// Initializes a new instance of the class. - /// - public Laplacian5X5Processor() - : base(Laplacian5X5XY) - { - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs deleted file mode 100644 index 424c01137e..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Laplacian of Gaussian operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class LaplacianOfGaussianProcessor : EdgeDetectorProcessor - where TPixel : struct, IPixel - { - /// - /// The 2d gradient operator. - /// - private static readonly Fast2DArray LaplacianOfGaussianXY = - new float[,] - { - { 0, 0, -1, 0, 0 }, - { 0, -1, -2, -1, 0 }, - { -1, -2, 16, -2, -1 }, - { 0, -1, -2, -1, 0 }, - { 0, 0, -1, 0, 0 } - }; - - /// - /// Initializes a new instance of the class. - /// - public LaplacianOfGaussianProcessor() - : base(LaplacianOfGaussianXY) - { - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs deleted file mode 100644 index 0d2e9b2066..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Prewitt operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class PrewittProcessor : EdgeDetector2DProcessor - where TPixel : struct, IPixel - { - /// - /// The horizontal gradient operator. - /// - private static readonly Fast2DArray PrewittX = - new float[,] - { - { -1, 0, 1 }, - { -1, 0, 1 }, - { -1, 0, 1 } - }; - - /// - /// The vertical gradient operator. - /// - private static readonly Fast2DArray PrewittY = - new float[,] - { - { 1, 1, 1 }, - { 0, 0, 0 }, - { -1, -1, -1 } - }; - - /// - /// Initializes a new instance of the class. - /// - public PrewittProcessor() - : base(PrewittX, PrewittY) - { - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs deleted file mode 100644 index 09aa8ecb6c..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Roberts Cross operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class RobertsCrossProcessor : EdgeDetector2DProcessor - where TPixel : struct, IPixel - { - /// - /// The horizontal gradient operator. - /// - private static readonly Fast2DArray RobertsCrossX = - new float[,] - { - { 1, 0 }, - { 0, -1 } - }; - - /// - /// The vertical gradient operator. - /// - private static readonly Fast2DArray RobertsCrossY = - new float[,] - { - { 0, 1 }, - { -1, 0 } - }; - - /// - /// Initializes a new instance of the class. - /// - public RobertsCrossProcessor() - : base(RobertsCrossX, RobertsCrossY) - { - } - } -} diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs deleted file mode 100644 index 18f8cbf18c..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Kirsch operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class RobinsonProcessor : EdgeDetectorCompassProcessor - where TPixel : struct, IPixel - { - /// - /// The North gradient operator - /// - private static readonly Fast2DArray RobinsonNorth = - new float[,] - { - { 1, 2, 1 }, - { 0, 0, 0 }, - { -1, -2, -1 } - }; - - /// - /// The NorthWest gradient operator - /// - private static readonly Fast2DArray RobinsonNorthWest = - new float[,] - { - { 2, 1, 0 }, - { 1, 0, -1 }, - { 0, -1, -2 } - }; - - /// - /// The West gradient operator - /// - private static readonly Fast2DArray RobinsonWest = - new float[,] - { - { 1, 0, -1 }, - { 2, 0, -2 }, - { 1, 0, -1 } - }; - - /// - /// The SouthWest gradient operator - /// - private static readonly Fast2DArray RobinsonSouthWest = - new float[,] - { - { 0, -1, -2 }, - { 1, 0, -1 }, - { 2, 1, 0 } - }; - - /// - /// The South gradient operator - /// - private static readonly Fast2DArray RobinsonSouth = - new float[,] - { - { -1, -2, -1 }, - { 0, 0, 0 }, - { 1, 2, 1 } - }; - - /// - /// The SouthEast gradient operator - /// - private static readonly Fast2DArray RobinsonSouthEast = - new float[,] - { - { -2, -1, 0 }, - { -1, 0, 1 }, - { 0, 1, 2 } - }; - - /// - /// The East gradient operator - /// - private static readonly Fast2DArray RobinsonEast = - new float[,] - { - { -1, 0, 1 }, - { -2, 0, 2 }, - { -1, 0, 1 } - }; - - /// - /// The NorthEast gradient operator - /// - private static readonly Fast2DArray RobinsonNorthEast = - new float[,] - { - { 0, 1, 2 }, - { -1, 0, 1 }, - { -2, -1, 0 } - }; - - /// - public override Fast2DArray North => RobinsonNorth; - - /// - public override Fast2DArray NorthWest => RobinsonNorthWest; - - /// - public override Fast2DArray West => RobinsonWest; - - /// - public override Fast2DArray SouthWest => RobinsonSouthWest; - - /// - public override Fast2DArray South => RobinsonSouth; - - /// - public override Fast2DArray SouthEast => RobinsonSouthEast; - - /// - public override Fast2DArray East => RobinsonEast; - - /// - public override Fast2DArray NorthEast => RobinsonNorthEast; - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs deleted file mode 100644 index e299d3f807..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Scharr operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class ScharrProcessor : EdgeDetector2DProcessor - where TPixel : struct, IPixel - { - /// - /// The horizontal gradient operator. - /// - private static readonly Fast2DArray ScharrX = - new float[,] - { - { -3, 0, 3 }, - { -10, 0, 10 }, - { -3, 0, 3 } - }; - - /// - /// The vertical gradient operator. - /// - private static readonly Fast2DArray ScharrY = - new float[,] - { - { 3, 10, 3 }, - { 0, 0, 0 }, - { -3, -10, -3 } - }; - - /// - /// Initializes a new instance of the class. - /// - public ScharrProcessor() - : base(ScharrX, ScharrY) - { - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs deleted file mode 100644 index e975e4ff6c..0000000000 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics.CodeAnalysis; -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// The Sobel operator filter. - /// - /// - /// The pixel format. - [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] - internal class SobelProcessor : EdgeDetector2DProcessor - where TPixel : struct, IPixel - { - /// - /// The horizontal gradient operator. - /// - private static readonly Fast2DArray SobelX = - new float[,] - { - { -1, 0, 1 }, - { -2, 0, 2 }, - { -1, 0, 1 } - }; - - /// - /// The vertical gradient operator. - /// - private static readonly Fast2DArray SobelY = - new float[,] - { - { -1, -2, -1 }, - { 0, 0, 0 }, - { 1, 2, 1 } - }; - - /// - /// Initializes a new instance of the class. - /// - public SobelProcessor() - : base(SobelX, SobelY) - { - } - } -} diff --git a/src/ImageSharp/Processing/Processors/DelegateProcessor.cs b/src/ImageSharp/Processing/Processors/DelegateProcessor.cs index f17c39681e..0bfc149772 100644 --- a/src/ImageSharp/Processing/Processors/DelegateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/DelegateProcessor.cs @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Processing } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { // NOP, we did all we wanted to do inside BeforeImageApply } diff --git a/src/ImageSharp/Processing/Processors/Filters/LomographProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/LomographProcessor.cs deleted file mode 100644 index 33c4338d58..0000000000 --- a/src/ImageSharp/Processing/Processors/Filters/LomographProcessor.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System.Numerics; - -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.Primitives; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// Converts the colors of the image recreating an old Lomograph effect. - /// - /// The pixel format. - internal class LomographProcessor : FilterProcessor - where TPixel : struct, IPixel - { - private static readonly TPixel VeryDarkGreen = ColorBuilder.FromRGBA(0, 10, 0, 255); - - private readonly MemoryManager memoryManager; - - private readonly GraphicsOptions options; - - /// - /// Initializes a new instance of the class. - /// - /// The to use for buffer allocations. - /// The options effecting blending and composition. - public LomographProcessor(MemoryManager memoryManager, GraphicsOptions options) - : base(MatrixFilters.LomographFilter) - { - this.memoryManager = memoryManager; - this.options = options; - } - - /// - protected override void AfterApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) - { - new VignetteProcessor(this.memoryManager, VeryDarkGreen, this.options).Apply(source, sourceRectangle, configuration); - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs deleted file mode 100644 index 152d586afe..0000000000 --- a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.Primitives; - -namespace SixLabors.ImageSharp.Processing.Processors -{ - /// - /// Converts the colors of the image recreating an old Polaroid effect. - /// - /// The pixel format. - internal class PolaroidProcessor : FilterProcessor - where TPixel : struct, IPixel - { - private static readonly TPixel VeryDarkOrange = ColorBuilder.FromRGB(102, 34, 0); - private static readonly TPixel LightOrange = ColorBuilder.FromRGBA(255, 153, 102, 128); - - private readonly MemoryManager memoryManager; - - private readonly GraphicsOptions options; - - /// - /// Initializes a new instance of the class. - /// - /// The to use for buffer allocations. - /// The options effecting blending and composition. - public PolaroidProcessor(MemoryManager memoryManager, GraphicsOptions options) - : base(MatrixFilters.PolaroidFilter) - { - this.memoryManager = memoryManager; - this.options = options; - } - - /// - protected override void AfterApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) - { - new VignetteProcessor(this.memoryManager, VeryDarkOrange, this.options).Apply(source, sourceRectangle, configuration); - new GlowProcessor(this.memoryManager, LightOrange, source.Width / 4F, this.options).Apply(source, sourceRectangle, configuration); - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/ImageProcessor.cs b/src/ImageSharp/Processing/Processors/ImageProcessor.cs index cab99112c1..124b345597 100644 --- a/src/ImageSharp/Processing/Processors/ImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ImageProcessor.cs @@ -52,9 +52,9 @@ namespace SixLabors.ImageSharp.Processing { try { - this.BeforeApply(source, sourceRectangle, configuration); - this.OnApply(source, sourceRectangle, configuration); - this.AfterApply(source, sourceRectangle, configuration); + this.BeforeFrameApply(source, sourceRectangle, configuration); + this.OnFrameApply(source, sourceRectangle, configuration); + this.AfterFrameApply(source, sourceRectangle, configuration); } #if DEBUG catch (Exception) @@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Processing /// The source image. Cannot be null. /// The structure that specifies the portion of the image object to draw. /// The configuration. - protected virtual void BeforeApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected virtual void BeforeFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { } @@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Processing /// The source image. Cannot be null. /// The structure that specifies the portion of the image object to draw. /// The configuration. - protected abstract void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration); + protected abstract void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration); /// /// This method is called after the process is applied to prepare the processor. @@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Processing /// The source image. Cannot be null. /// The structure that specifies the portion of the image object to draw. /// The configuration. - protected virtual void AfterApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected virtual void AfterFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { } diff --git a/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs similarity index 86% rename from src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs rename to src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs index 720b876913..d07dcbeed8 100644 --- a/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs @@ -19,25 +19,23 @@ namespace SixLabors.ImageSharp.Processing.Processors { private readonly MemoryManager memoryManager; - private readonly GraphicsOptions options; - /// /// Initializes a new instance of the class. /// /// The to use for buffer allocations. /// The to set the background color to. - /// The options defining blending algorithum and amount. + /// The options defining blending algorithm and amount. public BackgroundColorProcessor(MemoryManager memoryManager, TPixel color, GraphicsOptions options) { this.Value = color; this.memoryManager = memoryManager; - this.options = options; + this.GraphicsOptions = options; } /// /// Gets the Graphics options to alter how processor is applied. /// - public GraphicsOptions GraphicsOptions => this.options; + public GraphicsOptions GraphicsOptions { get; } /// /// Gets the background color value. @@ -45,7 +43,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public TPixel Value { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; @@ -81,10 +79,10 @@ namespace SixLabors.ImageSharp.Processing.Processors for (int i = 0; i < width; i++) { colorSpan[i] = this.Value; - amountSpan[i] = this.options.BlendPercentage; + amountSpan[i] = this.GraphicsOptions.BlendPercentage; } - PixelBlender blender = PixelOperations.Instance.GetPixelBlender(this.options.BlenderMode); + PixelBlender blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions.BlenderMode); Parallel.For( minY, maxY, @@ -93,7 +91,7 @@ namespace SixLabors.ImageSharp.Processing.Processors { Span destination = source.GetPixelRowSpan(y - startY).Slice(minX - startX, width); - // This switched color & destination in the 2nd and 3rd places because we are applying the target colour under the current one + // This switched color & destination in the 2nd and 3rd places because we are applying the target color under the current one blender.Blend(this.memoryManager, destination, colors.Span, destination, amount.Span); }); } diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs index 9ab301718c..d08283a0fe 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs @@ -10,7 +10,7 @@ using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Processors.Overlays { /// /// An that applies a radial glow effect an . @@ -19,31 +19,50 @@ namespace SixLabors.ImageSharp.Processing.Processors internal class GlowProcessor : ImageProcessor where TPixel : struct, IPixel { - private readonly MemoryManager memoryManager; - - private readonly GraphicsOptions options; private readonly PixelBlender blender; /// /// Initializes a new instance of the class. /// - /// The to use for buffer allocations. + /// The color or the glow. + public GlowProcessor(TPixel color) + { + this.GlowColor = color; + this.GraphicsOptions = GraphicsOptions.Default; + this.blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions.BlenderMode); + } + + /// + /// Initializes a new instance of the class. + /// + /// The color or the glow. + /// The radius of the glow. + public GlowProcessor(TPixel color, ValueSize radius) + { + this.GlowColor = color; + this.Radius = radius; + this.GraphicsOptions = GraphicsOptions.Default; + this.blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions.BlenderMode); + } + + /// + /// Initializes a new instance of the class. + /// /// The color or the glow. /// The radius of the glow. /// The options effecting blending and composition. - public GlowProcessor(MemoryManager memoryManager, TPixel color, ValueSize radius, GraphicsOptions options) + public GlowProcessor(TPixel color, ValueSize radius, GraphicsOptions options) { - this.memoryManager = memoryManager; - this.options = options; this.GlowColor = color; this.Radius = radius; - this.blender = PixelOperations.Instance.GetPixelBlender(this.options.BlenderMode); + this.blender = PixelOperations.Instance.GetPixelBlender(options.BlenderMode); + this.GraphicsOptions = options; } /// - /// Gets the Graphics options to alter how processor is applied. + /// Gets the options effecting blending and composition /// - public GraphicsOptions GraphicsOptions => this.options; + public GraphicsOptions GraphicsOptions { get; } /// /// Gets or sets the glow color to apply. @@ -56,7 +75,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public ValueSize Radius { get; set; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; @@ -87,7 +106,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } int width = maxX - minX; - using (IBuffer rowColors = this.memoryManager.Allocate(width)) + using (IBuffer rowColors = source.MemoryManager.Allocate(width)) { // Be careful! Do not capture rowColorsSpan in the lambda below! Span rowColorsSpan = rowColors.Span; @@ -103,7 +122,7 @@ namespace SixLabors.ImageSharp.Processing.Processors configuration.ParallelOptions, y => { - using (IBuffer amounts = this.memoryManager.Allocate(width)) + using (IBuffer amounts = source.MemoryManager.Allocate(width)) { Span amountsSpan = amounts.Span; int offsetY = y - startY; @@ -111,12 +130,12 @@ namespace SixLabors.ImageSharp.Processing.Processors for (int i = 0; i < width; i++) { float distance = Vector2.Distance(centre, new Vector2(i + offsetX, offsetY)); - amountsSpan[i] = (this.options.BlendPercentage * (1 - (.95F * (distance / maxDistance)))).Clamp(0, 1); + amountsSpan[i] = (this.GraphicsOptions.BlendPercentage * (1 - (.95F * (distance / maxDistance)))).Clamp(0, 1); } Span destination = source.GetPixelRowSpan(offsetY).Slice(offsetX, width); - this.blender.Blend(this.memoryManager, destination, destination, rowColors.Span, amountsSpan); + this.blender.Blend(source.MemoryManager, destination, destination, rowColors.Span, amountsSpan); } }); } diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs index d47211f0cb..3a2fc595c8 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs @@ -10,7 +10,7 @@ using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Processors.Overlays { /// /// An that applies a radial vignette effect to an . @@ -19,47 +19,51 @@ namespace SixLabors.ImageSharp.Processing.Processors internal class VignetteProcessor : ImageProcessor where TPixel : struct, IPixel { - private readonly MemoryManager memoryManager; - - private readonly GraphicsOptions options; private readonly PixelBlender blender; /// /// Initializes a new instance of the class. /// - /// The to use for buffer allocations. /// The color of the vignette. - /// The x-radius. - /// The y-radius. + public VignetteProcessor(TPixel color) + { + this.VignetteColor = color; + this.GraphicsOptions = GraphicsOptions.Default; + this.blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions.BlenderMode); + } + + /// + /// Initializes a new instance of the class. + /// + /// The color of the vignette. /// The options effecting blending and composition. - public VignetteProcessor(MemoryManager memoryManager, TPixel color, ValueSize radiusX, ValueSize radiusY, GraphicsOptions options) + public VignetteProcessor(TPixel color, GraphicsOptions options) { this.VignetteColor = color; - this.RadiusX = radiusX; - this.RadiusY = radiusY; - this.memoryManager = memoryManager; - this.options = options; - this.blender = PixelOperations.Instance.GetPixelBlender(this.options.BlenderMode); + this.GraphicsOptions = options; + this.blender = PixelOperations.Instance.GetPixelBlender(options.BlenderMode); } /// /// Initializes a new instance of the class. /// - /// The to use for buffer allocations. /// The color of the vignette. + /// The x-radius. + /// The y-radius. /// The options effecting blending and composition. - public VignetteProcessor(MemoryManager memoryManager, TPixel color, GraphicsOptions options) + public VignetteProcessor(TPixel color, ValueSize radiusX, ValueSize radiusY, GraphicsOptions options) { this.VignetteColor = color; - this.memoryManager = memoryManager; - this.options = options; - this.blender = PixelOperations.Instance.GetPixelBlender(this.options.BlenderMode); + this.RadiusX = radiusX; + this.RadiusY = radiusY; + this.blender = PixelOperations.Instance.GetPixelBlender(options.BlenderMode); + this.GraphicsOptions = options; } /// - /// Gets the Graphics options to alter how processor is applied. + /// Gets the options effecting blending and composition /// - public GraphicsOptions GraphicsOptions => this.options; + public GraphicsOptions GraphicsOptions { get; } /// /// Gets or sets the vignette color to apply. @@ -77,7 +81,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public ValueSize RadiusY { get; set; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; @@ -86,10 +90,10 @@ namespace SixLabors.ImageSharp.Processing.Processors TPixel vignetteColor = this.VignetteColor; Vector2 centre = Rectangle.Center(sourceRectangle); - float finalradiusX = this.RadiusX.Calculate(source.Size()); - float finalradiusY = this.RadiusY.Calculate(source.Size()); - float rX = finalradiusX > 0 ? MathF.Min(finalradiusX, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F; - float rY = finalradiusY > 0 ? MathF.Min(finalradiusY, sourceRectangle.Height * .5F) : sourceRectangle.Height * .5F; + float finalRadiusX = this.RadiusX.Calculate(source.Size()); + float finalRadiusY = this.RadiusY.Calculate(source.Size()); + float rX = finalRadiusX > 0 ? MathF.Min(finalRadiusX, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F; + float rY = finalRadiusY > 0 ? MathF.Min(finalRadiusY, sourceRectangle.Height * .5F) : sourceRectangle.Height * .5F; float maxDistance = MathF.Sqrt((rX * rX) + (rY * rY)); // Align start/end positions. @@ -110,7 +114,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } int width = maxX - minX; - using (IBuffer rowColors = this.memoryManager.Allocate(width)) + using (IBuffer rowColors = source.MemoryManager.Allocate(width)) { // Be careful! Do not capture rowColorsSpan in the lambda below! Span rowColorsSpan = rowColors.Span; @@ -126,7 +130,7 @@ namespace SixLabors.ImageSharp.Processing.Processors configuration.ParallelOptions, y => { - using (IBuffer amounts = this.memoryManager.Allocate(width)) + using (IBuffer amounts = source.MemoryManager.Allocate(width)) { Span amountsSpan = amounts.Span; int offsetY = y - startY; @@ -134,12 +138,12 @@ namespace SixLabors.ImageSharp.Processing.Processors for (int i = 0; i < width; i++) { float distance = Vector2.Distance(centre, new Vector2(i + offsetX, offsetY)); - amountsSpan[i] = (this.options.BlendPercentage * (.9F * (distance / maxDistance))).Clamp(0, 1); + amountsSpan[i] = (this.GraphicsOptions.BlendPercentage * (.9F * (distance / maxDistance))).Clamp(0, 1); } Span destination = source.GetPixelRowSpan(offsetY).Slice(offsetX, width); - this.blender.Blend(this.memoryManager, destination, destination, rowColors.Span, amountsSpan); + this.blender.Blend(source.MemoryManager, destination, destination, rowColors.Span, amountsSpan); } }); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor.cs index ac11e0dfb3..864001d075 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor.cs @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void OnApply( + protected override void OnFrameApply( ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, diff --git a/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs index 7f811eebc1..c118a7e866 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void OnApply(ImageFrame sourceBase, Rectangle sourceRectangle, Configuration config) + protected override void OnFrameApply(ImageFrame sourceBase, Rectangle sourceRectangle, Configuration config) { // all processing happens at the image level within BeforeImageApply(); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs index c04014ae35..ff5011bdbe 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs @@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public Rectangle CropRectangle { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { if (this.CropRectangle == sourceRectangle) { diff --git a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs index d2a08daba6..f263209026 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs @@ -3,6 +3,8 @@ using System; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Binarization.Processors; +using SixLabors.ImageSharp.Processing.Convolution.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Processors @@ -34,12 +36,12 @@ namespace SixLabors.ImageSharp.Processing.Processors public float Threshold { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { using (ImageFrame temp = source.Clone()) { // Detect the edges. - new SobelProcessor().Apply(temp, sourceRectangle, configuration); + new SobelProcessor(false).Apply(temp, sourceRectangle, configuration); // Apply threshold binarization filter. new BinaryThresholdProcessor(this.Threshold).Apply(temp, sourceRectangle, configuration); diff --git a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs index 9b8b785b58..6c2705979d 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs @@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Processing.Processors public FlipType FlipType { get; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { switch (this.FlipType) { diff --git a/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs index e16cd9ee84..dc0970a6cd 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void OnApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) { int height = this.TargetDimensions.Height; int width = this.TargetDimensions.Width; diff --git a/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs index 2e73920baa..dfb7b84b66 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs @@ -219,7 +219,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void BeforeApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) + protected override void BeforeFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) { if (!(this.Sampler is NearestNeighborResampler)) { @@ -237,7 +237,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void OnApply(ImageFrame source, ImageFrame cloned, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, ImageFrame cloned, Rectangle sourceRectangle, Configuration configuration) { // Jump out, we'll deal with that later. if (source.Width == cloned.Width && source.Height == cloned.Height && sourceRectangle == this.ResizeRectangle) @@ -366,9 +366,9 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - protected override void AfterApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) + protected override void AfterFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) { - base.AfterApply(source, destination, sourceRectangle, configuration); + base.AfterFrameApply(source, destination, sourceRectangle, configuration); // TODO: An exception in the processing chain can leave these buffers undisposed. We should consider making image processors IDisposable! this.horizontalWeights?.Dispose(); diff --git a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs index 824ae4310f..fabae88fd4 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// The angle of rotation in degrees. /// The source image size public RotateProcessor(float degrees, Size sourceSize) - : this(degrees, KnownResamplers.Bicubic, sourceSize) + : this(degrees, Resamplers.Bicubic, sourceSize) { } @@ -46,14 +46,14 @@ namespace SixLabors.ImageSharp.Processing.Processors public float Degrees { get; } /// - protected override void OnApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) { if (this.OptimizedApply(source, destination, configuration)) { return; } - base.OnApply(source, destination, sourceRectangle, configuration); + base.OnFrameApply(source, destination, sourceRectangle, configuration); } /// diff --git a/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs index 8e3ab7c34f..ad0aad7bbb 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs @@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// The angle in degrees to perform the skew along the y-axis. /// The source image size public SkewProcessor(float degreesX, float degreesY, Size sourceSize) - : this(degreesX, degreesY, KnownResamplers.Bicubic, sourceSize) + : this(degreesX, degreesY, Resamplers.Bicubic, sourceSize) { } diff --git a/src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs b/src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs index f13fa77c99..03adf58c34 100644 --- a/src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs +++ b/src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs @@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Processing /// /// Gets or sets the sampler to perform the resize operation. /// - public IResampler Sampler { get; set; } = KnownResamplers.Bicubic; + public IResampler Sampler { get; set; } = Resamplers.Bicubic; /// /// Gets or sets a value indicating whether to compress diff --git a/src/ImageSharp/Processing/Transforms/Pad.cs b/src/ImageSharp/Processing/Transforms/Pad.cs index 2f637aa162..1c990f82ea 100644 --- a/src/ImageSharp/Processing/Transforms/Pad.cs +++ b/src/ImageSharp/Processing/Transforms/Pad.cs @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp { Size = new Size(width, height), Mode = ResizeMode.BoxPad, - Sampler = KnownResamplers.NearestNeighbor + Sampler = Resamplers.NearestNeighbor }; return Resize(source, options); diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/KnownResamplers.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Resamplers.cs similarity index 99% rename from src/ImageSharp/Processing/Transforms/Resamplers/KnownResamplers.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/Resamplers.cs index 2da98497b5..599ae2dadb 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/KnownResamplers.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/Resamplers.cs @@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Processing /// /// Contains reusable static instances of known resampling algorithms /// - public static class KnownResamplers + public static class Resamplers { /// /// Gets the Bicubic sampler that implements the bicubic kernel algorithm W(x) diff --git a/src/ImageSharp/Processing/Transforms/Resize.cs b/src/ImageSharp/Processing/Transforms/Resize.cs index 285f3206dc..b94addb27b 100644 --- a/src/ImageSharp/Processing/Transforms/Resize.cs +++ b/src/ImageSharp/Processing/Transforms/Resize.cs @@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, Size size) where TPixel : struct, IPixel - => Resize(source, size.Width, size.Height, KnownResamplers.Bicubic, false); + => Resize(source, size.Width, size.Height, Resamplers.Bicubic, false); /// /// Resizes an image to the given . @@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, Size size, bool compand) where TPixel : struct, IPixel - => Resize(source, size.Width, size.Height, KnownResamplers.Bicubic, compand); + => Resize(source, size.Width, size.Height, Resamplers.Bicubic, compand); /// /// Resizes an image to the given width and height. @@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, int width, int height) where TPixel : struct, IPixel - => Resize(source, width, height, KnownResamplers.Bicubic, false); + => Resize(source, width, height, Resamplers.Bicubic, false); /// /// Resizes an image to the given width and height. @@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, int width, int height, bool compand) where TPixel : struct, IPixel - => Resize(source, width, height, KnownResamplers.Bicubic, compand); + => Resize(source, width, height, Resamplers.Bicubic, compand); /// /// Resizes an image to the given width and height with the given sampler. diff --git a/src/ImageSharp/Processing/Transforms/Rotate.cs b/src/ImageSharp/Processing/Transforms/Rotate.cs index faecdf91f9..bbaa762a22 100644 --- a/src/ImageSharp/Processing/Transforms/Rotate.cs +++ b/src/ImageSharp/Processing/Transforms/Rotate.cs @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp /// The public static IImageProcessingContext Rotate(this IImageProcessingContext source, float degrees) where TPixel : struct, IPixel - => Rotate(source, degrees, KnownResamplers.Bicubic); + => Rotate(source, degrees, Resamplers.Bicubic); /// /// Rotates an image by the given angle in degrees using the specified sampling algorithm. diff --git a/src/ImageSharp/Processing/Transforms/Skew.cs b/src/ImageSharp/Processing/Transforms/Skew.cs index fb054211a0..f4a92e0100 100644 --- a/src/ImageSharp/Processing/Transforms/Skew.cs +++ b/src/ImageSharp/Processing/Transforms/Skew.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp /// The public static IImageProcessingContext Skew(this IImageProcessingContext source, float degreesX, float degreesY) where TPixel : struct, IPixel - => Skew(source, degreesX, degreesY, KnownResamplers.Bicubic); + => Skew(source, degreesX, degreesY, Resamplers.Bicubic); /// /// Skews an image by the given angles in degrees using the specified sampling algorithm. diff --git a/src/ImageSharp/Processing/Transforms/Transform.cs b/src/ImageSharp/Processing/Transforms/Transform.cs index 66d5d5de7e..b82713ca94 100644 --- a/src/ImageSharp/Processing/Transforms/Transform.cs +++ b/src/ImageSharp/Processing/Transforms/Transform.cs @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp /// The public static IImageProcessingContext Transform(this IImageProcessingContext source, Matrix3x2 matrix) where TPixel : struct, IPixel - => Transform(source, matrix, KnownResamplers.Bicubic); + => Transform(source, matrix, Resamplers.Bicubic); /// /// Transforms an image by the given matrix using the specified sampling algorithm. @@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp /// The internal static IImageProcessingContext Transform(this IImageProcessingContext source, Matrix4x4 matrix) where TPixel : struct, IPixel - => Transform(source, matrix, KnownResamplers.Bicubic); + => Transform(source, matrix, Resamplers.Bicubic); /// /// Applies a projective transform to the image by the given matrix using the specified sampling algorithm. diff --git a/src/ImageSharp/Quantizers/QuantizerBase{TPixel}.cs b/src/ImageSharp/Quantizers/QuantizerBase{TPixel}.cs index 0b41edf98d..84dfd8dd5c 100644 --- a/src/ImageSharp/Quantizers/QuantizerBase{TPixel}.cs +++ b/src/ImageSharp/Quantizers/QuantizerBase{TPixel}.cs @@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Quantizers.Base public bool Dither { get; set; } = true; /// - public IErrorDiffuser DitherType { get; set; } = KnownDiffusers.FloydSteinberg; + public IErrorDiffuser DitherType { get; set; } = Diffusers.FloydSteinberg; /// public virtual QuantizedImage Quantize(ImageFrame image, int maxColors) diff --git a/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs b/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs index f65957128c..9a208e6159 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Convolution; using CoreImage = ImageSharp.Image; @@ -38,17 +39,17 @@ namespace SixLabors.ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp DetectEdges")] public void ImageProcessorCoreDetectEdges() { - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Kayyali)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Kayyali)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Kirsch)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Lapacian3X3)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Lapacian5X5)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.LaplacianOfGaussian)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Prewitt)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.RobertsCross)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Robinson)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Scharr)); - this.image.Mutate(x => x.DetectEdges(EdgeDetection.Sobel)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Kayyali)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Kayyali)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Kirsch)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Laplacian3x3)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Laplacian5x5)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.LaplacianOfGaussian)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Prewitt)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.RobertsCross)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Robinson)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Scharr)); + this.image.Mutate(x => x.DetectEdges(EdgeDetectionOperators.Sobel)); } } } diff --git a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs index 5f4e2d75b4..b14630cea8 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs @@ -19,6 +19,7 @@ namespace SixLabors.ImageSharp.Benchmarks using SixLabors.Primitives; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Advanced; + using SixLabors.ImageSharp.Processing.Processors.Overlays; public class Glow : BenchmarkBase { @@ -28,7 +29,7 @@ namespace SixLabors.ImageSharp.Benchmarks [GlobalSetup] public void Setup() { - this.bulk = new GlowProcessor(Configuration.Default.MemoryManager, NamedColors.Beige, 800 * .5f, GraphicsOptions.Default); + this.bulk = new GlowProcessor(NamedColors.Beige, 800 * .5f, GraphicsOptions.Default); this.parallel = new GlowProcessorParallel(NamedColors.Beige) { Radius = 800 * .5f, }; } @@ -75,7 +76,7 @@ namespace SixLabors.ImageSharp.Benchmarks public float Radius { get; set; } /// - protected override void OnApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs index 5fcb860be5..c49ba05eef 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs @@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.Tests // We pass a new rectangle here based on the dest bounds since we've offset the matrix blend.Mutate(x => x.Transform( centeredMatrix, - KnownResamplers.Bicubic, + Resamplers.Bicubic, new Rectangle(0, 0, destBounds.Width, destBounds.Height))); var position = new Point((image.Width - blend.Width) / 2, (image.Height - blend.Height) / 2); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs index bf6b1f4ab2..70a35f182a 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs @@ -190,7 +190,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [MemberData(nameof(CommonConversionData))] public void ConvertFromGrayScale(int inputBufferLength, int resultBufferLength, int seed) { - var converter = JpegColorConverter.GetConverter(JpegColorSpace.GrayScale); + var converter = JpegColorConverter.GetConverter(JpegColorSpace.Grayscale); JpegColorConverter.ComponentValues values = CreateRandomValues(1, inputBufferLength, seed); Vector4[] result = new Vector4[resultBufferLength]; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs index e56e912074..eb8ee90f9c 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Theory] [InlineData(TestImages.Jpeg.Baseline.Testorig420, JpegColorSpace.YCbCr)] - [InlineData(TestImages.Jpeg.Baseline.Jpeg400, JpegColorSpace.GrayScale)] + [InlineData(TestImages.Jpeg.Baseline.Jpeg400, JpegColorSpace.Grayscale)] [InlineData(TestImages.Jpeg.Baseline.Ycck, JpegColorSpace.Ycck)] [InlineData(TestImages.Jpeg.Baseline.Cmyk, JpegColorSpace.Cmyk)] public void ColorSpace_IsDeducedCorrectly(string imageFile, object expectedColorSpaceValue) diff --git a/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs index 003f998d88..8879bf9919 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Binarization { + using SixLabors.ImageSharp.Processing.Binarization; + using SixLabors.ImageSharp.Processing.Binarization.Processors; + public class BinaryDitherTest : BaseImageOperationsExtensionTest { private readonly IOrderedDither orderedDither; @@ -15,8 +18,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization public BinaryDitherTest() { - this.orderedDither = KnownDitherers.BayerDither4x4; - this.errorDiffuser = KnownDiffusers.FloydSteinberg; + this.orderedDither = Ditherers.BayerDither4x4; + this.errorDiffuser = Diffusers.FloydSteinberg; } [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs b/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs index 488b3d18b1..6029b0d5fa 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Binarization { + using SixLabors.ImageSharp.Processing.Binarization; + using SixLabors.ImageSharp.Processing.Binarization.Processors; + public class BinaryThresholdTest : BaseImageOperationsExtensionTest { diff --git a/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs index cd0e8e5ab0..07c69a94c2 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + using SixLabors.ImageSharp.Processing.Convolution.Processors; + public class BoxBlurTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs index b52938aac1..45a5b03135 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs @@ -11,6 +11,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + using SixLabors.ImageSharp.Processing.Convolution.Processors; + public class DetectEdgesTest : BaseImageOperationsExtensionTest { @@ -34,21 +37,21 @@ namespace SixLabors.ImageSharp.Tests.Processing.Convolution // Assert.True(processor.Grayscale); } public static IEnumerable EdgeDetectionTheoryData => new[] { - new object[]{ new TestType>(), EdgeDetection.Kayyali }, - new object[]{ new TestType>(), EdgeDetection.Kirsch }, - new object[]{ new TestType>(), EdgeDetection.Lapacian3X3 }, - new object[]{ new TestType>(), EdgeDetection.Lapacian5X5 }, - new object[]{ new TestType>(), EdgeDetection.LaplacianOfGaussian }, - new object[]{ new TestType>(), EdgeDetection.Prewitt }, - new object[]{ new TestType>(), EdgeDetection.RobertsCross }, - new object[]{ new TestType>(), EdgeDetection.Robinson }, - new object[]{ new TestType>(), EdgeDetection.Scharr }, - new object[]{ new TestType>(), EdgeDetection.Sobel }, + new object[]{ new TestType>(), EdgeDetectionOperators.Kayyali }, + new object[]{ new TestType>(), EdgeDetectionOperators.Kirsch }, + new object[]{ new TestType>(), EdgeDetectionOperators.Laplacian3x3 }, + new object[]{ new TestType>(), EdgeDetectionOperators.Laplacian5x5 }, + new object[]{ new TestType>(), EdgeDetectionOperators.LaplacianOfGaussian }, + new object[]{ new TestType>(), EdgeDetectionOperators.Prewitt }, + new object[]{ new TestType>(), EdgeDetectionOperators.RobertsCross }, + new object[]{ new TestType>(), EdgeDetectionOperators.Robinson }, + new object[]{ new TestType>(), EdgeDetectionOperators.Scharr }, + new object[]{ new TestType>(), EdgeDetectionOperators.Sobel }, }; [Theory] [MemberData(nameof(EdgeDetectionTheoryData))] - public void DetectEdges_filter_SobelProcessorDefaultsSet(TestType type, EdgeDetection filter) + public void DetectEdges_filter_SobelProcessorDefaultsSet(TestType type, EdgeDetectionOperators filter) where TProcessor : IEdgeDetectorProcessor { this.operations.DetectEdges(filter); @@ -60,7 +63,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Convolution [Theory] [MemberData(nameof(EdgeDetectionTheoryData))] - public void DetectEdges_filter_grayscale_SobelProcessorDefaultsSet(TestType type, EdgeDetection filter) + public void DetectEdges_filter_grayscale_SobelProcessorDefaultsSet(TestType type, EdgeDetectionOperators filter) where TProcessor : IEdgeDetectorProcessor { bool grey = (int)filter % 2 == 0; diff --git a/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs index d0773a0bfe..5399a7ec83 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + using SixLabors.ImageSharp.Processing.Convolution.Processors; + public class GaussianBlurTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs index c7c78a21a6..518c2960fb 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + using SixLabors.ImageSharp.Processing.Convolution.Processors; + public class GaussianSharpenTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs index 03ae17848c..3868ecd703 100644 --- a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs +++ b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Binarization { + using SixLabors.ImageSharp.Processing.Dithering; + using SixLabors.ImageSharp.Processing.Dithering.Processors; + public class DitherTest : BaseImageOperationsExtensionTest { private readonly IOrderedDither orderedDither; @@ -21,8 +24,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization public DitherTest() { - this.orderedDither = KnownDitherers.BayerDither4x4; - this.errorDiffuser = KnownDiffusers.FloydSteinberg; + this.orderedDither = Ditherers.BayerDither4x4; + this.errorDiffuser = Diffusers.FloydSteinberg; } [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs index 36de67188f..f40cc250bb 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects { + using SixLabors.ImageSharp.Processing.Effects; + using SixLabors.ImageSharp.Processing.Effects.Processors; + public class OilPaintTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs b/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs index 8b50e14861..1cc69bcb68 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects { + using SixLabors.ImageSharp.Processing.Effects; + using SixLabors.ImageSharp.Processing.Effects.Processors; + public class PixelateTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs b/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs index 4ade9fe64b..2a3d6e0cfe 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs @@ -6,6 +6,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class BlackWhiteTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs index 05605767fb..dc3281a638 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class BrightnessTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs b/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs index 2dc695f560..d1e592c736 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs @@ -2,15 +2,16 @@ // Licensed under the Apache License, Version 2.0. using System.Collections.Generic; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; + using SixLabors.ImageSharp.Tests.TestUtilities; -using SixLabors.Primitives; + using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class ColorBlindnessTest : BaseImageOperationsExtensionTest { public static IEnumerable TheoryData = new[] { diff --git a/tests/ImageSharp.Tests/Processing/Filters/ContrastTest.cs b/tests/ImageSharp.Tests/Processing/Filters/ContrastTest.cs index 4aec24dad0..dab4ec5854 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/ContrastTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/ContrastTest.cs @@ -6,6 +6,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class ContrastTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/FilterTest.cs b/tests/ImageSharp.Tests/Processing/Filters/FilterTest.cs index d1e9c0ba0a..6fa22030a8 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/FilterTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/FilterTest.cs @@ -7,6 +7,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class FilterTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs b/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs index 80c377eb1d..5195894450 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs @@ -1,17 +1,17 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Collections; using System.Collections.Generic; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; + using SixLabors.ImageSharp.Tests.TestUtilities; -using SixLabors.Primitives; + using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class GrayscaleTest : BaseImageOperationsExtensionTest { public static IEnumerable ModeTheoryData = new[] { diff --git a/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs b/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs index bf03ee4f81..e9f79ff1d4 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class HueTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/InvertTest.cs b/tests/ImageSharp.Tests/Processing/Filters/InvertTest.cs index ad74b3c909..24d33e9f7d 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/InvertTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/InvertTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class InvertTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/KodachromeTest.cs b/tests/ImageSharp.Tests/Processing/Filters/KodachromeTest.cs index b3731d43c1..d776a9c8a7 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/KodachromeTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/KodachromeTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class KodachromeTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs b/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs index 32107cb716..5bd4394ab2 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs @@ -9,6 +9,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class LomographTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/OpacityTest.cs b/tests/ImageSharp.Tests/Processing/Filters/OpacityTest.cs index 4108cbddac..6d217fa152 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/OpacityTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/OpacityTest.cs @@ -6,6 +6,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class OpacityTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs b/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs index 5661851a56..5e43245af6 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class PolaroidTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Filters/SaturateTest.cs b/tests/ImageSharp.Tests/Processing/Filters/SaturateTest.cs index e3b9e3d3b2..7d115f1ad2 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/SaturateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/SaturateTest.cs @@ -6,6 +6,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class SaturateTest : BaseImageOperationsExtensionTest { diff --git a/tests/ImageSharp.Tests/Processing/Filters/SepiaTest.cs b/tests/ImageSharp.Tests/Processing/Filters/SepiaTest.cs index 4983313882..b8a77c9f05 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/SepiaTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/SepiaTest.cs @@ -8,6 +8,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Filters { + using SixLabors.ImageSharp.Processing.Filters; + using SixLabors.ImageSharp.Processing.Filters.Processors; + public class SepiaTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs index 9e7a046507..b3ecdacbeb 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Overlays { + using SixLabors.ImageSharp.Processing.Processors.Overlays; + public class GlowTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs index e082e42cd7..01555c02a8 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs @@ -10,6 +10,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Overlays { + using SixLabors.ImageSharp.Processing.Processors.Overlays; + public class VignetteTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs index aec201239d..eb41c8435a 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs @@ -11,6 +11,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization { + using SixLabors.ImageSharp.Processing.Binarization; + public class BinaryDitherTests : FileTestBase { public static readonly string[] CommonTestImages = @@ -20,29 +22,29 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization public static readonly TheoryData Ditherers = new TheoryData { - { "Bayer8x8", KnownDitherers.BayerDither8x8 }, - { "Bayer4x4", KnownDitherers.BayerDither4x4 }, - { "Ordered3x3", KnownDitherers.OrderedDither3x3 }, - { "Bayer2x2", KnownDitherers.BayerDither2x2 } + { "Bayer8x8", Dithering.Ditherers.BayerDither8x8 }, + { "Bayer4x4", Dithering.Ditherers.BayerDither4x4 }, + { "Ordered3x3", Dithering.Ditherers.OrderedDither3x3 }, + { "Bayer2x2", Dithering.Ditherers.BayerDither2x2 } }; public static readonly TheoryData ErrorDiffusers = new TheoryData { - { "Atkinson", KnownDiffusers.Atkinson }, - { "Burks", KnownDiffusers.Burks }, - { "FloydSteinberg", KnownDiffusers.FloydSteinberg }, - { "JarvisJudiceNinke", KnownDiffusers.JarvisJudiceNinke }, - { "Sierra2", KnownDiffusers.Sierra2 }, - { "Sierra3", KnownDiffusers.Sierra3 }, - { "SierraLite", KnownDiffusers.SierraLite }, - { "StevensonArce", KnownDiffusers.StevensonArce }, - { "Stucki", KnownDiffusers.Stucki }, + { "Atkinson", Diffusers.Atkinson }, + { "Burks", Diffusers.Burks }, + { "FloydSteinberg", Diffusers.FloydSteinberg }, + { "JarvisJudiceNinke", Diffusers.JarvisJudiceNinke }, + { "Sierra2", Diffusers.Sierra2 }, + { "Sierra3", Diffusers.Sierra3 }, + { "SierraLite", Diffusers.SierraLite }, + { "StevensonArce", Diffusers.StevensonArce }, + { "Stucki", Diffusers.Stucki }, }; - private static IOrderedDither DefaultDitherer => KnownDitherers.BayerDither4x4; + private static IOrderedDither DefaultDitherer => Dithering.Ditherers.BayerDither4x4; - private static IErrorDiffuser DefaultErrorDiffuser => KnownDiffusers.Atkinson; + private static IErrorDiffuser DefaultErrorDiffuser => Diffusers.Atkinson; [Theory] [WithFileCollection(nameof(CommonTestImages), nameof(Ditherers), DefaultPixelType)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs index 3daeecfc75..42b9b9adf6 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization { + using SixLabors.ImageSharp.Processing.Binarization; + public class BinaryThresholdTest : FileTestBase { public static readonly TheoryData BinaryThresholdValues diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs index 94af7aa37e..a86d5d3a03 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + public class BoxBlurTest : FileTestBase { public static readonly TheoryData BoxBlurValues diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs index 323842556e..a3687f7b5f 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs @@ -10,28 +10,30 @@ using Xunit; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + public class DetectEdgesTest : FileTestBase { public static readonly string[] CommonTestImages = { TestImages.Png.Bike }; - public static readonly TheoryData DetectEdgesFilters = new TheoryData + public static readonly TheoryData DetectEdgesFilters = new TheoryData { - EdgeDetection.Kayyali, - EdgeDetection.Kirsch, - EdgeDetection.Lapacian3X3, - EdgeDetection.Lapacian5X5, - EdgeDetection.LaplacianOfGaussian, - EdgeDetection.Prewitt, - EdgeDetection.RobertsCross, - EdgeDetection.Robinson, - EdgeDetection.Scharr, - EdgeDetection.Sobel + EdgeDetectionOperators.Kayyali, + EdgeDetectionOperators.Kirsch, + EdgeDetectionOperators.Laplacian3x3, + EdgeDetectionOperators.Laplacian5x5, + EdgeDetectionOperators.LaplacianOfGaussian, + EdgeDetectionOperators.Prewitt, + EdgeDetectionOperators.RobertsCross, + EdgeDetectionOperators.Robinson, + EdgeDetectionOperators.Scharr, + EdgeDetectionOperators.Sobel }; [Theory] [WithTestPatternImages(nameof(DetectEdgesFilters), 100, 100, DefaultPixelType)] [WithFileCollection(nameof(CommonTestImages), nameof(DetectEdgesFilters), DefaultPixelType)] - public void DetectEdges_WorksWithAllFilters(TestImageProvider provider, EdgeDetection detector) + public void DetectEdges_WorksWithAllFilters(TestImageProvider provider, EdgeDetectionOperators detector) where TPixel : struct, IPixel { using (Image image = provider.GetImage()) diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs index 89e9a13b5c..d5885bb98c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + public class GaussianBlurTest : FileTestBase { public static readonly TheoryData GaussianBlurValues = new TheoryData { 3, 5 }; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs index 4775444a5a..4f3237a21b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution { + using SixLabors.ImageSharp.Processing.Convolution; + public class GaussianSharpenTest : FileTestBase { public static readonly TheoryData GaussianSharpenValues diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index 58c63d48c7..68d6efeec7 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -11,6 +11,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization { + using SixLabors.ImageSharp.Processing.Dithering; + public class DitherTests : FileTestBase { public static readonly string[] CommonTestImages = @@ -20,29 +22,29 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization public static readonly TheoryData Ditherers = new TheoryData { - { "Bayer8x8", KnownDitherers.BayerDither8x8 }, - { "Bayer4x4", KnownDitherers.BayerDither4x4 }, - { "Ordered3x3", KnownDitherers.OrderedDither3x3 }, - { "Bayer2x2", KnownDitherers.BayerDither2x2 } + { "Bayer8x8", Dithering.Ditherers.BayerDither8x8 }, + { "Bayer4x4", Dithering.Ditherers.BayerDither4x4 }, + { "Ordered3x3", Dithering.Ditherers.OrderedDither3x3 }, + { "Bayer2x2", Dithering.Ditherers.BayerDither2x2 } }; public static readonly TheoryData ErrorDiffusers = new TheoryData { - { "Atkinson", KnownDiffusers.Atkinson }, - { "Burks", KnownDiffusers.Burks }, - { "FloydSteinberg", KnownDiffusers.FloydSteinberg }, - { "JarvisJudiceNinke", KnownDiffusers.JarvisJudiceNinke }, - { "Sierra2", KnownDiffusers.Sierra2 }, - { "Sierra3", KnownDiffusers.Sierra3 }, - { "SierraLite", KnownDiffusers.SierraLite }, - { "StevensonArce", KnownDiffusers.StevensonArce }, - { "Stucki", KnownDiffusers.Stucki }, + { "Atkinson", Diffusers.Atkinson }, + { "Burks", Diffusers.Burks }, + { "FloydSteinberg", Diffusers.FloydSteinberg }, + { "JarvisJudiceNinke", Diffusers.JarvisJudiceNinke }, + { "Sierra2", Diffusers.Sierra2 }, + { "Sierra3", Diffusers.Sierra3 }, + { "SierraLite", Diffusers.SierraLite }, + { "StevensonArce", Diffusers.StevensonArce }, + { "Stucki", Diffusers.Stucki }, }; - private static IOrderedDither DefaultDitherer => KnownDitherers.BayerDither4x4; + private static IOrderedDither DefaultDitherer => Dithering.Ditherers.BayerDither4x4; - private static IErrorDiffuser DefaultErrorDiffuser => KnownDiffusers.Atkinson; + private static IErrorDiffuser DefaultErrorDiffuser => Diffusers.Atkinson; [Theory] [WithFileCollection(nameof(CommonTestImages), nameof(Ditherers), DefaultPixelType)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs index a9127f61dc..868763baf4 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects { + using SixLabors.ImageSharp.Processing.Effects; + public class OilPaintTest : FileTestBase { public static readonly TheoryData OilPaintValues = new TheoryData diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs index b3f1ee3a28..98bfbc5538 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects { + using SixLabors.ImageSharp.Processing.Effects; + public class PixelateTest : FileTestBase { public static readonly TheoryData PixelateValues diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/BlackWhiteTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/BlackWhiteTest.cs index e373230a73..ccf9152f0e 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/BlackWhiteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/BlackWhiteTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class BlackWhiteTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs index 783e55d832..14f5fa0808 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class BrightnessTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs index c0df24d291..b0dcbd726b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs @@ -8,6 +8,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class ColorBlindnessTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs index b532649b3d..c6afc5e11b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class ContrastTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/FilterTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/FilterTest.cs index 515b970aee..077073b4c7 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/FilterTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/FilterTest.cs @@ -11,6 +11,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class FilterTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs index f61c529a38..192034fbb6 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class GrayscaleTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs index fe9f9d5db2..6e3fd5feff 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class HueTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/InvertTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/InvertTest.cs index 452397c5eb..de105437ba 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/InvertTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/InvertTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class InvertTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/KodachromeTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/KodachromeTest.cs index a5165250b7..2265e0b0b0 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/KodachromeTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/KodachromeTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class KodachromeTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/LomographTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/LomographTest.cs index 09c8becec3..92c5b788cf 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/LomographTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/LomographTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class LomographTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs index 2cba4fb8ed..c76bf3b1de 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class OpacityTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/PolaroidTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/PolaroidTest.cs index 4e0347d2a4..19fcc67885 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/PolaroidTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/PolaroidTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class PolaroidTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs index 9b963b94a4..18d77660e4 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class SaturateTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/SepiaTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/SepiaTest.cs index 2a63e992d7..50bf0e3a1b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/SepiaTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/SepiaTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters { + using SixLabors.ImageSharp.Processing.Filters; + [GroupOutput("Filters")] public class SepiaTest { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs index 2e1b43c388..3920aff8aa 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms public void PrintWeightsData() { var size = new Size(500, 500); - var proc = new ResizeProcessor(KnownResamplers.Bicubic, 200, 200, size); + var proc = new ResizeProcessor(Resamplers.Bicubic, 200, 200, size); WeightsBuffer weights = proc.PrecomputeWeights(Configuration.Default.MemoryManager, proc.Width, size.Width); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs index 8370a802cd..e2ae50aff0 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -20,20 +20,20 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms public static readonly TheoryData AllReSamplers = new TheoryData { - { "Bicubic", KnownResamplers.Bicubic }, - { "Triangle", KnownResamplers.Triangle}, - { "NearestNeighbor", KnownResamplers.NearestNeighbor }, - { "Box", KnownResamplers.Box }, + { "Bicubic", Resamplers.Bicubic }, + { "Triangle", Resamplers.Triangle}, + { "NearestNeighbor", Resamplers.NearestNeighbor }, + { "Box", Resamplers.Box }, // { "Lanczos2", KnownResamplers.Lanczos2 }, TODO: Add expected file - { "Lanczos3", KnownResamplers.Lanczos3 }, - { "Lanczos5", KnownResamplers.Lanczos5 }, - { "MitchellNetravali", KnownResamplers.MitchellNetravali }, - { "Lanczos8", KnownResamplers.Lanczos8 }, - { "Hermite", KnownResamplers.Hermite }, - { "Spline", KnownResamplers.Spline }, - { "Robidoux", KnownResamplers.Robidoux }, - { "RobidouxSharp", KnownResamplers.RobidouxSharp }, - { "Welch", KnownResamplers.Welch } + { "Lanczos3", Resamplers.Lanczos3 }, + { "Lanczos5", Resamplers.Lanczos5 }, + { "MitchellNetravali", Resamplers.MitchellNetravali }, + { "Lanczos8", Resamplers.Lanczos8 }, + { "Hermite", Resamplers.Hermite }, + { "Spline", Resamplers.Spline }, + { "Robidoux", Resamplers.Robidoux }, + { "RobidouxSharp", Resamplers.RobidouxSharp }, + { "Welch", Resamplers.Welch } }; [Theory] @@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { using (Image image = provider.GetImage()) { - image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2, KnownResamplers.NearestNeighbor)); + image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2, Resamplers.NearestNeighbor)); // Comparer fights decoder with gif-s. Could not use CompareToReferenceOutput here :( image.DebugSave(provider, extension: Extensions.Gif); @@ -119,7 +119,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms var sourceRectangle = new Rectangle(image.Width / 8, image.Height / 8, image.Width / 4, image.Height / 4); var destRectangle = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); - image.Mutate(x => x.Resize(image.Width, image.Height, KnownResamplers.Bicubic, sourceRectangle, destRectangle, false)); + image.Mutate(x => x.Resize(image.Width, image.Height, Resamplers.Bicubic, sourceRectangle, destRectangle, false)); image.DebugSave(provider); image.CompareToReferenceOutput(provider); @@ -300,7 +300,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(2, 0)] public static void BicubicWindowOscillatesCorrectly(float x, float expected) { - var sampler = KnownResamplers.Bicubic; + var sampler = Resamplers.Bicubic; float result = sampler.GetValue(x); Assert.Equal(result, expected); @@ -314,7 +314,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(2, 0)] public static void TriangleWindowOscillatesCorrectly(float x, float expected) { - var sampler = KnownResamplers.Triangle; + var sampler = Resamplers.Triangle; float result = sampler.GetValue(x); Assert.Equal(result, expected); @@ -328,7 +328,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(2, 0)] public static void Lanczos3WindowOscillatesCorrectly(float x, float expected) { - var sampler = KnownResamplers.Lanczos3; + var sampler = Resamplers.Lanczos3; float result = sampler.GetValue(x); Assert.Equal(result, expected); @@ -342,7 +342,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(4, 0)] public static void Lanczos5WindowOscillatesCorrectly(float x, float expected) { - var sampler = KnownResamplers.Lanczos5; + var sampler = Resamplers.Lanczos5; float result = sampler.GetValue(x); Assert.Equal(result, expected); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs index 17bf3def26..e8c5763d5e 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs @@ -24,21 +24,21 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms public static readonly List ResamplerNames = new List { - nameof(KnownResamplers.Bicubic), - nameof(KnownResamplers.Box), - nameof(KnownResamplers.CatmullRom), - nameof(KnownResamplers.Hermite), - nameof(KnownResamplers.Lanczos2), - nameof(KnownResamplers.Lanczos3), - nameof(KnownResamplers.Lanczos5), - nameof(KnownResamplers.Lanczos8), - nameof(KnownResamplers.MitchellNetravali), - nameof(KnownResamplers.NearestNeighbor), - nameof(KnownResamplers.Robidoux), - nameof(KnownResamplers.RobidouxSharp), - nameof(KnownResamplers.Spline), - nameof(KnownResamplers.Triangle), - nameof(KnownResamplers.Welch), + nameof(Resamplers.Bicubic), + nameof(Resamplers.Box), + nameof(Resamplers.CatmullRom), + nameof(Resamplers.Hermite), + nameof(Resamplers.Lanczos2), + nameof(Resamplers.Lanczos3), + nameof(Resamplers.Lanczos5), + nameof(Resamplers.Lanczos8), + nameof(Resamplers.MitchellNetravali), + nameof(Resamplers.NearestNeighbor), + nameof(Resamplers.Robidoux), + nameof(Resamplers.RobidouxSharp), + nameof(Resamplers.Spline), + nameof(Resamplers.Triangle), + nameof(Resamplers.Welch), }; [Theory] @@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms private static IResampler GetResampler(string name) { - PropertyInfo property = typeof(KnownResamplers).GetTypeInfo().GetProperty(name); + PropertyInfo property = typeof(Resamplers).GetTypeInfo().GetProperty(name); if (property == null) { diff --git a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs index ace6cb70d6..e0797c4da9 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs @@ -36,30 +36,30 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms public static readonly TheoryData ResamplerNames = new TheoryData { - nameof(KnownResamplers.Bicubic), - nameof(KnownResamplers.Box), - nameof(KnownResamplers.CatmullRom), - nameof(KnownResamplers.Hermite), - nameof(KnownResamplers.Lanczos2), - nameof(KnownResamplers.Lanczos3), - nameof(KnownResamplers.Lanczos5), - nameof(KnownResamplers.Lanczos8), - nameof(KnownResamplers.MitchellNetravali), - nameof(KnownResamplers.NearestNeighbor), - nameof(KnownResamplers.Robidoux), - nameof(KnownResamplers.RobidouxSharp), - nameof(KnownResamplers.Spline), - nameof(KnownResamplers.Triangle), - nameof(KnownResamplers.Welch), + nameof(Resamplers.Bicubic), + nameof(Resamplers.Box), + nameof(Resamplers.CatmullRom), + nameof(Resamplers.Hermite), + nameof(Resamplers.Lanczos2), + nameof(Resamplers.Lanczos3), + nameof(Resamplers.Lanczos5), + nameof(Resamplers.Lanczos8), + nameof(Resamplers.MitchellNetravali), + nameof(Resamplers.NearestNeighbor), + nameof(Resamplers.Robidoux), + nameof(Resamplers.RobidouxSharp), + nameof(Resamplers.Spline), + nameof(Resamplers.Triangle), + nameof(Resamplers.Welch), }; public static readonly TheoryData Transform_DoesNotCreateEdgeArtifacts_ResamplerNames = new TheoryData { - nameof(KnownResamplers.NearestNeighbor), - nameof(KnownResamplers.Triangle), - nameof(KnownResamplers.Bicubic), - nameof(KnownResamplers.Lanczos8), + nameof(Resamplers.NearestNeighbor), + nameof(Resamplers.Triangle), + nameof(Resamplers.Bicubic), + nameof(Resamplers.Lanczos8), }; public AffineTransformTests(ITestOutputHelper output) @@ -111,7 +111,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms this.PrintMatrix(m); - image.Mutate(i => i.Transform(m, KnownResamplers.Bicubic)); + image.Mutate(i => i.Transform(m, Resamplers.Bicubic)); string testOutputDetails = $"R({angleDeg})_S({sx},{sy})_T({tx},{ty})"; image.DebugSave(provider, testOutputDetails); @@ -128,7 +128,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { Matrix3x2 m = this.MakeManuallyCenteredMatrix(angleDeg, s, image); - image.Mutate(i => i.Transform(m, KnownResamplers.Bicubic)); + image.Mutate(i => i.Transform(m, Resamplers.Bicubic)); string testOutputDetails = $"R({angleDeg})_S({s})"; image.DebugSave(provider, testOutputDetails); @@ -161,7 +161,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { var m = Matrix3x2.CreateScale(2.0F, 1.5F); - image.Mutate(i => i.Transform(m, KnownResamplers.Spline, rectangle)); + image.Mutate(i => i.Transform(m, Resamplers.Spline, rectangle)); image.DebugSave(provider); image.CompareToReferenceOutput(provider); @@ -179,7 +179,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { var m = Matrix3x2.CreateScale(1.0F, 2.0F); - image.Mutate(i => i.Transform(m, KnownResamplers.Spline, rectangle)); + image.Mutate(i => i.Transform(m, Resamplers.Spline, rectangle)); image.DebugSave(provider); image.CompareToReferenceOutput(provider); @@ -223,7 +223,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms private static IResampler GetResampler(string name) { - PropertyInfo property = typeof(KnownResamplers).GetTypeInfo().GetProperty(name); + PropertyInfo property = typeof(Resamplers).GetTypeInfo().GetProperty(name); if (property == null) { diff --git a/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs index a9c2922d48..cf4f83ca47 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 500; int height = 565; - IResampler sampler = KnownResamplers.NearestNeighbor; + IResampler sampler = Resamplers.NearestNeighbor; this.operations.Pad(width, height); ResizeProcessor resizeProcessor = this.Verify>(); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs index b51d342cf1..5f3815711d 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 50; int height = 100; - IResampler sampler = KnownResamplers.Lanczos3; + IResampler sampler = Resamplers.Lanczos3; this.operations.Resize(width, height, sampler); ResizeProcessor resizeProcessor = this.Verify>(); @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 50; int height = 100; - IResampler sampler = KnownResamplers.Lanczos3; + IResampler sampler = Resamplers.Lanczos3; bool compand = true; // ReSharper disable once ConditionIsAlwaysTrueOrFalse @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 50; int height = 100; - IResampler sampler = KnownResamplers.Lanczos3; + IResampler sampler = Resamplers.Lanczos3; bool compand = true; ResizeMode mode = ResizeMode.Stretch; diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs index fe5af24d26..1e58b7097a 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs @@ -12,6 +12,8 @@ using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests { + using SixLabors.ImageSharp.Processing.Effects; + public class TestUtilityExtensionsTests { public TestUtilityExtensionsTests(ITestOutputHelper output) diff --git a/tests/Images/External b/tests/Images/External index 653f0c7e3c..e9f33352b7 160000 --- a/tests/Images/External +++ b/tests/Images/External @@ -1 +1 @@ -Subproject commit 653f0c7e3c84657f68dd46e5a380186b3696b956 +Subproject commit e9f33352b77a5176508d2d5dcafbd1bd33805530 From 22ee2bb1a476841df8481a9ace3ec54a4ef81573 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 8 Mar 2018 00:21:30 +1100 Subject: [PATCH 02/18] Replace Fast2DArray with DenseMatrix Much better and faster (comprable to 1D array) --- .../Brushes/PatternBrush{TPixel}.cs | 28 +-- .../ErrorDiffusion/AtkinsonDiffuser.cs | 3 +- .../Dithering/ErrorDiffusion/BurksDiffuser.cs | 4 +- .../ErrorDiffusion/ErrorDiffuserBase.cs | 10 +- .../ErrorDiffusion/FloydSteinbergDiffuser.cs | 4 +- .../JarvisJudiceNinkeDiffuser.cs | 4 +- .../ErrorDiffusion/Sierra2Diffuser.cs | 4 +- .../ErrorDiffusion/Sierra3Diffuser.cs | 4 +- .../ErrorDiffusion/SierraLiteDiffuser.cs | 4 +- .../ErrorDiffusion/StevensonArceDiffuser.cs | 4 +- .../ErrorDiffusion/StuckiDiffuser.cs | 4 +- .../Dithering/Ordered/OrderedDither.cs | 14 +- .../Dithering/Ordered/OrderedDitherFactory.cs | 12 +- src/ImageSharp/Memory/Fast2DArray{T}.cs | 173 -------------- .../ICC/DataWriter/IccDataWriter.Matrix.cs | 8 +- .../IccMatrixProcessElement.cs | 18 +- src/ImageSharp/Primitives/DenseMatrix{T}.cs | 215 ++++++++++++++++++ .../{Numerics => Primitives}/ValueSize.cs | 16 +- .../Processors/BoxBlurProcessor.cs | 17 +- .../Processors/Convolution2DProcessor.cs | 17 +- .../Processors/Convolution2PassProcessor.cs | 16 +- .../Processors/ConvolutionProcessor.cs | 9 +- .../Processors/EdgeDetector2DProcessor.cs | 9 +- .../EdgeDetectorCompassProcessor.cs | 21 +- .../Processors/EdgeDetectorProcessor.cs | 7 +- .../Processors/GaussianBlurProcessor.cs | 17 +- .../Processors/GaussianSharpenProcessor.cs | 17 +- .../Convolution/Processors/KayyaliKernels.cs | 6 +- .../Convolution/Processors/KirschProcessor.cs | 18 +- .../Convolution/Processors/KirshKernels.cs | 18 +- .../Processors/LaplacianKernelFactory.cs | 17 +- .../Processors/LaplacianKernels.cs | 8 +- .../Convolution/Processors/PrewittKernels.cs | 6 +- .../Processors/RobertsCrossKernels.cs | 6 +- .../Convolution/Processors/RobinsonKernels.cs | 18 +- .../Processors/RobinsonProcessor.cs | 18 +- .../Convolution/Processors/ScharrKernels.cs | 6 +- .../Convolution/Processors/SobelKernels.cs | 6 +- src/ImageSharp/Processing/Overlays/Glow.cs | 1 + .../Processing/Overlays/Vignette.cs | 1 + .../Processors/Overlays/GlowProcessor.cs | 1 + .../Processors/Overlays/VignetteProcessor.cs | 1 + .../ImageSharp.Benchmarks/General/Array2D.cs | 47 ++-- .../Drawing/SolidBezierTests.cs | 4 +- .../Primitives/DenseMatrixTests.cs | 108 +++++++++ .../Processing/Overlays/GlowTest.cs | 1 + .../Processing/Overlays/VignetteTest.cs | 1 + 47 files changed, 559 insertions(+), 392 deletions(-) delete mode 100644 src/ImageSharp/Memory/Fast2DArray{T}.cs create mode 100644 src/ImageSharp/Primitives/DenseMatrix{T}.cs rename src/ImageSharp/{Numerics => Primitives}/ValueSize.cs (90%) create mode 100644 tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs diff --git a/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs index cc22b26391..ba6d912081 100644 --- a/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs @@ -5,9 +5,9 @@ using System; using System.Numerics; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Drawing.Brushes.Processors; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Drawing.Brushes @@ -40,8 +40,8 @@ namespace SixLabors.ImageSharp.Drawing.Brushes /// /// The pattern. /// - private readonly Fast2DArray pattern; - private readonly Fast2DArray patternVector; + private readonly DenseMatrix pattern; + private readonly DenseMatrix patternVector; /// /// Initializes a new instance of the class. @@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Drawing.Brushes /// Color of the back. /// The pattern. public PatternBrush(TPixel foreColor, TPixel backColor, bool[,] pattern) - : this(foreColor, backColor, new Fast2DArray(pattern)) + : this(foreColor, backColor, new DenseMatrix(pattern)) { } @@ -60,12 +60,12 @@ namespace SixLabors.ImageSharp.Drawing.Brushes /// Color of the fore. /// Color of the back. /// The pattern. - internal PatternBrush(TPixel foreColor, TPixel backColor, Fast2DArray pattern) + internal PatternBrush(TPixel foreColor, TPixel backColor, DenseMatrix pattern) { var foreColorVector = foreColor.ToVector4(); var backColorVector = backColor.ToVector4(); - this.pattern = new Fast2DArray(pattern.Width, pattern.Height); - this.patternVector = new Fast2DArray(pattern.Width, pattern.Height); + this.pattern = new DenseMatrix(pattern.Columns, pattern.Rows); + this.patternVector = new DenseMatrix(pattern.Columns, pattern.Rows); for (int i = 0; i < pattern.Data.Length; i++) { if (pattern.Data[i]) @@ -105,8 +105,8 @@ namespace SixLabors.ImageSharp.Drawing.Brushes /// /// The pattern. /// - private readonly Fast2DArray pattern; - private readonly Fast2DArray patternVector; + private readonly DenseMatrix pattern; + private readonly DenseMatrix patternVector; /// /// Initializes a new instance of the class. @@ -115,7 +115,7 @@ namespace SixLabors.ImageSharp.Drawing.Brushes /// The pattern. /// The patternVector. /// The options - public PatternBrushApplicator(ImageFrame source, Fast2DArray pattern, Fast2DArray patternVector, GraphicsOptions options) + public PatternBrushApplicator(ImageFrame source, DenseMatrix pattern, DenseMatrix patternVector, GraphicsOptions options) : base(source, options) { this.pattern = pattern; @@ -134,8 +134,8 @@ namespace SixLabors.ImageSharp.Drawing.Brushes { get { - x = x % this.pattern.Width; - y = y % this.pattern.Height; + x = x % this.pattern.Columns; + y = y % this.pattern.Rows; // 2d array index at row/column return this.pattern[y, x]; @@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.Drawing.Brushes /// internal override void Apply(Span scanline, int x, int y) { - int patternY = y % this.pattern.Height; + int patternY = y % this.pattern.Rows; MemoryManager memoryManager = this.Target.MemoryManager; using (IBuffer amountBuffer = memoryManager.Allocate(scanline.Length)) @@ -164,7 +164,7 @@ namespace SixLabors.ImageSharp.Drawing.Brushes { amountSpan[i] = (scanline[i] * this.Options.BlendPercentage).Clamp(0, 1); - int patternX = (x + i) % this.pattern.Width; + int patternX = (x + i) % this.pattern.Columns; overlaySpan[i] = this.pattern[patternY, patternX]; } diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs b/src/ImageSharp/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs index 3899b14cc9..f5219b216a 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs +++ b/src/ImageSharp/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.Dithering.Base; using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Dithering { @@ -15,7 +16,7 @@ namespace SixLabors.ImageSharp.Dithering /// /// The diffusion matrix /// - private static readonly Fast2DArray AtkinsonMatrix = + private static readonly DenseMatrix AtkinsonMatrix = new float[,] { { 0, 0, 1, 1 }, diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/BurksDiffuser.cs b/src/ImageSharp/Dithering/ErrorDiffusion/BurksDiffuser.cs index 4d9f4d3c4f..9505417e51 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/BurksDiffuser.cs +++ b/src/ImageSharp/Dithering/ErrorDiffusion/BurksDiffuser.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Dithering.Base; -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Dithering { @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Dithering /// /// The diffusion matrix /// - private static readonly Fast2DArray BurksMatrix = + private static readonly DenseMatrix BurksMatrix = new float[,] { { 0, 0, 0, 8, 4 }, diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs b/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs index 8f448198b0..ddfac86a15 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs +++ b/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs @@ -5,8 +5,8 @@ using System; using System.Numerics; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Dithering.Base { @@ -38,21 +38,21 @@ namespace SixLabors.ImageSharp.Dithering.Base /// /// The diffusion matrix /// - private readonly Fast2DArray matrix; + private readonly DenseMatrix matrix; /// /// Initializes a new instance of the class. /// /// The dithering matrix. /// The divisor. - internal ErrorDiffuserBase(Fast2DArray matrix, byte divisor) + internal ErrorDiffuserBase(DenseMatrix matrix, byte divisor) { Guard.NotNull(matrix, nameof(matrix)); Guard.MustBeGreaterThan(divisor, 0, nameof(divisor)); this.matrix = matrix; - this.matrixWidth = this.matrix.Width; - this.matrixHeight = this.matrix.Height; + this.matrixWidth = this.matrix.Columns; + this.matrixHeight = this.matrix.Rows; this.divisorVector = new Vector4(divisor); this.startingOffset = 0; diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs b/src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs index 6457fbe01e..dd06ed199d 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs +++ b/src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Dithering.Base; -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Dithering { @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Dithering /// /// The diffusion matrix /// - private static readonly Fast2DArray FloydSteinbergMatrix = + private static readonly DenseMatrix FloydSteinbergMatrix = new float[,] { { 0, 0, 7 }, diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs b/src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs index 30e09b47a9..48d2f3a97d 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs +++ b/src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Dithering.Base; -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Dithering { @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Dithering /// /// The diffusion matrix /// - private static readonly Fast2DArray JarvisJudiceNinkeMatrix = + private static readonly DenseMatrix JarvisJudiceNinkeMatrix = new float[,] { { 0, 0, 0, 7, 5 }, diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra2Diffuser.cs b/src/ImageSharp/Dithering/ErrorDiffusion/Sierra2Diffuser.cs index c472d25b0d..3aa37798d1 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra2Diffuser.cs +++ b/src/ImageSharp/Dithering/ErrorDiffusion/Sierra2Diffuser.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Dithering.Base; -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Dithering { @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Dithering /// /// The diffusion matrix /// - private static readonly Fast2DArray Sierra2Matrix = + private static readonly DenseMatrix Sierra2Matrix = new float[,] { { 0, 0, 0, 4, 3 }, diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra3Diffuser.cs b/src/ImageSharp/Dithering/ErrorDiffusion/Sierra3Diffuser.cs index c19ab2aaac..e6875b1d40 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra3Diffuser.cs +++ b/src/ImageSharp/Dithering/ErrorDiffusion/Sierra3Diffuser.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Dithering.Base; -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Dithering { @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Dithering /// /// The diffusion matrix /// - private static readonly Fast2DArray Sierra3Matrix = + private static readonly DenseMatrix Sierra3Matrix = new float[,] { { 0, 0, 0, 5, 3 }, diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs b/src/ImageSharp/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs index 263bae568a..371f39fe54 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs +++ b/src/ImageSharp/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Dithering.Base; -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Dithering { @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Dithering /// /// The diffusion matrix /// - private static readonly Fast2DArray SierraLiteMatrix = + private static readonly DenseMatrix SierraLiteMatrix = new float[,] { { 0, 0, 2 }, diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs b/src/ImageSharp/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs index 0f0338ac72..beda8efbf0 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs +++ b/src/ImageSharp/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Dithering.Base; -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Dithering { @@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Dithering /// /// The diffusion matrix /// - private static readonly Fast2DArray StevensonArceMatrix = + private static readonly DenseMatrix StevensonArceMatrix = new float[,] { { 0, 0, 0, 0, 0, 32, 0 }, diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/StuckiDiffuser.cs b/src/ImageSharp/Dithering/ErrorDiffusion/StuckiDiffuser.cs index 0717695065..54c448c28a 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/StuckiDiffuser.cs +++ b/src/ImageSharp/Dithering/ErrorDiffusion/StuckiDiffuser.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Dithering.Base; -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Dithering { @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Dithering /// /// The diffusion matrix /// - private static readonly Fast2DArray StuckiMatrix = + private static readonly DenseMatrix StuckiMatrix = new float[,] { { 0, 0, 0, 8, 4 }, diff --git a/src/ImageSharp/Dithering/Ordered/OrderedDither.cs b/src/ImageSharp/Dithering/Ordered/OrderedDither.cs index c07b185bbe..6fa90545a3 100644 --- a/src/ImageSharp/Dithering/Ordered/OrderedDither.cs +++ b/src/ImageSharp/Dithering/Ordered/OrderedDither.cs @@ -1,8 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Dithering { @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Dithering /// public class OrderedDither : IOrderedDither { - private readonly Fast2DArray thresholdMatrix; + private readonly DenseMatrix thresholdMatrix; private readonly int modulusX; private readonly int modulusY; @@ -21,17 +21,17 @@ namespace SixLabors.ImageSharp.Dithering /// The length of the matrix sides public OrderedDither(uint length) { - Fast2DArray ditherMatrix = OrderedDitherFactory.CreateDitherMatrix(length); - this.modulusX = ditherMatrix.Width; - this.modulusY = ditherMatrix.Height; + DenseMatrix ditherMatrix = OrderedDitherFactory.CreateDitherMatrix(length); + this.modulusX = ditherMatrix.Columns; + this.modulusY = ditherMatrix.Rows; // Adjust the matrix range for 0-255 // It looks like it's actually possible to dither an image using it's own colors. We should investigate for V2 // https://stackoverflow.com/questions/12422407/monochrome-dithering-in-javascript-bayer-atkinson-floyd-steinberg int multiplier = 256 / ditherMatrix.Count; - for (int y = 0; y < ditherMatrix.Height; y++) + for (int y = 0; y < ditherMatrix.Rows; y++) { - for (int x = 0; x < ditherMatrix.Width; x++) + for (int x = 0; x < ditherMatrix.Columns; x++) { ditherMatrix[y, x] = (uint)((ditherMatrix[y, x] + 1) * multiplier) - 1; } diff --git a/src/ImageSharp/Dithering/Ordered/OrderedDitherFactory.cs b/src/ImageSharp/Dithering/Ordered/OrderedDitherFactory.cs index fc9ac25517..78bc5fff98 100644 --- a/src/ImageSharp/Dithering/Ordered/OrderedDitherFactory.cs +++ b/src/ImageSharp/Dithering/Ordered/OrderedDitherFactory.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using System.Runtime.CompilerServices; -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Dithering { @@ -16,8 +16,8 @@ namespace SixLabors.ImageSharp.Dithering /// /// /// The length of the matrix sides - /// The - public static Fast2DArray CreateDitherMatrix(uint length) + /// The + public static DenseMatrix CreateDitherMatrix(uint length) { // Calculate the the logarithm of length to the base 2 uint exponent = 0; @@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Dithering while (length > bayerLength); // Create our Bayer matrix that matches the given exponent and dimensions - var matrix = new Fast2DArray((int)length); + var matrix = new DenseMatrix((int)length); uint i = 0; for (int y = 0; y < length; y++) { @@ -81,9 +81,9 @@ namespace SixLabors.ImageSharp.Dithering uint result = 0; for (uint i = 0; i < order; ++i) { - uint xOdd_XOR_yOdd = (x & 1) ^ (y & 1); + uint xOddXorYOdd = (x & 1) ^ (y & 1); uint xOdd = x & 1; - result = ((result << 1 | xOdd_XOR_yOdd) << 1) | xOdd; + result = ((result << 1 | xOddXorYOdd) << 1) | xOdd; x >>= 1; y >>= 1; } diff --git a/src/ImageSharp/Memory/Fast2DArray{T}.cs b/src/ImageSharp/Memory/Fast2DArray{T}.cs deleted file mode 100644 index 38ccdd279d..0000000000 --- a/src/ImageSharp/Memory/Fast2DArray{T}.cs +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace SixLabors.ImageSharp.Memory -{ - /// - /// Provides fast access to 2D arrays. - /// - /// The type of elements in the array. - internal struct Fast2DArray - { - /// - /// The 1D representation of the 2D array. - /// - public T[] Data; - - /// - /// Gets the width of the 2D array. - /// - public int Width; - - /// - /// Gets the height of the 2D array. - /// - public int Height; - - /// - /// Gets the number of items in the 2D array - /// - public int Count; - - /// - /// Initializes a new instance of the struct. - /// - /// The length of each dimension. - public Fast2DArray(int length) - : this(length, length) - { - } - - /// - /// Initializes a new instance of the struct. - /// - /// The width. - /// The height. - public Fast2DArray(int width, int height) - { - this.Height = height; - this.Width = width; - - Guard.MustBeGreaterThan(width, 0, nameof(width)); - Guard.MustBeGreaterThan(height, 0, nameof(height)); - - this.Count = width * height; - this.Data = new T[this.Count]; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The 2D array to provide access to. - public Fast2DArray(T[,] data) - { - Guard.NotNull(data, nameof(data)); - this.Height = data.GetLength(0); - this.Width = data.GetLength(1); - - Guard.MustBeGreaterThan(this.Width, 0, nameof(this.Width)); - Guard.MustBeGreaterThan(this.Height, 0, nameof(this.Height)); - - this.Count = this.Width * this.Height; - this.Data = new T[this.Count]; - - for (int y = 0; y < this.Height; y++) - { - for (int x = 0; x < this.Width; x++) - { - this.Data[(y * this.Width) + x] = data[y, x]; - } - } - } - - /// - /// Gets or sets the item at the specified position. - /// - /// The row-coordinate of the item. Must be greater than or equal to zero and less than the height of the array. - /// The column-coordinate of the item. Must be greater than or equal to zero and less than the width of the array. - /// The at the specified position. - public T this[int row, int column] - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - this.CheckCoordinates(row, column); - return this.Data[(row * this.Width) + column]; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - set - { - this.CheckCoordinates(row, column); - this.Data[(row * this.Width) + column] = value; - } - } - - /// - /// Performs an implicit conversion from a 2D array to a . - /// - /// The source array. - /// - /// The representation on the source data. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator Fast2DArray(T[,] data) - { - return new Fast2DArray(data); - } - - /// - /// Gets a representing the row beginning from the the first item on that row. - /// - /// The y-coordinate of the row. Must be greater than or equal to zero and less than the height of the 2D array. - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Span GetRowSpan(int row) - { - this.CheckCoordinates(row); - return new Span(this.Data, row * this.Width, this.Width); - } - - /// - /// Checks the coordinates to ensure they are within bounds. - /// - /// The y-coordinate of the item. Must be greater than zero and smaller than the height of the array. - /// The x-coordinate of the item. Must be greater than zero and smaller than the width of the array. - /// - /// Thrown if the coordinates are not within the bounds of the array. - /// - [Conditional("DEBUG")] - private void CheckCoordinates(int row, int column) - { - if (row < 0 || row >= this.Height) - { - throw new ArgumentOutOfRangeException(nameof(row), row, $"{row} is outwith the array bounds."); - } - - if (column < 0 || column >= this.Width) - { - throw new ArgumentOutOfRangeException(nameof(column), column, $"{column} is outwith the array bounds."); - } - } - - /// - /// Checks the coordinates to ensure they are within bounds. - /// - /// The y-coordinate of the item. Must be greater than zero and smaller than the height of the array. - /// - /// Thrown if the coordinates are not within the bounds of the image. - /// - [Conditional("DEBUG")] - private void CheckCoordinates(int row) - { - if (row < 0 || row >= this.Height) - { - throw new ArgumentOutOfRangeException(nameof(row), row, $"{row} is outwith the array bounds."); - } - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs index 0b7064cf93..5d7d729b2c 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using System.Numerics; -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { @@ -59,12 +59,12 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// The matrix to write /// True if the values are encoded as Single; false if encoded as Fix16 /// The number of bytes written - public int WriteMatrix(Fast2DArray value, bool isSingle) + public int WriteMatrix(DenseMatrix value, bool isSingle) { int count = 0; - for (int y = 0; y < value.Height; y++) + for (int y = 0; y < value.Rows; y++) { - for (int x = 0; x < value.Width; x++) + for (int x = 0; x < value.Columns; x++) { if (isSingle) { diff --git a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMatrixProcessElement.cs b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMatrixProcessElement.cs index 642f766d56..13b58161c6 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMatrixProcessElement.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMatrixProcessElement.cs @@ -3,7 +3,8 @@ using System; using System.Linq; -using SixLabors.ImageSharp.Memory; + +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { @@ -33,7 +34,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// /// Gets the two dimensional matrix with size of Input-Channels x Output-Channels /// - public Fast2DArray MatrixIxO { get; } + public DenseMatrix MatrixIxO { get; } /// /// Gets the one dimensional matrix with size of Output-Channels x 1 @@ -60,18 +61,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc private bool EqualsMatrix(IccMatrixProcessElement element) { - for (int x = 0; x < this.MatrixIxO.Width; x++) - { - for (int y = 0; y < this.MatrixIxO.Height; y++) - { - if (this.MatrixIxO[x, y] != element.MatrixIxO[x, y]) - { - return false; - } - } - } - - return true; + return this.MatrixIxO.Equals(element.MatrixIxO); } } } diff --git a/src/ImageSharp/Primitives/DenseMatrix{T}.cs b/src/ImageSharp/Primitives/DenseMatrix{T}.cs new file mode 100644 index 0000000000..1f459e7cb0 --- /dev/null +++ b/src/ImageSharp/Primitives/DenseMatrix{T}.cs @@ -0,0 +1,215 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using System; +using System.Diagnostics; +using System.Runtime.CompilerServices; + +namespace SixLabors.ImageSharp.Primitives +{ + /// + /// Represents a dense matrix with arbitrary elements. + /// Components that are adjacent in a column of the matrix are adjacent in the storage array. + /// The components are said to be stored in column major order. + /// + /// The type of elements in the matrix. + public readonly struct DenseMatrix : IEquatable> + where T : struct, IEquatable + { + /// + /// The 1D representation of the dense matrix. + /// + public readonly T[] Data; + + /// + /// Gets the number of columns in the dense matrix. + /// + public readonly int Columns; + + /// + /// Gets the number of rows in the dense matrix. + /// + public readonly int Rows; + + /// + /// Gets the number of items in the array. + /// + public readonly int Count; + + /// + /// Initializes a new instance of the struct. + /// + /// The length of each side in the matrix. + public DenseMatrix(int length) + : this(length, length) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The number of columns. + /// The number of rows. + public DenseMatrix(int columns, int rows) + { + Guard.MustBeGreaterThan(columns, 0, nameof(columns)); + Guard.MustBeGreaterThan(rows, 0, nameof(rows)); + + this.Rows = rows; + this.Columns = columns; + this.Count = columns * rows; + this.Data = new T[this.Columns * this.Rows]; + } + + /// + /// Initializes a new instance of the struct. + /// + /// The 2D array to provide access to. + public DenseMatrix(T[,] data) + { + Guard.NotNull(data, nameof(data)); + int rows = data.GetLength(0); + int columns = data.GetLength(1); + + Guard.MustBeGreaterThan(rows, 0, nameof(this.Rows)); + Guard.MustBeGreaterThan(columns, 0, nameof(this.Columns)); + + this.Rows = rows; + this.Columns = columns; + this.Count = this.Columns * this.Rows; + this.Data = new T[this.Columns * this.Rows]; + + for (int y = 0; y < this.Rows; y++) + { + for (int x = 0; x < this.Columns; x++) + { + ref T value = ref this[y, x]; + value = data[y, x]; + } + } + } + + /// + /// Gets or sets the item at the specified position. + /// + /// The row-coordinate of the item. Must be greater than or equal to zero and less than the height of the array. + /// The column-coordinate of the item. Must be greater than or equal to zero and less than the width of the array. + /// The at the specified position. + public ref T this[int row, int column] + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get + { + this.CheckCoordinates(row, column); + return ref this.Data[(row * this.Columns) + column]; + } + } + + /// + /// Performs an implicit conversion from a to a . + /// + /// The source array. + /// + /// The representation on the source data. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static implicit operator DenseMatrix(T[,] data) => new DenseMatrix(data); + + /// + /// Performs an implicit conversion from a to a . + /// + /// The source array. + /// + /// The representation on the source data. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] +#pragma warning disable SA1008 // Opening parenthesis should be spaced correctly + public static implicit operator T[,] (DenseMatrix data) +#pragma warning restore SA1008 // Opening parenthesis should be spaced correctly + { + var result = new T[data.Rows, data.Columns]; + + for (int y = 0; y < data.Rows; y++) + { + for (int x = 0; x < data.Columns; x++) + { + ref T value = ref result[y, x]; + value = data[y, x]; + } + } + + return result; + } + + /// + /// Fills the matrix with the given value + /// + /// The value to fill each item with + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Fill(T value) + { + for (int i = 0; i < this.Data.Length; i++) + { + this.Data[i] = value; + } + } + + /// + /// Clears the matrix setting each value to the default value for the element type + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Clear() => Array.Clear(this.Data, 0, this.Data.Length); + + /// + /// Checks the coordinates to ensure they are within bounds. + /// + /// The y-coordinate of the item. Must be greater than zero and smaller than the height of the matrix. + /// The x-coordinate of the item. Must be greater than zero and smaller than the width of the matrix. + /// + /// Thrown if the coordinates are not within the bounds of the array. + /// + [Conditional("DEBUG")] + private void CheckCoordinates(int row, int column) + { + if (row < 0 || row >= this.Rows) + { + throw new ArgumentOutOfRangeException(nameof(row), row, $"{row} is outwith the matrix bounds."); + } + + if (column < 0 || column >= this.Columns) + { + throw new ArgumentOutOfRangeException(nameof(column), column, $"{column} is outwith the matrix bounds."); + } + } + + /// + public bool Equals(DenseMatrix other) + { + if (this.Columns != other.Columns) + { + return false; + } + + if (this.Rows != other.Rows) + { + return false; + } + + for (int i = 0; i < this.Data.Length; i++) + { + if (!this.Data[i].Equals(other.Data[i])) + { + return false; + } + } + + return true; + } + + /// + public override bool Equals(object obj) => obj is DenseMatrix matrix && this.Equals(matrix); + + /// + public override int GetHashCode() => this.Data.GetHashCode(); + } +} \ No newline at end of file diff --git a/src/ImageSharp/Numerics/ValueSize.cs b/src/ImageSharp/Primitives/ValueSize.cs similarity index 90% rename from src/ImageSharp/Numerics/ValueSize.cs rename to src/ImageSharp/Primitives/ValueSize.cs index 02573816d9..e64d838e6a 100644 --- a/src/ImageSharp/Numerics/ValueSize.cs +++ b/src/ImageSharp/Primitives/ValueSize.cs @@ -4,7 +4,7 @@ using System; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Primitives { /// /// Represents a value in relation to a value on the image @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp } /// - /// The different vlaue types + /// Enumerates the different value types /// public enum ValueSizeType { @@ -120,10 +120,22 @@ namespace SixLabors.ImageSharp return $"{this.Value} - {this.Type}"; } + /// + public override bool Equals(object obj) + { + return obj is ValueSize size && this.Equals(size); + } + /// public bool Equals(ValueSize other) { return this.Type == other.Type && this.Value.Equals(other.Value); } + + /// + public override int GetHashCode() + { + return HashHelpers.Combine(this.Value.GetHashCode(), this.Type.GetHashCode()); + } } } diff --git a/src/ImageSharp/Processing/Convolution/Processors/BoxBlurProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/BoxBlurProcessor.cs index df3d56bdae..b3e477f3c0 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/BoxBlurProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/BoxBlurProcessor.cs @@ -1,9 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Primitives; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors @@ -42,12 +41,12 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the horizontal gradient operator. /// - public Fast2DArray KernelX { get; } + public DenseMatrix KernelX { get; } /// /// Gets the vertical gradient operator. /// - public Fast2DArray KernelY { get; } + public DenseMatrix KernelY { get; } /// protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) @@ -59,13 +58,13 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// Create a 1 dimensional Box kernel. /// /// Whether to calculate a horizontal kernel. - /// The - private Fast2DArray CreateBoxKernel(bool horizontal) + /// The + private DenseMatrix CreateBoxKernel(bool horizontal) { int size = this.kernelSize; - Fast2DArray kernel = horizontal - ? new Fast2DArray(size, 1) - : new Fast2DArray(1, size); + DenseMatrix kernel = horizontal + ? new DenseMatrix(size, 1) + : new DenseMatrix(1, size); float sum = 0F; for (int i = 0; i < size; i++) diff --git a/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs index 4e46984677..bbdd2f9792 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs @@ -7,9 +7,10 @@ using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// /// Defines a processor that uses two one-dimensional matrices to perform convolution against an image. @@ -23,7 +24,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// /// The horizontal gradient operator. /// The vertical gradient operator. - public Convolution2DProcessor(Fast2DArray kernelX, Fast2DArray kernelY) + public Convolution2DProcessor(DenseMatrix kernelX, DenseMatrix kernelY) { this.KernelX = kernelX; this.KernelY = kernelY; @@ -32,20 +33,20 @@ namespace SixLabors.ImageSharp.Processing.Processors /// /// Gets the horizontal gradient operator. /// - public Fast2DArray KernelX { get; } + public DenseMatrix KernelX { get; } /// /// Gets the vertical gradient operator. /// - public Fast2DArray KernelY { get; } + public DenseMatrix KernelY { get; } /// protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { - int kernelYHeight = this.KernelY.Height; - int kernelYWidth = this.KernelY.Width; - int kernelXHeight = this.KernelX.Height; - int kernelXWidth = this.KernelX.Width; + int kernelYHeight = this.KernelY.Rows; + int kernelYWidth = this.KernelY.Columns; + int kernelXHeight = this.KernelX.Rows; + int kernelXWidth = this.KernelX.Columns; int radiusY = kernelYHeight >> 1; int radiusX = kernelXWidth >> 1; diff --git a/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs index 3ea025512c..51479929f4 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs @@ -4,13 +4,13 @@ using System; using System.Numerics; using System.Threading.Tasks; -using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// /// Defines a processor that uses two one-dimensional matrices to perform two-pass convolution against an image. @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// /// The horizontal gradient operator. /// The vertical gradient operator. - public Convolution2PassProcessor(Fast2DArray kernelX, Fast2DArray kernelY) + public Convolution2PassProcessor(DenseMatrix kernelX, DenseMatrix kernelY) { this.KernelX = kernelX; this.KernelY = kernelY; @@ -33,12 +33,12 @@ namespace SixLabors.ImageSharp.Processing.Processors /// /// Gets the horizontal gradient operator. /// - public Fast2DArray KernelX { get; } + public DenseMatrix KernelX { get; } /// /// Gets the vertical gradient operator. /// - public Fast2DArray KernelY { get; } + public DenseMatrix KernelY { get; } /// protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) @@ -67,11 +67,11 @@ namespace SixLabors.ImageSharp.Processing.Processors Buffer2D targetPixels, Buffer2D sourcePixels, Rectangle sourceRectangle, - Fast2DArray kernel, + DenseMatrix kernel, ParallelOptions parallelOptions) { - int kernelHeight = kernel.Height; - int kernelWidth = kernel.Width; + int kernelHeight = kernel.Rows; + int kernelWidth = kernel.Columns; int radiusY = kernelHeight >> 1; int radiusX = kernelWidth >> 1; diff --git a/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs index 2eff3bf213..eb65091fe0 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs @@ -8,9 +8,10 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Convolution.Processors { /// /// Defines a processor that uses a 2 dimensional matrix to perform convolution against an image. @@ -23,7 +24,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// Initializes a new instance of the class. /// /// The 2d gradient operator. - public ConvolutionProcessor(Fast2DArray kernelXY) + public ConvolutionProcessor(DenseMatrix kernelXY) { this.KernelXY = kernelXY; } @@ -31,12 +32,12 @@ namespace SixLabors.ImageSharp.Processing.Processors /// /// Gets the 2d gradient operator. /// - public Fast2DArray KernelXY { get; } + public DenseMatrix KernelXY { get; } /// protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { - int kernelLength = this.KernelXY.Height; + int kernelLength = this.KernelXY.Rows; int radius = kernelLength >> 1; int startY = sourceRectangle.Y; diff --git a/src/ImageSharp/Processing/Convolution/Processors/EdgeDetector2DProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetector2DProcessor.cs index 74a0194452..d853fdb8eb 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/EdgeDetector2DProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetector2DProcessor.cs @@ -1,10 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Memory; 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 @@ -22,7 +21,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// The horizontal gradient operator. /// The vertical gradient operator. /// Whether to convert the image to grayscale before performing edge detection. - protected EdgeDetector2DProcessor(Fast2DArray kernelX, Fast2DArray kernelY, bool grayscale) + protected EdgeDetector2DProcessor(DenseMatrix kernelX, DenseMatrix kernelY, bool grayscale) { this.KernelX = kernelX; this.KernelY = kernelY; @@ -32,12 +31,12 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the horizontal gradient operator. /// - public Fast2DArray KernelX { get; } + public DenseMatrix KernelX { get; } /// /// Gets the vertical gradient operator. /// - public Fast2DArray KernelY { get; } + public DenseMatrix KernelY { get; } /// public bool Grayscale { get; set; } diff --git a/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorCompassProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorCompassProcessor.cs index df26c23b82..b2f78fc857 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorCompassProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorCompassProcessor.cs @@ -4,10 +4,9 @@ using System; using System.Numerics; using System.Threading.Tasks; -using SixLabors.ImageSharp.Memory; 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 @@ -31,42 +30,42 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the North gradient operator /// - public abstract Fast2DArray North { get; } + public abstract DenseMatrix North { get; } /// /// Gets the NorthWest gradient operator /// - public abstract Fast2DArray NorthWest { get; } + public abstract DenseMatrix NorthWest { get; } /// /// Gets the West gradient operator /// - public abstract Fast2DArray West { get; } + public abstract DenseMatrix West { get; } /// /// Gets the SouthWest gradient operator /// - public abstract Fast2DArray SouthWest { get; } + public abstract DenseMatrix SouthWest { get; } /// /// Gets the South gradient operator /// - public abstract Fast2DArray South { get; } + public abstract DenseMatrix South { get; } /// /// Gets the SouthEast gradient operator /// - public abstract Fast2DArray SouthEast { get; } + public abstract DenseMatrix SouthEast { get; } /// /// Gets the East gradient operator /// - public abstract Fast2DArray East { get; } + public abstract DenseMatrix East { get; } /// /// Gets the NorthEast gradient operator /// - public abstract Fast2DArray NorthEast { get; } + public abstract DenseMatrix NorthEast { get; } /// public bool Grayscale { get; } @@ -83,7 +82,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { - Fast2DArray[] kernels = { this.North, this.NorthWest, this.West, this.SouthWest, this.South, this.SouthEast, this.East, this.NorthEast }; + DenseMatrix[] kernels = { this.North, this.NorthWest, this.West, this.SouthWest, this.South, this.SouthEast, this.East, this.NorthEast }; int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; diff --git a/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorProcessor.cs index cd2e7d76ca..ecb6364a87 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/EdgeDetectorProcessor.cs @@ -1,10 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Memory; 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 @@ -21,7 +20,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// The 2d gradient operator. /// Whether to convert the image to grayscale before performing edge detection. - protected EdgeDetectorProcessor(Fast2DArray kernelXY, bool grayscale) + protected EdgeDetectorProcessor(DenseMatrix kernelXY, bool grayscale) { this.KernelXY = kernelXY; this.Grayscale = grayscale; @@ -33,7 +32,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the 2d gradient operator. /// - public Fast2DArray KernelXY { get; } + public DenseMatrix KernelXY { get; } /// protected override void BeforeFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) diff --git a/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs index 3ce321cd39..328f572352 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs @@ -2,9 +2,8 @@ // Licensed under the Apache License, Version 2.0. using System; -using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Primitives; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors @@ -73,12 +72,12 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the horizontal gradient operator. /// - public Fast2DArray KernelX { get; } + public DenseMatrix KernelX { get; } /// /// Gets the vertical gradient operator. /// - public Fast2DArray KernelY { get; } + public DenseMatrix KernelY { get; } /// protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) @@ -90,14 +89,14 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// Create a 1 dimensional Gaussian kernel using the Gaussian G(x) function /// /// Whether to calculate a horizontal kernel. - /// The - private Fast2DArray CreateGaussianKernel(bool horizontal) + /// The + private DenseMatrix CreateGaussianKernel(bool horizontal) { int size = this.kernelSize; float weight = this.Sigma; - Fast2DArray kernel = horizontal - ? new Fast2DArray(size, 1) - : new Fast2DArray(1, size); + DenseMatrix kernel = horizontal + ? new DenseMatrix(size, 1) + : new DenseMatrix(1, size); float sum = 0F; float midpoint = (size - 1) / 2F; diff --git a/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs index cff0767b1d..df5026db0a 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs @@ -2,9 +2,8 @@ // Licensed under the Apache License, Version 2.0. using System; -using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Primitives; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors @@ -75,12 +74,12 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the horizontal gradient operator. /// - public Fast2DArray KernelX { get; } + public DenseMatrix KernelX { get; } /// /// Gets the vertical gradient operator. /// - public Fast2DArray KernelY { get; } + public DenseMatrix KernelY { get; } /// protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) @@ -92,14 +91,14 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// Create a 1 dimensional Gaussian kernel using the Gaussian G(x) function /// /// Whether to calculate a horizontal kernel. - /// The - private Fast2DArray CreateGaussianKernel(bool horizontal) + /// The + private DenseMatrix CreateGaussianKernel(bool horizontal) { int size = this.kernelSize; float weight = this.Sigma; - Fast2DArray kernel = horizontal - ? new Fast2DArray(size, 1) - : new Fast2DArray(1, size); + DenseMatrix kernel = horizontal + ? new DenseMatrix(size, 1) + : new DenseMatrix(1, size); float sum = 0; diff --git a/src/ImageSharp/Processing/Convolution/Processors/KayyaliKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/KayyaliKernels.cs index b18bd52af2..e131cac38c 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/KayyaliKernels.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/KayyaliKernels.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors { @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the horizontal gradient operator. /// - public static Fast2DArray KayyaliX => + public static DenseMatrix KayyaliX => new float[,] { { 6, 0, -6 }, @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the vertical gradient operator. /// - public static Fast2DArray KayyaliY => + public static DenseMatrix KayyaliY => new float[,] { { -6, 0, 6 }, diff --git a/src/ImageSharp/Processing/Convolution/Processors/KirschProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/KirschProcessor.cs index 3ae333e18e..c9a21da0b7 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/KirschProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/KirschProcessor.cs @@ -1,8 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors { @@ -23,27 +23,27 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors } /// - public override Fast2DArray North => KirshKernels.KirschNorth; + public override DenseMatrix North => KirshKernels.KirschNorth; /// - public override Fast2DArray NorthWest => KirshKernels.KirschNorthWest; + public override DenseMatrix NorthWest => KirshKernels.KirschNorthWest; /// - public override Fast2DArray West => KirshKernels.KirschWest; + public override DenseMatrix West => KirshKernels.KirschWest; /// - public override Fast2DArray SouthWest => KirshKernels.KirschSouthWest; + public override DenseMatrix SouthWest => KirshKernels.KirschSouthWest; /// - public override Fast2DArray South => KirshKernels.KirschSouth; + public override DenseMatrix South => KirshKernels.KirschSouth; /// - public override Fast2DArray SouthEast => KirshKernels.KirschSouthEast; + public override DenseMatrix SouthEast => KirshKernels.KirschSouthEast; /// - public override Fast2DArray East => KirshKernels.KirschEast; + public override DenseMatrix East => KirshKernels.KirschEast; /// - public override Fast2DArray NorthEast => KirshKernels.KirschNorthEast; + public override DenseMatrix NorthEast => KirshKernels.KirschNorthEast; } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/KirshKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/KirshKernels.cs index 99c327055f..8e52f8df4c 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/KirshKernels.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/KirshKernels.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors { @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the North gradient operator /// - public static Fast2DArray KirschNorth => + public static DenseMatrix KirschNorth => new float[,] { { 5, 5, 5 }, @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the NorthWest gradient operator /// - public static Fast2DArray KirschNorthWest => + public static DenseMatrix KirschNorthWest => new float[,] { { 5, 5, -3 }, @@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the West gradient operator /// - public static Fast2DArray KirschWest => + public static DenseMatrix KirschWest => new float[,] { { 5, -3, -3 }, @@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the SouthWest gradient operator /// - public static Fast2DArray KirschSouthWest => + public static DenseMatrix KirschSouthWest => new float[,] { { -3, -3, -3 }, @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the South gradient operator /// - public static Fast2DArray KirschSouth => + public static DenseMatrix KirschSouth => new float[,] { { -3, -3, -3 }, @@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the SouthEast gradient operator /// - public static Fast2DArray KirschSouthEast => + public static DenseMatrix KirschSouthEast => new float[,] { { -3, -3, -3 }, @@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the East gradient operator /// - public static Fast2DArray KirschEast => + public static DenseMatrix KirschEast => new float[,] { { -3, -3, 5 }, @@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the NorthEast gradient operator /// - public static Fast2DArray KirschNorthEast => + public static DenseMatrix KirschNorthEast => new float[,] { { -3, 5, 5 }, diff --git a/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernelFactory.cs b/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernelFactory.cs index e28da14b55..053033432e 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernelFactory.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernelFactory.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors { @@ -15,21 +15,14 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// /// The length of the matrix sides - /// The - public static Fast2DArray CreateKernel(uint length) + /// The + public static DenseMatrix CreateKernel(uint length) { Guard.MustBeGreaterThanOrEqualTo(length, 3u, nameof(length)); Guard.IsFalse(length % 2 == 0, nameof(length), "The kernel length must be an odd number."); - var kernel = new Fast2DArray((int)length); - - for (int y = 0; y < kernel.Height; y++) - { - for (int x = 0; x < kernel.Width; x++) - { - kernel[x, y] = -1; - } - } + var kernel = new DenseMatrix((int)length); + kernel.Fill(-1); int mid = (int)(length / 2); kernel[mid, mid] = (length * length) - 1; diff --git a/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernels.cs index 611982b9a5..4077369802 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernels.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/LaplacianKernels.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors { @@ -13,17 +13,17 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the 3x3 Laplacian kernel /// - public static Fast2DArray Laplacian3x3 => LaplacianKernelFactory.CreateKernel(3); + public static DenseMatrix Laplacian3x3 => LaplacianKernelFactory.CreateKernel(3); /// /// Gets the 5x5 Laplacian kernel /// - public static Fast2DArray Laplacian5x5 => LaplacianKernelFactory.CreateKernel(5); + public static DenseMatrix Laplacian5x5 => LaplacianKernelFactory.CreateKernel(5); /// /// Gets the Laplacian of Gaussian kernel. /// - public static Fast2DArray LaplacianOfGaussianXY => + public static DenseMatrix LaplacianOfGaussianXY => new float[,] { { 0, 0, -1, 0, 0 }, diff --git a/src/ImageSharp/Processing/Convolution/Processors/PrewittKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/PrewittKernels.cs index 64bce4f8cc..aba4d52c34 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/PrewittKernels.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/PrewittKernels.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors { @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the horizontal gradient operator. /// - public static Fast2DArray PrewittX => + public static DenseMatrix PrewittX => new float[,] { { -1, 0, 1 }, @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the vertical gradient operator. /// - public static Fast2DArray PrewittY => + public static DenseMatrix PrewittY => new float[,] { { 1, 1, 1 }, diff --git a/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossKernels.cs index 63d96c79bd..64d1fcea54 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossKernels.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/RobertsCrossKernels.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors { @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the horizontal gradient operator. /// - public static Fast2DArray RobertsCrossX => + public static DenseMatrix RobertsCrossX => new float[,] { { 1, 0 }, @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the vertical gradient operator. /// - public static Fast2DArray RobertsCrossY => + public static DenseMatrix RobertsCrossY => new float[,] { { 0, 1 }, diff --git a/src/ImageSharp/Processing/Convolution/Processors/RobinsonKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/RobinsonKernels.cs index e102023290..9d440fcc0d 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/RobinsonKernels.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/RobinsonKernels.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors { @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the North gradient operator /// - public static Fast2DArray RobinsonNorth => + public static DenseMatrix RobinsonNorth => new float[,] { { 1, 2, 1 }, @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the NorthWest gradient operator /// - public static Fast2DArray RobinsonNorthWest => + public static DenseMatrix RobinsonNorthWest => new float[,] { { 2, 1, 0 }, @@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the West gradient operator /// - public static Fast2DArray RobinsonWest => + public static DenseMatrix RobinsonWest => new float[,] { { 1, 0, -1 }, @@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the SouthWest gradient operator /// - public static Fast2DArray RobinsonSouthWest => + public static DenseMatrix RobinsonSouthWest => new float[,] { { 0, -1, -2 }, @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the South gradient operator /// - public static Fast2DArray RobinsonSouth => + public static DenseMatrix RobinsonSouth => new float[,] { { -1, -2, -1 }, @@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the SouthEast gradient operator /// - public static Fast2DArray RobinsonSouthEast => + public static DenseMatrix RobinsonSouthEast => new float[,] { { -2, -1, 0 }, @@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the East gradient operator /// - public static Fast2DArray RobinsonEast => + public static DenseMatrix RobinsonEast => new float[,] { { -1, 0, 1 }, @@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the NorthEast gradient operator /// - public static Fast2DArray RobinsonNorthEast => + public static DenseMatrix RobinsonNorthEast => new float[,] { { 0, 1, 2 }, diff --git a/src/ImageSharp/Processing/Convolution/Processors/RobinsonProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/RobinsonProcessor.cs index fac0c52e5a..f129b1daa2 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/RobinsonProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/RobinsonProcessor.cs @@ -1,8 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors { @@ -24,27 +24,27 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors } /// - public override Fast2DArray North => RobinsonKernels.RobinsonNorth; + public override DenseMatrix North => RobinsonKernels.RobinsonNorth; /// - public override Fast2DArray NorthWest => RobinsonKernels.RobinsonNorthWest; + public override DenseMatrix NorthWest => RobinsonKernels.RobinsonNorthWest; /// - public override Fast2DArray West => RobinsonKernels.RobinsonWest; + public override DenseMatrix West => RobinsonKernels.RobinsonWest; /// - public override Fast2DArray SouthWest => RobinsonKernels.RobinsonSouthWest; + public override DenseMatrix SouthWest => RobinsonKernels.RobinsonSouthWest; /// - public override Fast2DArray South => RobinsonKernels.RobinsonSouth; + public override DenseMatrix South => RobinsonKernels.RobinsonSouth; /// - public override Fast2DArray SouthEast => RobinsonKernels.RobinsonSouthEast; + public override DenseMatrix SouthEast => RobinsonKernels.RobinsonSouthEast; /// - public override Fast2DArray East => RobinsonKernels.RobinsonEast; + public override DenseMatrix East => RobinsonKernels.RobinsonEast; /// - public override Fast2DArray NorthEast => RobinsonKernels.RobinsonNorthEast; + public override DenseMatrix NorthEast => RobinsonKernels.RobinsonNorthEast; } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Convolution/Processors/ScharrKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/ScharrKernels.cs index cf8b9925ad..c309e4cec5 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/ScharrKernels.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/ScharrKernels.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors { @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the horizontal gradient operator. /// - public static Fast2DArray ScharrX => + public static DenseMatrix ScharrX => new float[,] { { -3, 0, 3 }, @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the vertical gradient operator. /// - public static Fast2DArray ScharrY => + public static DenseMatrix ScharrY => new float[,] { { 3, 10, 3 }, diff --git a/src/ImageSharp/Processing/Convolution/Processors/SobelKernels.cs b/src/ImageSharp/Processing/Convolution/Processors/SobelKernels.cs index 691bd66149..626226c660 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/SobelKernels.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/SobelKernels.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Processing.Convolution.Processors { @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the horizontal gradient operator. /// - public static Fast2DArray SobelX => + public static DenseMatrix SobelX => new float[,] { { -1, 0, 1 }, @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// Gets the vertical gradient operator. /// - public static Fast2DArray SobelY => + public static DenseMatrix SobelY => new float[,] { { -1, -2, -1 }, diff --git a/src/ImageSharp/Processing/Overlays/Glow.cs b/src/ImageSharp/Processing/Overlays/Glow.cs index af80666d6f..80eb4287ab 100644 --- a/src/ImageSharp/Processing/Overlays/Glow.cs +++ b/src/ImageSharp/Processing/Overlays/Glow.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.ImageSharp.Processing.Processors.Overlays; using SixLabors.Primitives; diff --git a/src/ImageSharp/Processing/Overlays/Vignette.cs b/src/ImageSharp/Processing/Overlays/Vignette.cs index ba2424d77a..4df53f14e9 100644 --- a/src/ImageSharp/Processing/Overlays/Vignette.cs +++ b/src/ImageSharp/Processing/Overlays/Vignette.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.ImageSharp.Processing.Processors.Overlays; using SixLabors.Primitives; diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs index d08283a0fe..abd0c15bb0 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs @@ -8,6 +8,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Processors.Overlays diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs index 3a2fc595c8..ad73b6553a 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs @@ -8,6 +8,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Processors.Overlays diff --git a/tests/ImageSharp.Benchmarks/General/Array2D.cs b/tests/ImageSharp.Benchmarks/General/Array2D.cs index 02df1a19e2..60d89847fd 100644 --- a/tests/ImageSharp.Benchmarks/General/Array2D.cs +++ b/tests/ImageSharp.Benchmarks/General/Array2D.cs @@ -9,7 +9,18 @@ namespace SixLabors.ImageSharp.Benchmarks.General using BenchmarkDotNet.Attributes; - using SixLabors.ImageSharp.Memory; + using SixLabors.ImageSharp.Primitives; + + /** + * Method | Count | Mean | Error | StdDev | Scaled | ScaledSD | +-------------------------------------------- |------ |---------:|---------:|---------:|-------:|---------:| + 'Emulated 2D array access using flat array' | 32 | 224.2 ns | 4.739 ns | 13.75 ns | 0.65 | 0.07 | + 'Array access using 2D array' | 32 | 346.6 ns | 9.225 ns | 26.91 ns | 1.00 | 0.00 | + 'Array access using a jagged array' | 32 | 229.3 ns | 6.028 ns | 17.58 ns | 0.67 | 0.07 | + 'Array access using DenseMatrix' | 32 | 223.2 ns | 5.248 ns | 15.22 ns | 0.65 | 0.07 | + + * + */ public class Array2D { @@ -19,9 +30,9 @@ namespace SixLabors.ImageSharp.Benchmarks.General private float[][] jaggedData; - private Fast2DArray fastData; - - [Params(4, 16, 128)] + private DenseMatrix matrix; + + [Params(4, 16, 32)] public int Count { get; set; } public int Min { get; private set; } @@ -39,9 +50,9 @@ namespace SixLabors.ImageSharp.Benchmarks.General this.jaggedData[i] = new float[this.Count]; } - this.fastData = new Fast2DArray(this.array2D); + this.matrix = new DenseMatrix(this.array2D); - this.Min = this.Count / 2 - 10; + this.Min = (this.Count / 2) - 10; this.Min = Math.Max(0, this.Min); this.Max = this.Min + Math.Min(10, this.Count); } @@ -56,7 +67,9 @@ namespace SixLabors.ImageSharp.Benchmarks.General { for (int j = this.Min; j < this.Max; j++) { - s += a[count * i + j]; + ref float v = ref a[count * i + j]; + v = i * j; + s += v; } } return s; @@ -71,7 +84,9 @@ namespace SixLabors.ImageSharp.Benchmarks.General { for (int j = this.Min; j < this.Max; j++) { - s += a[i, j]; + ref float v = ref a[i, j]; + v = i * j; + s += v; } } return s; @@ -86,25 +101,29 @@ namespace SixLabors.ImageSharp.Benchmarks.General { for (int j = this.Min; j < this.Max; j++) { - s += a[i][j]; + ref float v = ref a[i][j]; + v = i * j; + s += v; } } return s; } - [Benchmark(Description = "Array access using Fast2DArray")] - public float ArrayFastIndex() + [Benchmark(Description = "Array access using DenseMatrix")] + public float ArrayMatrixIndex() { float s = 0; - Fast2DArray a = this.fastData; + DenseMatrix a = this.matrix; for (int i = this.Min; i < this.Max; i++) { for (int j = this.Min; j < this.Max; j++) { - s += a[i, j]; + ref float v = ref a[i, j]; + v = i * j; + s += v; } } return s; } } -} +} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs index 70badd34c5..4c6cc7acb3 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void FilledBezier(TestImageProvider provider) where TPixel : struct, IPixel { - Primitives.PointF[] simplePath = { + SixLabors.Primitives.PointF[] simplePath = { new Vector2(10, 400), new Vector2(30, 10), new Vector2(240, 30), @@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void OverlayByFilledPolygonOpacity(TestImageProvider provider) where TPixel : struct, IPixel { - Primitives.PointF[] simplePath = { + SixLabors.Primitives.PointF[] simplePath = { new Vector2(10, 400), new Vector2(30, 10), new Vector2(240, 30), diff --git a/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs b/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs new file mode 100644 index 0000000000..7d161d35f7 --- /dev/null +++ b/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs @@ -0,0 +1,108 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using System; +using SixLabors.ImageSharp.Primitives; +using Xunit; + +namespace SixLabors.ImageSharp.Tests.Primitives +{ + public class DenseMatrixTests + { + private static readonly float[,] FloydSteinbergMatrix = + { + { 0, 0, 7 }, + { 3, 5, 1 } + }; + + [Fact] + public void DenseMatrixThrowsOnNullInitializer() + { + Assert.Throws(() => + { + var dense = new DenseMatrix(null); + }); + } + + [Fact] + public void DenseMatrixThrowsOnEmptyZeroWidth() + { + Assert.Throws(() => + { + var dense = new DenseMatrix(0, 10); + }); + } + + [Fact] + public void DenseMatrixThrowsOnEmptyZeroHeight() + { + Assert.Throws(() => + { + var dense = new DenseMatrix(10, 0); + }); + } + + [Fact] + public void DenseMatrixThrowsOnEmptyInitializer() + { + Assert.Throws(() => + { + var dense = new DenseMatrix(new float[0, 0]); + }); + } + + [Fact] + public void DenseMatrixReturnsCorrectDimensions() + { + var dense = new DenseMatrix(FloydSteinbergMatrix); + Assert.True(dense.Columns == FloydSteinbergMatrix.GetLength(1)); + Assert.True(dense.Rows == FloydSteinbergMatrix.GetLength(0)); + Assert.Equal(3, dense.Columns); + Assert.Equal(2, dense.Rows); + } + + [Fact] + public void DenseMatrixGetReturnsCorrectResults() + { + DenseMatrix dense = FloydSteinbergMatrix; + + for (int row = 0; row < dense.Rows; row++) + { + for (int column = 0; column < dense.Columns; column++) + { + Assert.True(Math.Abs(dense[row, column] - FloydSteinbergMatrix[row, column]) < Constants.Epsilon); + } + } + } + + [Fact] + public void DenseMatrixGetSetReturnsCorrectResults() + { + var dense = new DenseMatrix(4, 4); + const int Val = 5; + + dense[3, 3] = Val; + + Assert.Equal(Val, dense[3, 3]); + } + + [Fact] + public void DenseMatrixCanFillAndClear() + { + var dense = new DenseMatrix(9); + dense.Fill(4); + + for (int i = 0; i < dense.Data.Length; i++) + { + Assert.Equal(4, dense.Data[i]); + } + + dense.Clear(); + + for (int i = 0; i < dense.Data.Length; i++) + { + Assert.Equal(0, dense.Data[i]); + } + } + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs index b3ecdacbeb..0a87f8343a 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs @@ -9,6 +9,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Overlays { + using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing.Processors.Overlays; public class GlowTest : BaseImageOperationsExtensionTest diff --git a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs index 01555c02a8..25b7d26ad1 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs @@ -10,6 +10,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Overlays { + using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing.Processors.Overlays; public class VignetteTest : BaseImageOperationsExtensionTest From 091cb8a3b5d12e608c69c4ab46e5b8407aead1ca Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 9 Mar 2018 10:56:36 +1100 Subject: [PATCH 03/18] 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 ae70cdee43..7541be7893 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 b390e46ae9..0000000000 --- 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 5ee6b4bc1a..5e3d73fd19 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 0a84eab8ba..0e90efc7ec 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 22aad9ca6a..72cba78e54 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 80eb4287ab..a86128f88d 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 d07dcbeed8..c91cc93c2f 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 abd0c15bb0..7477c13906 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 ad73b6553a..bca63b314b 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 4df53f14e9..e533c914ff 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 c4954ef0d1..97faab88f6 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 a089ffe1a1..e7a9fc3f76 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 0bfc149772..2ff00d5833 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 f2a09abb77..70e2814d85 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 ce1a88599a..a8042c77cf 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 4f40c001d9..f89d9a6846 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 fd8e4ad285..aa24088ae0 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 f948c4921f..9075e02e89 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 b3890c101e..1fd2dbe826 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 46d02e4197..64132e479e 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 3681ff6f20..17c3933c08 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 b14630cea8..2771aa2e0f 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 6e7e2c8c48..8bba227c5b 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 5ffd9f5f14..af1364af43 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 df029d2d72..bea0d8b07d 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 429acafb95..3902e874ce 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 d37058f5d1..bd06e1f1f5 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 79ebf47787..21113f48cb 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 6eb139baca..88b6a8b258 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 6c0670a85e..8eb8d21592 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 d8c5c41d8b..7b26d9e1db 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 a43f14eb71..f2d5187e3d 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 52668cc56c..baaa8fe2a3 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 4c6cc7acb3..1fc1b172fb 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 e1849b0d01..59ddc43edc 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 be7c8adb08..fbb0f00957 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 3a5fbe8387..aed68f76b5 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 22a811feee..463d5c7d80 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 cc030bbf7c..ec34691531 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 0010bb41d3..d2ea982aee 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 fc17df93d1..660f01dff4 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 f8f7b6758a..e226e1ce8e 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 73c2f78f40..59677ac784 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 b77112ba68..77db68281c 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 a5364db721..0000000000 --- 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 437c223fa9..f01a5ef96d 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 a0ddc2c7cc..e9a97992aa 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 518a28bea0..73d3c80230 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 a24b8a4d47..ceb25d58ea 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 0a87f8343a..0d4695c29f 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 25b7d26ad1..665b6cf1ca 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 eb41c8435a..f5f0ee7a69 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 42b9b9adf6..b1092782cc 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 a86d5d3a03..b49fbf435e 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 d5885bb98c..69a635e9d7 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 4f3237a21b..468aa277c6 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 68d6efeec7..519790655f 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 2dd44b3a76..1e234e81ea 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 868763baf4..715e997bf1 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 98bfbc5538..84831e4159 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 5693b6d755..5c610fb316 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 0d9c3e89b3..1c69b531c7 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 aa18feac2d..69515b2cbd 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 57341560e3..27502df30d 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 b5f26b4883..f83a08bae1 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 8e4b7d3d5b..02bda3a0bb 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 32860d2a4d..9901661f4c 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 1352a2476a..0f96348375 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 f03f9db09a..3df71a08af 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 dd033ae7c8..d31094085b 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 3f8ec05568..8e6d60a509 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 c67e4e06bf..6ff935b546 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; From fe64365532750191d10a4574c581a4eee2ba6b84 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 9 Mar 2018 14:21:42 +1100 Subject: [PATCH 04/18] Transforms --- src/ImageSharp/Image/ImageFrameCollection.cs | 7 +-- .../Processors/GaussianBlurProcessor.cs | 2 +- .../Processors/GaussianSharpenProcessor.cs | 2 +- .../Processors/CloningImageProcessor.cs | 2 +- .../{Options => }/AnchorPosition.cs | 2 +- ...{AutoOrient.cs => AutoOrientExtensions.cs} | 8 +-- .../{Resamplers => }/BicubicResampler.cs | 6 +-- .../{Resamplers => }/BoxResampler.cs | 4 +- .../{Resamplers => }/CatmullRomResampler.cs | 4 +- .../Transforms/{Crop.cs => CropExtensions.cs} | 13 +++-- .../Processing/Transforms/EntropyCrop.cs | 26 --------- .../Transforms/EntropyCropExtensions.cs | 35 ++++++++++++ .../Transforms/{Flip.cs => FlipExtensions.cs} | 12 ++--- .../Transforms/{Options => }/FlipType.cs | 4 +- .../{Resamplers => }/HermiteResampler.cs | 4 +- .../Transforms/{Resamplers => }/IResampler.cs | 4 +- .../{Resamplers => }/Lanczos2Resampler.cs | 4 +- .../{Resamplers => }/Lanczos3Resampler.cs | 4 +- .../{Resamplers => }/Lanczos5Resampler.cs | 4 +- .../{Resamplers => }/Lanczos8Resampler.cs | 4 +- .../MitchellNetravaliResampler.cs | 4 +- .../NearestNeighborResampler.cs | 4 +- .../Orientation.cs => OrientationType.cs} | 4 +- .../Transforms/{Pad.cs => PadExtensions.cs} | 9 ++-- .../Processors/AffineTransformProcessor.cs | 6 +-- .../Processors/AutoOrientProcessor.cs | 40 +++++++------- .../CenteredAffineTransformProcessor.cs | 6 +-- .../CenteredProjectiveTransformProcessor.cs | 2 +- .../Transforms/Processors/CropProcessor.cs | 53 ++++++++++--------- .../Processors/EntropyCropProcessor.cs | 43 +++++++++------ .../Transforms/Processors/FlipProcessor.cs | 8 ++- .../InterpolatedTransformProcessorBase.cs | 4 +- .../ProjectiveTransformProcessor.cs | 4 +- .../Transforms/Processors/ResizeProcessor.cs | 36 +++++++------ .../Transforms/Processors/RotateProcessor.cs | 3 +- .../Transforms/Processors/SkewProcessor.cs | 2 +- .../Processors/TransformProcessorBase.cs | 3 +- .../Transforms/{Resamplers => }/Resamplers.cs | 2 +- .../{Resize.cs => ResizeExtensions.cs} | 29 +++++----- .../Transforms/{Options => }/ResizeHelper.cs | 2 +- .../Transforms/{Options => }/ResizeMode.cs | 2 +- .../Transforms/{Options => }/ResizeOptions.cs | 4 +- .../{Resamplers => }/RobidouxResampler.cs | 4 +- .../RobidouxSharpResampler.cs | 4 +- .../{Rotate.cs => RotateExtensions.cs} | 15 +++--- ...{RotateFlip.cs => RotateFlipExtensions.cs} | 14 ++--- .../Transforms/{Options => }/RotateType.cs | 4 +- .../Transforms/{Skew.cs => SkewExtensions.cs} | 13 +++-- .../{Resamplers => }/SplineResampler.cs | 4 +- .../{Transform.cs => TransformExtensions.cs} | 13 ++--- .../Processing/Transforms/TransformHelpers.cs | 2 +- .../{Resamplers => }/TriangleResampler.cs | 4 +- .../{Resamplers => }/WelchResampler.cs | 2 +- tests/ImageSharp.Benchmarks/Samplers/Crop.cs | 3 +- .../ImageSharp.Benchmarks/Samplers/Resize.cs | 1 + .../ComplexIntegrationTests.cs | 1 + .../ImageSharp.Tests/Drawing/DrawImageTest.cs | 2 + .../Drawing/FillPatternTests.cs | 1 + .../Formats/Png/PngSmokeTests.cs | 1 + .../Image/ImageProcessingContextTests.cs | 1 + .../Image/ImageRotationTests.cs | 1 + .../Processors/Transforms/AutoOrientTests.cs | 2 + .../Processors/Transforms/CropTest.cs | 1 + .../Processors/Transforms/EntropyCropTest.cs | 1 + .../Processors/Transforms/FlipTests.cs | 2 + .../Processors/Transforms/PadTest.cs | 1 + .../Transforms/ResizeProfilingBenchmarks.cs | 3 ++ .../Processors/Transforms/ResizeTests.cs | 2 + .../Processors/Transforms/RotateFlipTests.cs | 2 + .../Processors/Transforms/RotateTests.cs | 2 + .../Processors/Transforms/SkewTest.cs | 1 + .../Transforms/AffineTransformTests.cs | 4 +- .../Processing/Transforms/AutoOrientTests.cs | 4 +- .../Processing/Transforms/CropTest.cs | 19 ++++--- .../Processing/Transforms/EntropyCropTest.cs | 18 +++---- .../Processing/Transforms/FlipTests.cs | 5 +- .../Processing/Transforms/PadTest.cs | 3 +- .../Processing/Transforms/ResizeTests.cs | 5 +- .../Processing/Transforms/RotateFlipTests.cs | 9 ++-- .../Processing/Transforms/RotateTests.cs | 3 ++ .../Processing/Transforms/SkewTest.cs | 3 ++ .../Transforms/TransformsHelpersTest.cs | 2 + .../TestUtilities/Tests/ImageComparerTests.cs | 1 + 83 files changed, 323 insertions(+), 281 deletions(-) rename src/ImageSharp/Processing/Transforms/{Options => }/AnchorPosition.cs (96%) rename src/ImageSharp/Processing/Transforms/{AutoOrient.cs => AutoOrientExtensions.cs} (74%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/BicubicResampler.cs (87%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/BoxResampler.cs (92%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/CatmullRomResampler.cs (93%) rename src/ImageSharp/Processing/Transforms/{Crop.cs => CropExtensions.cs} (78%) delete mode 100644 src/ImageSharp/Processing/Transforms/EntropyCrop.cs create mode 100644 src/ImageSharp/Processing/Transforms/EntropyCropExtensions.cs rename src/ImageSharp/Processing/Transforms/{Flip.cs => FlipExtensions.cs} (69%) rename src/ImageSharp/Processing/Transforms/{Options => }/FlipType.cs (90%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/HermiteResampler.cs (92%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/IResampler.cs (92%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/Lanczos2Resampler.cs (93%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/Lanczos3Resampler.cs (93%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/Lanczos5Resampler.cs (93%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/Lanczos8Resampler.cs (93%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/MitchellNetravaliResampler.cs (92%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/NearestNeighborResampler.cs (90%) rename src/ImageSharp/Processing/Transforms/{Options/Orientation.cs => OrientationType.cs} (93%) rename src/ImageSharp/Processing/Transforms/{Pad.cs => PadExtensions.cs} (80%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/Resamplers.cs (98%) rename src/ImageSharp/Processing/Transforms/{Resize.cs => ResizeExtensions.cs} (88%) rename src/ImageSharp/Processing/Transforms/{Options => }/ResizeHelper.cs (99%) rename src/ImageSharp/Processing/Transforms/{Options => }/ResizeMode.cs (96%) rename src/ImageSharp/Processing/Transforms/{Options => }/ResizeOptions.cs (96%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/RobidouxResampler.cs (92%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/RobidouxSharpResampler.cs (92%) rename src/ImageSharp/Processing/Transforms/{Rotate.cs => RotateExtensions.cs} (80%) rename src/ImageSharp/Processing/Transforms/{RotateFlip.cs => RotateFlipExtensions.cs} (76%) rename src/ImageSharp/Processing/Transforms/{Options => }/RotateType.cs (92%) rename src/ImageSharp/Processing/Transforms/{Skew.cs => SkewExtensions.cs} (79%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/SplineResampler.cs (91%) rename src/ImageSharp/Processing/Transforms/{Transform.cs => TransformExtensions.cs} (94%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/TriangleResampler.cs (93%) rename src/ImageSharp/Processing/Transforms/{Resamplers => }/WelchResampler.cs (92%) diff --git a/src/ImageSharp/Image/ImageFrameCollection.cs b/src/ImageSharp/Image/ImageFrameCollection.cs index aefeacce15..e85e67c741 100644 --- a/src/ImageSharp/Image/ImageFrameCollection.cs +++ b/src/ImageSharp/Image/ImageFrameCollection.cs @@ -10,7 +10,7 @@ using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp { /// - /// Encapsulates an imaged collection of frames. + /// Encapsulates a collection of frames that make up an image. /// /// The type of the pixel. internal sealed class ImageFrameCollection : IImageFrameCollection @@ -51,10 +51,7 @@ namespace SixLabors.ImageSharp public ImageFrame RootFrame => this.frames.Count > 0 ? this.frames[0] : null; /// - public ImageFrame this[int index] - { - get => this.frames[index]; - } + public ImageFrame this[int index] => this.frames[index]; /// public int IndexOf(ImageFrame frame) => this.frames.IndexOf(frame); diff --git a/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs index 328f572352..9b3ad51b7d 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// Initializes a new instance of the class. /// /// The 'sigma' value representing the weight of the blur. - public GaussianBlurProcessor(float sigma = 3f) + public GaussianBlurProcessor(float sigma = 3F) { this.kernelSize = ((int)Math.Ceiling(sigma) * 2) + 1; this.Sigma = sigma; diff --git a/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs index df5026db0a..bb55e60c9b 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs @@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// /// The 'sigma' value representing the weight of the sharpening. /// - public GaussianSharpenProcessor(float sigma = 3f) + public GaussianSharpenProcessor(float sigma = 3F) { this.kernelSize = ((int)Math.Ceiling(sigma) * 2) + 1; this.Sigma = sigma; diff --git a/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs b/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs index e7a9fc3f76..ec342dd9fe 100644 --- a/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs @@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.Processing.Processors #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/Transforms/Options/AnchorPosition.cs b/src/ImageSharp/Processing/Transforms/AnchorPosition.cs similarity index 96% rename from src/ImageSharp/Processing/Transforms/Options/AnchorPosition.cs rename to src/ImageSharp/Processing/Transforms/AnchorPosition.cs index 263af14ccd..4519f90f94 100644 --- a/src/ImageSharp/Processing/Transforms/Options/AnchorPosition.cs +++ b/src/ImageSharp/Processing/Transforms/AnchorPosition.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// Enumerated anchor positions to apply to resized images. diff --git a/src/ImageSharp/Processing/Transforms/AutoOrient.cs b/src/ImageSharp/Processing/Transforms/AutoOrientExtensions.cs similarity index 74% rename from src/ImageSharp/Processing/Transforms/AutoOrient.cs rename to src/ImageSharp/Processing/Transforms/AutoOrientExtensions.cs index b8b31ff278..d3ac16708a 100644 --- a/src/ImageSharp/Processing/Transforms/AutoOrient.cs +++ b/src/ImageSharp/Processing/Transforms/AutoOrientExtensions.cs @@ -2,14 +2,14 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Processors; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Transforms { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of auto-orientation operations to the type. /// - public static partial class ImageExtensions + public static class AutoOrientExtensions { /// /// Adjusts an image so that its orientation is suitable for viewing. Adjustments are based on EXIF metadata embedded in the image. diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/BicubicResampler.cs b/src/ImageSharp/Processing/Transforms/BicubicResampler.cs similarity index 87% rename from src/ImageSharp/Processing/Transforms/Resamplers/BicubicResampler.cs rename to src/ImageSharp/Processing/Transforms/BicubicResampler.cs index be9de9edaa..5a48fd4ad3 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/BicubicResampler.cs +++ b/src/ImageSharp/Processing/Transforms/BicubicResampler.cs @@ -1,12 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The function implements the bicubic kernel algorithm W(x) as described on /// Wikipedia - /// A commonly used algorithm within imageprocessing that preserves sharpness better than triangle interpolation. + /// A commonly used algorithm within image processing that preserves sharpness better than triangle interpolation. /// public class BicubicResampler : IResampler { @@ -38,4 +38,4 @@ namespace SixLabors.ImageSharp.Processing return result; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/BoxResampler.cs b/src/ImageSharp/Processing/Transforms/BoxResampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Resamplers/BoxResampler.cs rename to src/ImageSharp/Processing/Transforms/BoxResampler.cs index 5aab0d07fa..fa31ac4fb5 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/BoxResampler.cs +++ b/src/ImageSharp/Processing/Transforms/BoxResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The function implements the box algorithm. Similar to nearest neighbor when upscaling. @@ -23,4 +23,4 @@ namespace SixLabors.ImageSharp.Processing return 0; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/CatmullRomResampler.cs b/src/ImageSharp/Processing/Transforms/CatmullRomResampler.cs similarity index 93% rename from src/ImageSharp/Processing/Transforms/Resamplers/CatmullRomResampler.cs rename to src/ImageSharp/Processing/Transforms/CatmullRomResampler.cs index 1c84676188..03723823bb 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/CatmullRomResampler.cs +++ b/src/ImageSharp/Processing/Transforms/CatmullRomResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The Catmull-Rom filter is a well known standard Cubic Filter often used as a interpolation function. @@ -23,4 +23,4 @@ namespace SixLabors.ImageSharp.Processing return ImageMaths.GetBcValue(x, B, C); } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Crop.cs b/src/ImageSharp/Processing/Transforms/CropExtensions.cs similarity index 78% rename from src/ImageSharp/Processing/Transforms/Crop.cs rename to src/ImageSharp/Processing/Transforms/CropExtensions.cs index 3fa59c2483..9e347f51cb 100644 --- a/src/ImageSharp/Processing/Transforms/Crop.cs +++ b/src/ImageSharp/Processing/Transforms/CropExtensions.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.Transforms.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Transforms { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of cropping operations to the type. /// - public static partial class ImageExtensions + public static class CropExtensions { /// /// Crops an image to the given width and height. @@ -23,7 +22,7 @@ namespace SixLabors.ImageSharp /// The public static IImageProcessingContext Crop(this IImageProcessingContext source, int width, int height) where TPixel : struct, IPixel - => Crop(source, new Rectangle(0, 0, width, height)); + => Crop(source, new Rectangle(0, 0, width, height)); /// /// Crops an image to the given rectangle. @@ -36,6 +35,6 @@ namespace SixLabors.ImageSharp /// The public static IImageProcessingContext Crop(this IImageProcessingContext source, Rectangle cropRectangle) where TPixel : struct, IPixel - => source.ApplyProcessor(new CropProcessor(cropRectangle)); + => source.ApplyProcessor(new CropProcessor(cropRectangle)); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/EntropyCrop.cs b/src/ImageSharp/Processing/Transforms/EntropyCrop.cs deleted file mode 100644 index cbd2b46599..0000000000 --- a/src/ImageSharp/Processing/Transforms/EntropyCrop.cs +++ /dev/null @@ -1,26 +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.Processors; - -namespace SixLabors.ImageSharp -{ - /// - /// Extension methods for the type. - /// - public static partial class ImageExtensions - { - /// - /// Crops an image to the area of greatest entropy. - /// - /// The pixel format. - /// The image to crop. - /// The threshold for entropic density. - /// The - public static IImageProcessingContext EntropyCrop(this IImageProcessingContext source, float threshold = .5f) - where TPixel : struct, IPixel - => source.ApplyProcessor(new EntropyCropProcessor(threshold)); - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/EntropyCropExtensions.cs b/src/ImageSharp/Processing/Transforms/EntropyCropExtensions.cs new file mode 100644 index 0000000000..3ca4c72bc1 --- /dev/null +++ b/src/ImageSharp/Processing/Transforms/EntropyCropExtensions.cs @@ -0,0 +1,35 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Transforms.Processors; + +namespace SixLabors.ImageSharp.Processing.Transforms +{ + /// + /// Adds extensions that allow the application of entropy cropping operations to the type. + /// + public static class EntropyCropExtensions + { + /// + /// Crops an image to the area of greatest entropy using a threshold for entropic density of .5F. + /// + /// The pixel format. + /// The image to crop. + /// The + public static IImageProcessingContext EntropyCrop(this IImageProcessingContext source) + where TPixel : struct, IPixel + => source.ApplyProcessor(new EntropyCropProcessor()); + + /// + /// Crops an image to the area of greatest entropy. + /// + /// The pixel format. + /// The image to crop. + /// The threshold for entropic density. + /// The + public static IImageProcessingContext EntropyCrop(this IImageProcessingContext source, float threshold) + where TPixel : struct, IPixel + => source.ApplyProcessor(new EntropyCropProcessor(threshold)); + } +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Flip.cs b/src/ImageSharp/Processing/Transforms/FlipExtensions.cs similarity index 69% rename from src/ImageSharp/Processing/Transforms/Flip.cs rename to src/ImageSharp/Processing/Transforms/FlipExtensions.cs index e153e89f28..e88074c137 100644 --- a/src/ImageSharp/Processing/Transforms/Flip.cs +++ b/src/ImageSharp/Processing/Transforms/FlipExtensions.cs @@ -1,17 +1,15 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Processors; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Transforms { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of flipping operations to the type. /// - public static partial class ImageExtensions + public static class FlipExtensions { /// /// Flips an image by the given instructions. @@ -22,6 +20,6 @@ namespace SixLabors.ImageSharp /// The public static IImageProcessingContext Flip(this IImageProcessingContext source, FlipType flipType) where TPixel : struct, IPixel - => source.ApplyProcessor(new FlipProcessor(flipType)); + => source.ApplyProcessor(new FlipProcessor(flipType)); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Options/FlipType.cs b/src/ImageSharp/Processing/Transforms/FlipType.cs similarity index 90% rename from src/ImageSharp/Processing/Transforms/Options/FlipType.cs rename to src/ImageSharp/Processing/Transforms/FlipType.cs index 0129891f66..71a4e6fc8f 100644 --- a/src/ImageSharp/Processing/Transforms/Options/FlipType.cs +++ b/src/ImageSharp/Processing/Transforms/FlipType.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// Provides enumeration over how a image should be flipped. @@ -23,4 +23,4 @@ namespace SixLabors.ImageSharp.Processing /// Vertical, } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/HermiteResampler.cs b/src/ImageSharp/Processing/Transforms/HermiteResampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Resamplers/HermiteResampler.cs rename to src/ImageSharp/Processing/Transforms/HermiteResampler.cs index 33435059f1..f41c03e2db 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/HermiteResampler.cs +++ b/src/ImageSharp/Processing/Transforms/HermiteResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The Hermite filter is type of smoothed triangular interpolation Filter, @@ -22,4 +22,4 @@ namespace SixLabors.ImageSharp.Processing return ImageMaths.GetBcValue(x, B, C); } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/IResampler.cs b/src/ImageSharp/Processing/Transforms/IResampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Resamplers/IResampler.cs rename to src/ImageSharp/Processing/Transforms/IResampler.cs index 9a128a05be..fd23a4644d 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/IResampler.cs +++ b/src/ImageSharp/Processing/Transforms/IResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// Encapsulates an interpolation algorithm for resampling images. @@ -22,4 +22,4 @@ namespace SixLabors.ImageSharp.Processing /// float GetValue(float x); } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs b/src/ImageSharp/Processing/Transforms/Lanczos2Resampler.cs similarity index 93% rename from src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs rename to src/ImageSharp/Processing/Transforms/Lanczos2Resampler.cs index 29568db021..c78926ed23 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs +++ b/src/ImageSharp/Processing/Transforms/Lanczos2Resampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The function implements the Lanczos kernel algorithm as described on @@ -29,4 +29,4 @@ namespace SixLabors.ImageSharp.Processing return 0F; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs b/src/ImageSharp/Processing/Transforms/Lanczos3Resampler.cs similarity index 93% rename from src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs rename to src/ImageSharp/Processing/Transforms/Lanczos3Resampler.cs index 492ef69e4c..b6d08fc530 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs +++ b/src/ImageSharp/Processing/Transforms/Lanczos3Resampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The function implements the Lanczos kernel algorithm as described on @@ -29,4 +29,4 @@ namespace SixLabors.ImageSharp.Processing return 0F; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs b/src/ImageSharp/Processing/Transforms/Lanczos5Resampler.cs similarity index 93% rename from src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs rename to src/ImageSharp/Processing/Transforms/Lanczos5Resampler.cs index cae152a53c..b8055f6ce9 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs +++ b/src/ImageSharp/Processing/Transforms/Lanczos5Resampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The function implements the Lanczos kernel algorithm as described on @@ -29,4 +29,4 @@ namespace SixLabors.ImageSharp.Processing return 0F; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs b/src/ImageSharp/Processing/Transforms/Lanczos8Resampler.cs similarity index 93% rename from src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs rename to src/ImageSharp/Processing/Transforms/Lanczos8Resampler.cs index b390c55419..39afe11bbf 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs +++ b/src/ImageSharp/Processing/Transforms/Lanczos8Resampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The function implements the Lanczos kernel algorithm as described on @@ -29,4 +29,4 @@ namespace SixLabors.ImageSharp.Processing return 0F; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/MitchellNetravaliResampler.cs b/src/ImageSharp/Processing/Transforms/MitchellNetravaliResampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Resamplers/MitchellNetravaliResampler.cs rename to src/ImageSharp/Processing/Transforms/MitchellNetravaliResampler.cs index df351d9505..0b1685e110 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/MitchellNetravaliResampler.cs +++ b/src/ImageSharp/Processing/Transforms/MitchellNetravaliResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The function implements the mitchell algorithm as described on @@ -21,4 +21,4 @@ namespace SixLabors.ImageSharp.Processing return ImageMaths.GetBcValue(x, B, C); } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/NearestNeighborResampler.cs b/src/ImageSharp/Processing/Transforms/NearestNeighborResampler.cs similarity index 90% rename from src/ImageSharp/Processing/Transforms/Resamplers/NearestNeighborResampler.cs rename to src/ImageSharp/Processing/Transforms/NearestNeighborResampler.cs index 7a7785be36..c0f019a88d 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/NearestNeighborResampler.cs +++ b/src/ImageSharp/Processing/Transforms/NearestNeighborResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The function implements the nearest neighbor algorithm. This uses an unscaled filter @@ -18,4 +18,4 @@ namespace SixLabors.ImageSharp.Processing return x; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Options/Orientation.cs b/src/ImageSharp/Processing/Transforms/OrientationType.cs similarity index 93% rename from src/ImageSharp/Processing/Transforms/Options/Orientation.cs rename to src/ImageSharp/Processing/Transforms/OrientationType.cs index 9c8d96a71c..752ac9fe68 100644 --- a/src/ImageSharp/Processing/Transforms/Options/Orientation.cs +++ b/src/ImageSharp/Processing/Transforms/OrientationType.cs @@ -1,12 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// Enumerates the available orientation values supplied by EXIF metadata. /// - internal enum Orientation : ushort + internal enum OrientationType : ushort { /// /// Unknown rotation. diff --git a/src/ImageSharp/Processing/Transforms/Pad.cs b/src/ImageSharp/Processing/Transforms/PadExtensions.cs similarity index 80% rename from src/ImageSharp/Processing/Transforms/Pad.cs rename to src/ImageSharp/Processing/Transforms/PadExtensions.cs index 1c990f82ea..7d26cba620 100644 --- a/src/ImageSharp/Processing/Transforms/Pad.cs +++ b/src/ImageSharp/Processing/Transforms/PadExtensions.cs @@ -2,15 +2,14 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Transforms { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of padding operations to the type. /// - public static partial class ImageExtensions + public static class PadExtensions { /// /// Evenly pads an image to fit the new dimensions. @@ -30,7 +29,7 @@ namespace SixLabors.ImageSharp Sampler = Resamplers.NearestNeighbor }; - return Resize(source, options); + return source.Resize(options); } } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs index 864001d075..3846379cd7 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs @@ -12,7 +12,7 @@ using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Transforms.Processors { /// /// Provides the base methods to perform affine transforms on an image. @@ -208,8 +208,6 @@ namespace SixLabors.ImageSharp.Processing.Processors /// The . /// protected virtual Matrix3x2 GetProcessingMatrix(Rectangle sourceRectangle, Rectangle destinationRectangle) - { - return this.TransformMatrix; - } + => this.TransformMatrix; } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Processors/AutoOrientProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/AutoOrientProcessor.cs index c118a7e866..a0a5bfa770 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/AutoOrientProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/AutoOrientProcessor.cs @@ -6,7 +6,7 @@ using SixLabors.ImageSharp.MetaData.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Transforms.Processors { /// /// Adjusts an image so that its orientation is suitable for viewing. Adjustments are based on EXIF metadata embedded in the image. @@ -18,42 +18,42 @@ namespace SixLabors.ImageSharp.Processing.Processors /// protected override void BeforeImageApply(Image source, Rectangle sourceRectangle) { - Orientation orientation = GetExifOrientation(source); + OrientationType orientation = GetExifOrientation(source); Size size = sourceRectangle.Size; switch (orientation) { - case Orientation.TopRight: + case OrientationType.TopRight: new FlipProcessor(FlipType.Horizontal).Apply(source, sourceRectangle); break; - case Orientation.BottomRight: + case OrientationType.BottomRight: new RotateProcessor((int)RotateType.Rotate180, size).Apply(source, sourceRectangle); break; - case Orientation.BottomLeft: + case OrientationType.BottomLeft: new FlipProcessor(FlipType.Vertical).Apply(source, sourceRectangle); break; - case Orientation.LeftTop: + case OrientationType.LeftTop: new RotateProcessor((int)RotateType.Rotate90, size).Apply(source, sourceRectangle); new FlipProcessor(FlipType.Horizontal).Apply(source, sourceRectangle); break; - case Orientation.RightTop: + case OrientationType.RightTop: new RotateProcessor((int)RotateType.Rotate90, size).Apply(source, sourceRectangle); break; - case Orientation.RightBottom: + case OrientationType.RightBottom: new FlipProcessor(FlipType.Vertical).Apply(source, sourceRectangle); new RotateProcessor((int)RotateType.Rotate270, size).Apply(source, sourceRectangle); break; - case Orientation.LeftBottom: + case OrientationType.LeftBottom: new RotateProcessor((int)RotateType.Rotate270, size).Apply(source, sourceRectangle); break; - case Orientation.Unknown: - case Orientation.TopLeft: + case OrientationType.Unknown: + case OrientationType.TopLeft: default: break; } @@ -62,39 +62,39 @@ namespace SixLabors.ImageSharp.Processing.Processors /// protected override void OnFrameApply(ImageFrame sourceBase, Rectangle sourceRectangle, Configuration config) { - // all processing happens at the image level within BeforeImageApply(); + // All processing happens at the image level within BeforeImageApply(); } /// /// Returns the current EXIF orientation /// /// The image to auto rotate. - /// The - private static Orientation GetExifOrientation(Image source) + /// The + private static OrientationType GetExifOrientation(Image source) { if (source.MetaData.ExifProfile == null) { - return Orientation.Unknown; + return OrientationType.Unknown; } ExifValue value = source.MetaData.ExifProfile.GetValue(ExifTag.Orientation); if (value == null) { - return Orientation.Unknown; + return OrientationType.Unknown; } - Orientation orientation; + OrientationType orientation; if (value.DataType == ExifDataType.Short) { - orientation = (Orientation)value.Value; + orientation = (OrientationType)value.Value; } else { - orientation = (Orientation)Convert.ToUInt16(value.Value); + orientation = (OrientationType)Convert.ToUInt16(value.Value); source.MetaData.ExifProfile.RemoveValue(ExifTag.Orientation); } - source.MetaData.ExifProfile.SetValue(ExifTag.Orientation, (ushort)Orientation.TopLeft); + source.MetaData.ExifProfile.SetValue(ExifTag.Orientation, (ushort)OrientationType.TopLeft); return orientation; } diff --git a/src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs index 6b8314d172..b9a4a6a76a 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs @@ -5,7 +5,7 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Transforms.Processors { /// /// A base class that provides methods to allow the automatic centering of affine transforms @@ -27,9 +27,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// protected override Matrix3x2 GetProcessingMatrix(Rectangle sourceRectangle, Rectangle destinationRectangle) - { - return TransformHelpers.GetCenteredTransformMatrix(sourceRectangle, destinationRectangle, this.TransformMatrix); - } + => TransformHelpers.GetCenteredTransformMatrix(sourceRectangle, destinationRectangle, this.TransformMatrix); private static Size GetTransformedDimensions(Size sourceDimensions, Matrix3x2 matrix) { diff --git a/src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs index 081ea84610..513e6da323 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs @@ -5,7 +5,7 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Transforms.Processors { /// /// A base class that provides methods to allow the automatic centering of non-affine transforms diff --git a/src/ImageSharp/Processing/Transforms/Processors/CropProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/CropProcessor.cs index ff5011bdbe..5462b34dca 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/CropProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/CropProcessor.cs @@ -2,20 +2,21 @@ // Licensed under the Apache License, Version 2.0. using System; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -// TODO: Convert this into a cloning processor inheriting TransformProcessor once Anton's memory PR is merged -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Transforms.Processors { /// /// Provides methods to allow the cropping of an image. /// /// The pixel format. - internal class CropProcessor : ImageProcessor + internal class CropProcessor : TransformProcessorBase where TPixel : struct, IPixel { /// @@ -33,10 +34,23 @@ namespace SixLabors.ImageSharp.Processing.Processors public Rectangle CropRectangle { get; } /// - protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override Image CreateDestination(Image source, Rectangle sourceRectangle) { - if (this.CropRectangle == sourceRectangle) + // We will always be creating the clone even for mutate because we may need to resize the canvas + IEnumerable> frames = source.Frames.Select(x => new ImageFrame(source.GetMemoryManager(), this.CropRectangle.Width, this.CropRectangle.Height, x.MetaData.Clone())); + + // Use the overload to prevent an extra frame being added + return new Image(source.GetConfiguration(), source.MetaData.Clone(), frames); + } + + /// + protected override void OnFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) + { + // Handle resize dimensions identical to the original + if (source.Width == destination.Width && source.Height == destination.Height && sourceRectangle == this.CropRectangle) { + // the cloned will be blank here copy all the pixel data over + source.GetPixelSpan().CopyTo(destination.GetPixelSpan()); return; } @@ -45,25 +59,16 @@ namespace SixLabors.ImageSharp.Processing.Processors int minX = Math.Max(this.CropRectangle.X, sourceRectangle.X); int maxX = Math.Min(this.CropRectangle.Right, sourceRectangle.Right); - using (Buffer2D targetPixels = configuration.MemoryManager.Allocate2D(this.CropRectangle.Size)) - { - Parallel.For( - minY, - maxY, - configuration.ParallelOptions, - y => - { - Span sourceRow = source.GetPixelRowSpan(y).Slice(minX); - Span targetRow = targetPixels.GetRowSpan(y - minY); - SpanHelper.Copy(sourceRow, targetRow, maxX - minX); - }); - - Buffer2D.SwapContents(source.PixelBuffer, targetPixels); - } + Parallel.For( + minY, + maxY, + configuration.ParallelOptions, + y => + { + Span sourceRow = source.GetPixelRowSpan(y).Slice(minX); + Span targetRow = destination.GetPixelRowSpan(y - minY); + SpanHelper.Copy(sourceRow, targetRow, maxX - minX); + }); } - - /// - protected override void AfterImageApply(Image source, Rectangle sourceRectangle) - => TransformHelpers.UpdateDimensionalMetData(source); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Processors/EntropyCropProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/EntropyCropProcessor.cs index f263209026..668d73690d 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/EntropyCropProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/EntropyCropProcessor.cs @@ -1,22 +1,29 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; +using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Binarization.Processors; using SixLabors.ImageSharp.Processing.Convolution.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Transforms.Processors { /// - /// Provides methods to allow the cropping of an image to preserve areas of highest - /// entropy. + /// Provides methods to allow the cropping of an image to preserve areas of highest entropy. /// /// The pixel format. internal class EntropyCropProcessor : ImageProcessor where TPixel : struct, IPixel { + /// + /// Initializes a new instance of the class. + /// + public EntropyCropProcessor() + : this(.5F) + { + } + /// /// Initializes a new instance of the class. /// @@ -26,20 +33,25 @@ namespace SixLabors.ImageSharp.Processing.Processors /// public EntropyCropProcessor(float threshold) { - Guard.MustBeBetweenOrEqualTo(threshold, 0, 1, nameof(threshold)); + Guard.MustBeBetweenOrEqualTo(threshold, 0, 1F, nameof(threshold)); this.Threshold = threshold; } /// - /// Gets the threshold value. + /// Gets the entropy threshold value. /// public float Threshold { get; } /// - protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) + protected override void BeforeImageApply(Image source, Rectangle sourceRectangle) { - using (ImageFrame temp = source.Clone()) + Rectangle rectangle; + + // All frames have be the same size so we only need to calculate the correct dimensions for the first frame + using (ImageFrame temp = source.Frames.RootFrame.Clone()) { + Configuration configuration = source.GetConfiguration(); + // Detect the edges. new SobelProcessor(false).Apply(temp, sourceRectangle, configuration); @@ -47,15 +59,16 @@ namespace SixLabors.ImageSharp.Processing.Processors new BinaryThresholdProcessor(this.Threshold).Apply(temp, sourceRectangle, configuration); // Search for the first white pixels - Rectangle rectangle = ImageMaths.GetFilteredBoundingRectangle(temp, 0); + rectangle = ImageMaths.GetFilteredBoundingRectangle(temp, 0); + } - if (rectangle == sourceRectangle) - { - return; - } + new CropProcessor(rectangle).Apply(source, sourceRectangle); + } - new CropProcessor(rectangle).Apply(source, sourceRectangle, configuration); - } + /// + protected override void OnFrameApply(ImageFrame sourceBase, Rectangle sourceRectangle, Configuration config) + { + // All processing happens at the image level within BeforeImageApply(); } } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs index 6c2705979d..28c1c97946 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs @@ -9,7 +9,7 @@ using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Transforms.Processors { /// /// Provides methods that allow the flipping of an image around its center point. @@ -48,8 +48,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - /// Swaps the image at the X-axis, which goes horizontally through the middle - /// at half the height of the image. + /// Swaps the image at the X-axis, which goes horizontally through the middle at half the height of the image. /// /// The source image to apply the process to. /// The configuration. @@ -81,8 +80,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } /// - /// Swaps the image at the Y-axis, which goes vertically through the middle - /// at half of the width of the image. + /// Swaps the image at the Y-axis, which goes vertically through the middle at half of the width of the image. /// /// The source image to apply the process to. /// The configuration. diff --git a/src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs b/src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs index 27f9a1ace6..303713d6ce 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs @@ -5,7 +5,7 @@ using System; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Transforms.Processors { /// /// The base class for performing interpolated affine and non-affine transforms. @@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// /// Calculated the weights for the given point. /// This method uses more samples than the upscaled version to ensure edge pixels are correctly rendered. - /// Additionally the weights are nomalized. + /// Additionally the weights are normalized. /// /// The minimum sampling offset /// The maximum sampling offset diff --git a/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs index dc0970a6cd..a628d8a049 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs @@ -12,11 +12,11 @@ using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +// TODO: Doesn't work yet! Implement tests + Finish implementation + Document Matrix4x4 behavior +namespace SixLabors.ImageSharp.Processing.Transforms.Processors { /// /// Provides the base methods to perform non-affine transforms on an image. - /// TODO: Doesn't work yet! Implement tests + Finish implementation + Document Matrix4x4 behavior /// /// The pixel format. internal class ProjectiveTransformProcessor : InterpolatedTransformProcessorBase diff --git a/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs index dfb7b84b66..6e60be8436 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs @@ -10,9 +10,10 @@ 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.Processors +namespace SixLabors.ImageSharp.Processing.Transforms.Processors { /// /// Provides methods that allow the resizing of images using various algorithms. @@ -212,38 +213,39 @@ namespace SixLabors.ImageSharp.Processing.Processors protected override Image CreateDestination(Image source, Rectangle sourceRectangle) { // We will always be creating the clone even for mutate because we may need to resize the canvas - IEnumerable> frames = source.Frames.Select(x => new ImageFrame(source.GetMemoryManager(), this.Width, this.Height, x.MetaData.Clone())); // this will create places holders + IEnumerable> frames = source.Frames.Select(x => new ImageFrame(source.GetMemoryManager(), this.Width, this.Height, x.MetaData.Clone())); // Use the overload to prevent an extra frame being added return new Image(source.GetConfiguration(), source.MetaData.Clone(), frames); } /// - protected override void BeforeFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) + protected override void BeforeImageApply(Image source, Image destination, Rectangle sourceRectangle) { if (!(this.Sampler is NearestNeighborResampler)) { - // TODO: Optimization opportunity: if we could assume that all frames are of the same size, we can move this into 'BeforeImageApply()` + // Since all image frame dimensions have to be the same we can calculate this for all frames. + MemoryManager memoryManager = source.GetMemoryManager(); this.horizontalWeights = this.PrecomputeWeights( - source.MemoryManager, + memoryManager, this.ResizeRectangle.Width, sourceRectangle.Width); this.verticalWeights = this.PrecomputeWeights( - source.MemoryManager, + memoryManager, this.ResizeRectangle.Height, sourceRectangle.Height); } } /// - protected override void OnFrameApply(ImageFrame source, ImageFrame cloned, Rectangle sourceRectangle, Configuration configuration) + protected override void OnFrameApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration) { - // Jump out, we'll deal with that later. - if (source.Width == cloned.Width && source.Height == cloned.Height && sourceRectangle == this.ResizeRectangle) + // Handle resize dimensions identical to the original + if (source.Width == destination.Width && source.Height == destination.Height && sourceRectangle == this.ResizeRectangle) { // the cloned will be blank here copy all the pixel data over - source.GetPixelSpan().CopyTo(cloned.GetPixelSpan()); + source.GetPixelSpan().CopyTo(destination.GetPixelSpan()); return; } @@ -275,7 +277,7 @@ namespace SixLabors.ImageSharp.Processing.Processors { // Y coordinates of source points Span sourceRow = source.GetPixelRowSpan((int)(((y - startY) * heightFactor) + sourceY)); - Span targetRow = cloned.GetPixelRowSpan(y); + Span targetRow = destination.GetPixelRowSpan(y); for (int x = minX; x < maxX; x++) { @@ -336,18 +338,18 @@ namespace SixLabors.ImageSharp.Processing.Processors { // Ensure offsets are normalized for cropping and padding. WeightsWindow window = this.verticalWeights.Weights[y - startY]; - Span targetRow = cloned.GetPixelRowSpan(y); + Span targetRow = destination.GetPixelRowSpan(y); if (this.Compand) { for (int x = 0; x < width; x++) { // Destination color components - Vector4 destination = window.ComputeWeightedColumnSum(firstPassPixels, x, sourceY); - destination = destination.Compress(); + Vector4 destinationVector = window.ComputeWeightedColumnSum(firstPassPixels, x, sourceY); + destinationVector = destinationVector.Compress(); ref TPixel pixel = ref targetRow[x]; - pixel.PackFromVector4(destination); + pixel.PackFromVector4(destinationVector); } } else @@ -355,10 +357,10 @@ namespace SixLabors.ImageSharp.Processing.Processors for (int x = 0; x < width; x++) { // Destination color components - Vector4 destination = window.ComputeWeightedColumnSum(firstPassPixels, x, sourceY); + Vector4 destinationVector = window.ComputeWeightedColumnSum(firstPassPixels, x, sourceY); ref TPixel pixel = ref targetRow[x]; - pixel.PackFromVector4(destination); + pixel.PackFromVector4(destinationVector); } } }); diff --git a/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs index fabae88fd4..9a069f1b6b 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs @@ -3,13 +3,14 @@ using System; using System.Threading.Tasks; + using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.MetaData.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Transforms.Processors { /// /// Provides methods that allow the rotating of images. diff --git a/src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs index ad0aad7bbb..5bb594f2fe 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs @@ -4,7 +4,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Transforms.Processors { /// /// Provides methods that allow the skewing of images. diff --git a/src/ImageSharp/Processing/Transforms/Processors/TransformProcessorBase.cs b/src/ImageSharp/Processing/Transforms/Processors/TransformProcessorBase.cs index 7403a400e7..0ca5ee1911 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/TransformProcessorBase.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/TransformProcessorBase.cs @@ -2,9 +2,10 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Processors +namespace SixLabors.ImageSharp.Processing.Transforms.Processors { /// /// The base class for all transform processors. Any processor that changes the dimensions of the image should inherit from this. diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/Resamplers.cs b/src/ImageSharp/Processing/Transforms/Resamplers.cs similarity index 98% rename from src/ImageSharp/Processing/Transforms/Resamplers/Resamplers.cs rename to src/ImageSharp/Processing/Transforms/Resamplers.cs index 599ae2dadb..791d493d9e 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/Resamplers.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// Contains reusable static instances of known resampling algorithms diff --git a/src/ImageSharp/Processing/Transforms/Resize.cs b/src/ImageSharp/Processing/Transforms/ResizeExtensions.cs similarity index 88% rename from src/ImageSharp/Processing/Transforms/Resize.cs rename to src/ImageSharp/Processing/Transforms/ResizeExtensions.cs index b94addb27b..1580aa6366 100644 --- a/src/ImageSharp/Processing/Transforms/Resize.cs +++ b/src/ImageSharp/Processing/Transforms/ResizeExtensions.cs @@ -2,16 +2,15 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Transforms { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of resize operations to the type. /// - public static partial class ImageExtensions + public static class ResizeExtensions { /// /// Resizes an image in accordance with the given . @@ -23,7 +22,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width within the resize options will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, ResizeOptions options) where TPixel : struct, IPixel - => source.ApplyProcessor(new ResizeProcessor(options, source.GetCurrentSize())); + => source.ApplyProcessor(new ResizeProcessor(options, source.GetCurrentSize())); /// /// Resizes an image to the given . @@ -35,7 +34,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, Size size) where TPixel : struct, IPixel - => Resize(source, size.Width, size.Height, Resamplers.Bicubic, false); + => Resize(source, size.Width, size.Height, Resamplers.Bicubic, false); /// /// Resizes an image to the given . @@ -48,7 +47,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, Size size, bool compand) where TPixel : struct, IPixel - => Resize(source, size.Width, size.Height, Resamplers.Bicubic, compand); + => Resize(source, size.Width, size.Height, Resamplers.Bicubic, compand); /// /// Resizes an image to the given width and height. @@ -61,7 +60,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, int width, int height) where TPixel : struct, IPixel - => Resize(source, width, height, Resamplers.Bicubic, false); + => Resize(source, width, height, Resamplers.Bicubic, false); /// /// Resizes an image to the given width and height. @@ -75,7 +74,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, int width, int height, bool compand) where TPixel : struct, IPixel - => Resize(source, width, height, Resamplers.Bicubic, compand); + => Resize(source, width, height, Resamplers.Bicubic, compand); /// /// Resizes an image to the given width and height with the given sampler. @@ -89,7 +88,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, int width, int height, IResampler sampler) where TPixel : struct, IPixel - => Resize(source, width, height, sampler, false); + => Resize(source, width, height, sampler, false); /// /// Resizes an image to the given width and height with the given sampler. @@ -103,7 +102,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, Size size, IResampler sampler, bool compand) where TPixel : struct, IPixel - => Resize(source, size.Width, size.Height, sampler, new Rectangle(0, 0, size.Width, size.Height), compand); + => Resize(source, size.Width, size.Height, sampler, new Rectangle(0, 0, size.Width, size.Height), compand); /// /// Resizes an image to the given width and height with the given sampler. @@ -118,7 +117,7 @@ namespace SixLabors.ImageSharp /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, int width, int height, IResampler sampler, bool compand) where TPixel : struct, IPixel - => Resize(source, width, height, sampler, new Rectangle(0, 0, width, height), compand); + => Resize(source, width, height, sampler, new Rectangle(0, 0, width, height), compand); /// /// Resizes an image to the given width and height with the given sampler and @@ -147,7 +146,7 @@ namespace SixLabors.ImageSharp Rectangle targetRectangle, bool compand) where TPixel : struct, IPixel - => source.ApplyProcessor(new ResizeProcessor(sampler, width, height, source.GetCurrentSize(), targetRectangle, compand), sourceRectangle); + => source.ApplyProcessor(new ResizeProcessor(sampler, width, height, source.GetCurrentSize(), targetRectangle, compand), sourceRectangle); /// /// Resizes an image to the given width and height with the given sampler and source rectangle. @@ -171,6 +170,6 @@ namespace SixLabors.ImageSharp Rectangle targetRectangle, bool compand) where TPixel : struct, IPixel - => source.ApplyProcessor(new ResizeProcessor(sampler, width, height, source.GetCurrentSize(), targetRectangle, compand)); + => source.ApplyProcessor(new ResizeProcessor(sampler, width, height, source.GetCurrentSize(), targetRectangle, compand)); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs b/src/ImageSharp/Processing/Transforms/ResizeHelper.cs similarity index 99% rename from src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs rename to src/ImageSharp/Processing/Transforms/ResizeHelper.cs index ba6f4509d8..0d500b1bce 100644 --- a/src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs +++ b/src/ImageSharp/Processing/Transforms/ResizeHelper.cs @@ -5,7 +5,7 @@ using System; using System.Linq; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// Provides methods to help calculate the target rectangle when resizing using the diff --git a/src/ImageSharp/Processing/Transforms/Options/ResizeMode.cs b/src/ImageSharp/Processing/Transforms/ResizeMode.cs similarity index 96% rename from src/ImageSharp/Processing/Transforms/Options/ResizeMode.cs rename to src/ImageSharp/Processing/Transforms/ResizeMode.cs index c88808f758..248ac20f4e 100644 --- a/src/ImageSharp/Processing/Transforms/Options/ResizeMode.cs +++ b/src/ImageSharp/Processing/Transforms/ResizeMode.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// Enumerated resize modes to apply to resized images. diff --git a/src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs b/src/ImageSharp/Processing/Transforms/ResizeOptions.cs similarity index 96% rename from src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs rename to src/ImageSharp/Processing/Transforms/ResizeOptions.cs index 03adf58c34..afa3142e51 100644 --- a/src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs +++ b/src/ImageSharp/Processing/Transforms/ResizeOptions.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Linq; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The resize options for resizing images against certain modes. @@ -43,4 +43,4 @@ namespace SixLabors.ImageSharp.Processing /// public bool Compand { get; set; } = false; } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/RobidouxResampler.cs b/src/ImageSharp/Processing/Transforms/RobidouxResampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Resamplers/RobidouxResampler.cs rename to src/ImageSharp/Processing/Transforms/RobidouxResampler.cs index bd28d8da46..829e1ee9bd 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/RobidouxResampler.cs +++ b/src/ImageSharp/Processing/Transforms/RobidouxResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The function implements the Robidoux algorithm. @@ -21,4 +21,4 @@ namespace SixLabors.ImageSharp.Processing return ImageMaths.GetBcValue(x, B, C); } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/RobidouxSharpResampler.cs b/src/ImageSharp/Processing/Transforms/RobidouxSharpResampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Resamplers/RobidouxSharpResampler.cs rename to src/ImageSharp/Processing/Transforms/RobidouxSharpResampler.cs index a345da3f42..4cbf13f58c 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/RobidouxSharpResampler.cs +++ b/src/ImageSharp/Processing/Transforms/RobidouxSharpResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The function implements the Robidoux Sharp algorithm. @@ -21,4 +21,4 @@ namespace SixLabors.ImageSharp.Processing return ImageMaths.GetBcValue(x, B, C); } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Rotate.cs b/src/ImageSharp/Processing/Transforms/RotateExtensions.cs similarity index 80% rename from src/ImageSharp/Processing/Transforms/Rotate.cs rename to src/ImageSharp/Processing/Transforms/RotateExtensions.cs index bbaa762a22..9001bc3ff5 100644 --- a/src/ImageSharp/Processing/Transforms/Rotate.cs +++ b/src/ImageSharp/Processing/Transforms/RotateExtensions.cs @@ -2,15 +2,14 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Processors; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Transforms { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of rotate operations to the type. /// - public static partial class ImageExtensions + public static class RotateExtensions { /// /// Rotates and flips an image by the given instructions. @@ -21,7 +20,7 @@ namespace SixLabors.ImageSharp /// The public static IImageProcessingContext Rotate(this IImageProcessingContext source, RotateType rotateType) where TPixel : struct, IPixel - => Rotate(source, (float)rotateType); + => Rotate(source, (float)rotateType); /// /// Rotates an image by the given angle in degrees. @@ -32,7 +31,7 @@ namespace SixLabors.ImageSharp /// The public static IImageProcessingContext Rotate(this IImageProcessingContext source, float degrees) where TPixel : struct, IPixel - => Rotate(source, degrees, Resamplers.Bicubic); + => Rotate(source, degrees, Resamplers.Bicubic); /// /// Rotates an image by the given angle in degrees using the specified sampling algorithm. @@ -44,6 +43,6 @@ namespace SixLabors.ImageSharp /// The public static IImageProcessingContext Rotate(this IImageProcessingContext source, float degrees, IResampler sampler) where TPixel : struct, IPixel - => source.ApplyProcessor(new RotateProcessor(degrees, sampler, source.GetCurrentSize())); + => source.ApplyProcessor(new RotateProcessor(degrees, sampler, source.GetCurrentSize())); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/RotateFlip.cs b/src/ImageSharp/Processing/Transforms/RotateFlipExtensions.cs similarity index 76% rename from src/ImageSharp/Processing/Transforms/RotateFlip.cs rename to src/ImageSharp/Processing/Transforms/RotateFlipExtensions.cs index 2ddcb151b2..693c0d8ad7 100644 --- a/src/ImageSharp/Processing/Transforms/RotateFlip.cs +++ b/src/ImageSharp/Processing/Transforms/RotateFlipExtensions.cs @@ -1,16 +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; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Transforms { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of rotate-flip operations to the type. /// - public static partial class ImageExtensions + public static class RotateFlipExtensions { /// /// Rotates and flips an image by the given instructions. @@ -22,8 +20,6 @@ namespace SixLabors.ImageSharp /// The public static IImageProcessingContext RotateFlip(this IImageProcessingContext source, RotateType rotateType, FlipType flipType) where TPixel : struct, IPixel - { - return source.Rotate(rotateType).Flip(flipType); - } + => source.Rotate(rotateType).Flip(flipType); } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Options/RotateType.cs b/src/ImageSharp/Processing/Transforms/RotateType.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Options/RotateType.cs rename to src/ImageSharp/Processing/Transforms/RotateType.cs index 9f6d45f2bf..498ad4149a 100644 --- a/src/ImageSharp/Processing/Transforms/Options/RotateType.cs +++ b/src/ImageSharp/Processing/Transforms/RotateType.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// Provides enumeration over how the image should be rotated. @@ -28,4 +28,4 @@ namespace SixLabors.ImageSharp.Processing /// Rotate270 = 270 } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Skew.cs b/src/ImageSharp/Processing/Transforms/SkewExtensions.cs similarity index 79% rename from src/ImageSharp/Processing/Transforms/Skew.cs rename to src/ImageSharp/Processing/Transforms/SkewExtensions.cs index f4a92e0100..c80619aa9a 100644 --- a/src/ImageSharp/Processing/Transforms/Skew.cs +++ b/src/ImageSharp/Processing/Transforms/SkewExtensions.cs @@ -2,15 +2,14 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Processors; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Transforms { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of skew operations to the type. /// - public static partial class ImageExtensions + public static class SkewExtensions { /// /// Skews an image by the given angles in degrees. @@ -22,7 +21,7 @@ namespace SixLabors.ImageSharp /// The public static IImageProcessingContext Skew(this IImageProcessingContext source, float degreesX, float degreesY) where TPixel : struct, IPixel - => Skew(source, degreesX, degreesY, Resamplers.Bicubic); + => Skew(source, degreesX, degreesY, Resamplers.Bicubic); /// /// Skews an image by the given angles in degrees using the specified sampling algorithm. @@ -35,6 +34,6 @@ namespace SixLabors.ImageSharp /// The public static IImageProcessingContext Skew(this IImageProcessingContext source, float degreesX, float degreesY, IResampler sampler) where TPixel : struct, IPixel - => source.ApplyProcessor(new SkewProcessor(degreesX, degreesY, sampler, source.GetCurrentSize())); + => source.ApplyProcessor(new SkewProcessor(degreesX, degreesY, sampler, source.GetCurrentSize())); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/SplineResampler.cs b/src/ImageSharp/Processing/Transforms/SplineResampler.cs similarity index 91% rename from src/ImageSharp/Processing/Transforms/Resamplers/SplineResampler.cs rename to src/ImageSharp/Processing/Transforms/SplineResampler.cs index ac5e2dedba..3448d5fb8c 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/SplineResampler.cs +++ b/src/ImageSharp/Processing/Transforms/SplineResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The function implements the spline algorithm. @@ -21,4 +21,4 @@ namespace SixLabors.ImageSharp.Processing return ImageMaths.GetBcValue(x, B, C); } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Transform.cs b/src/ImageSharp/Processing/Transforms/TransformExtensions.cs similarity index 94% rename from src/ImageSharp/Processing/Transforms/Transform.cs rename to src/ImageSharp/Processing/Transforms/TransformExtensions.cs index b82713ca94..7bd37afeff 100644 --- a/src/ImageSharp/Processing/Transforms/Transform.cs +++ b/src/ImageSharp/Processing/Transforms/TransformExtensions.cs @@ -3,16 +3,15 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Transforms { /// - /// Extension methods for the type. + /// Adds extensions that allow the application of composable transform operations to the type. /// - public static partial class ImageExtensions + public static class TransformExtensions { /// /// Transforms an image by the given matrix. @@ -77,9 +76,7 @@ namespace SixLabors.ImageSharp IResampler sampler, Size destinationSize) where TPixel : struct, IPixel - { - return source.ApplyProcessor(new AffineTransformProcessor(matrix, sampler, destinationSize)); - } + => source.ApplyProcessor(new AffineTransformProcessor(matrix, sampler, destinationSize)); /// /// Transforms an image by the given matrix. diff --git a/src/ImageSharp/Processing/Transforms/TransformHelpers.cs b/src/ImageSharp/Processing/Transforms/TransformHelpers.cs index 1567c11619..46dd134cec 100644 --- a/src/ImageSharp/Processing/Transforms/TransformHelpers.cs +++ b/src/ImageSharp/Processing/Transforms/TransformHelpers.cs @@ -7,7 +7,7 @@ using SixLabors.ImageSharp.MetaData.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// Contains helper methods for working with affine and non-affine transforms diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/TriangleResampler.cs b/src/ImageSharp/Processing/Transforms/TriangleResampler.cs similarity index 93% rename from src/ImageSharp/Processing/Transforms/Resamplers/TriangleResampler.cs rename to src/ImageSharp/Processing/Transforms/TriangleResampler.cs index 842da87e06..2f5783e207 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/TriangleResampler.cs +++ b/src/ImageSharp/Processing/Transforms/TriangleResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The function implements the triangle (bilinear) algorithm. @@ -29,4 +29,4 @@ namespace SixLabors.ImageSharp.Processing return 0F; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs b/src/ImageSharp/Processing/Transforms/WelchResampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs rename to src/ImageSharp/Processing/Transforms/WelchResampler.cs index 9e18a24710..de60f9f247 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs +++ b/src/ImageSharp/Processing/Transforms/WelchResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing +namespace SixLabors.ImageSharp.Processing.Transforms { /// /// The function implements the welch algorithm. diff --git a/tests/ImageSharp.Benchmarks/Samplers/Crop.cs b/tests/ImageSharp.Benchmarks/Samplers/Crop.cs index 17c3933c08..166cf77fe2 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Crop.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Crop.cs @@ -9,9 +9,8 @@ namespace SixLabors.ImageSharp.Benchmarks using System.Drawing.Drawing2D; using BenchmarkDotNet.Attributes; - - using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Transforms; using CoreSize = SixLabors.Primitives.Size; diff --git a/tests/ImageSharp.Benchmarks/Samplers/Resize.cs b/tests/ImageSharp.Benchmarks/Samplers/Resize.cs index 8bba227c5b..0a47306860 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Resize.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Resize.cs @@ -12,6 +12,7 @@ namespace SixLabors.ImageSharp.Benchmarks using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Transforms; using CoreSize = SixLabors.Primitives.Size; diff --git a/tests/ImageSharp.Tests/ComplexIntegrationTests.cs b/tests/ImageSharp.Tests/ComplexIntegrationTests.cs index ad4676872f..86703959aa 100644 --- a/tests/ImageSharp.Tests/ComplexIntegrationTests.cs +++ b/tests/ImageSharp.Tests/ComplexIntegrationTests.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Transforms; using SixLabors.Primitives; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs index c49ba05eef..177891b94a 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs @@ -11,6 +11,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests { + using SixLabors.ImageSharp.Processing.Transforms; + public class DrawImageTest : FileTestBase { private const PixelTypes PixelTypes = Tests.PixelTypes.Rgba32; diff --git a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs index bd06e1f1f5..da2589ed54 100644 --- a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs @@ -13,6 +13,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Transforms; public class FillPatternBrushTests : FileTestBase { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs index 660f01dff4..e7fd21d963 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs @@ -11,6 +11,7 @@ using SixLabors.ImageSharp.Formats.Png; namespace SixLabors.ImageSharp.Tests.Formats.Png { using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Transforms; public class PngSmokeTests { diff --git a/tests/ImageSharp.Tests/Image/ImageProcessingContextTests.cs b/tests/ImageSharp.Tests/Image/ImageProcessingContextTests.cs index e226e1ce8e..b60fc5ff20 100644 --- a/tests/ImageSharp.Tests/Image/ImageProcessingContextTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageProcessingContextTests.cs @@ -8,6 +8,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests { using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Transforms; public class ImageProcessingContextTests { diff --git a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs index 59677ac784..a18b8326ab 100644 --- a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs @@ -8,6 +8,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests { using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Transforms; public class ImageRotationTests { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs index 161ac15e33..fb1a7f0a38 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs @@ -9,6 +9,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { + using SixLabors.ImageSharp.Processing.Transforms; + public class AutoOrientTests : FileTestBase { public static readonly string[] FlipFiles = { TestImages.Bmp.F }; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs index 69515b2cbd..e9fd50b7fa 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs @@ -7,6 +7,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Transforms; public class CropTest : FileTestBase { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs index 27502df30d..da3ba6be69 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs @@ -7,6 +7,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Transforms; public class EntropyCropTest : FileTestBase { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs index 9ca3994986..7a4743e449 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { + using SixLabors.ImageSharp.Processing.Transforms; + public class FlipTests : FileTestBase { public static readonly string[] FlipFiles = { TestImages.Bmp.F }; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs index f83a08bae1..3294ecc733 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs @@ -7,6 +7,7 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Transforms; public class PadTest : FileTestBase { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs index 3920aff8aa..84030adf16 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs @@ -12,6 +12,9 @@ using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { + using SixLabors.ImageSharp.Processing.Transforms; + using SixLabors.ImageSharp.Processing.Transforms.Processors; + public class ResizeProfilingBenchmarks : MeasureFixture { public ResizeProfilingBenchmarks(ITestOutputHelper output) diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs index e2ae50aff0..38201d4d6f 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -13,6 +13,8 @@ using Xunit; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { + using SixLabors.ImageSharp.Processing.Transforms; + public class ResizeTests : FileTestBase { public static readonly string[] CommonTestImages = { TestImages.Png.CalliphoraPartial }; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs index e7415e1619..f15ed3cc7e 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { + using SixLabors.ImageSharp.Processing.Transforms; + public class RotateFlipTests : FileTestBase { public static readonly string[] FlipFiles = { TestImages.Bmp.F }; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs index b5220ea948..54e2a4a185 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs @@ -11,6 +11,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms using System; using System.Reflection; + using SixLabors.ImageSharp.Processing.Transforms; + public class RotateTests : FileTestBase { public static readonly TheoryData RotateAngles diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs index e8c5763d5e..c092881c62 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms using System.Reflection; using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Transforms; public class SkewTest : FileTestBase { diff --git a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs index e0797c4da9..85c35ba275 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs @@ -11,6 +11,8 @@ using SixLabors.ImageSharp.Helpers; namespace SixLabors.ImageSharp.Tests.Processing.Transforms { + using SixLabors.ImageSharp.Processing.Transforms; + public class AffineTransformTests { private readonly ITestOutputHelper Output; @@ -236,7 +238,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms private static void VerifyAllPixelsAreWhiteOrTransparent(Image image) where TPixel : struct, IPixel { - TPixel[] data = new TPixel[image.Width * image.Height]; + var data = new TPixel[image.Width * image.Height]; image.Frames.RootFrame.SavePixelData(data); var rgba = default(Rgba32); var white = new Rgb24(255, 255, 255); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/AutoOrientTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/AutoOrientTests.cs index 20de25054c..92d4f030ba 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/AutoOrientTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/AutoOrientTests.cs @@ -1,11 +1,13 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Processing.Processors; using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Transforms { + using SixLabors.ImageSharp.Processing.Transforms; + using SixLabors.ImageSharp.Processing.Transforms.Processors; + public class AutoOrientTests : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs index a001efc417..2cc0484de9 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs @@ -1,9 +1,8 @@ // 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.Transforms; +using SixLabors.ImageSharp.Processing.Transforms.Processors; using SixLabors.Primitives; using Xunit; @@ -14,10 +13,10 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms [Theory] [InlineData(10, 10)] [InlineData(12, 123)] - public void Crop_Width_height_CropProcessorWithRectangleSet(int width, int height) + public void CropWidthHeightCropProcessorWithRectangleSet(int width, int height) { this.operations.Crop(width, height); - var processor = this.Verify>(); + CropProcessor processor = this.Verify>(); Assert.Equal(new Rectangle(0, 0, width, height), processor.CropRectangle); } @@ -25,13 +24,13 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms [Theory] [InlineData(10, 10, 2, 6)] [InlineData(12, 123, 6, 2)] - public void Crop_Rectangle_CropProcessorWithRectangleSet(int x, int y, int width, int height) + public void CropRectangleCropProcessorWithRectangleSet(int x, int y, int width, int height) { - var rect = new Rectangle(x, y, width, height); - this.operations.Crop(rect); - var processor = this.Verify>(); + var cropRectangle = new Rectangle(x, y, width, height); + this.operations.Crop(cropRectangle); + CropProcessor processor = this.Verify>(); - Assert.Equal(rect, processor.CropRectangle); + Assert.Equal(cropRectangle, processor.CropRectangle); } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Processing/Transforms/EntropyCropTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/EntropyCropTest.cs index c1cde48794..8ddb760791 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/EntropyCropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/EntropyCropTest.cs @@ -1,25 +1,23 @@ // 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.Transforms; +using SixLabors.ImageSharp.Processing.Transforms.Processors; using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Transforms { public class EntropyCropTest : BaseImageOperationsExtensionTest { - [Theory] - [InlineData(0.5f)] - [InlineData(.2f)] - public void EntropyCrop_threasholdFloat_EntropyCropProcessorWithThreshold(float threashold) + [InlineData(0.5F)] + [InlineData(.2F)] + public void EntropyCropThresholdFloatEntropyCropProcessorWithThreshold(float threshold) { - this.operations.EntropyCrop(threashold); - var processor = this.Verify>(); + this.operations.EntropyCrop(threshold); + EntropyCropProcessor processor = this.Verify>(); - Assert.Equal(threashold, processor.Threshold); + Assert.Equal(threshold, processor.Threshold); } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Processing/Transforms/FlipTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/FlipTests.cs index 4b3e97d106..0ab9978d1b 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/FlipTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/FlipTests.cs @@ -9,6 +9,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Transforms { + using SixLabors.ImageSharp.Processing.Transforms; + using SixLabors.ImageSharp.Processing.Transforms.Processors; + public class FlipTests : BaseImageOperationsExtensionTest { @@ -19,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms public void Flip_degreesFloat_RotateProcessorWithAnglesSetAndExpandTrue(FlipType flip) { this.operations.Flip(flip); - var flipProcessor = this.Verify>(); + FlipProcessor flipProcessor = this.Verify>(); Assert.Equal(flip, flipProcessor.FlipType); } diff --git a/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs index cf4f83ca47..bb227496d8 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs @@ -8,7 +8,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Transforms { - + using SixLabors.ImageSharp.Processing.Transforms; + using SixLabors.ImageSharp.Processing.Transforms.Processors; public class PadTest : BaseImageOperationsExtensionTest { diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs index 5f3815711d..b2170069f2 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs @@ -1,14 +1,13 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Transforms; +using SixLabors.ImageSharp.Processing.Transforms.Processors; using SixLabors.Primitives; using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Transforms { - using SixLabors.ImageSharp.Processing.Processors; - public class ResizeTests : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Transforms/RotateFlipTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/RotateFlipTests.cs index 75d7067702..d1f7783104 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/RotateFlipTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/RotateFlipTests.cs @@ -1,17 +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; -using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Transforms; +using SixLabors.ImageSharp.Processing.Transforms.Processors; using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Transforms { public class RotateFlipTests : BaseImageOperationsExtensionTest { - [Theory] [InlineData(RotateType.None, FlipType.None, 0)] [InlineData(RotateType.Rotate90, FlipType.None, 90)] @@ -25,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms [InlineData(RotateType.Rotate90, FlipType.Vertical, 90)] [InlineData(RotateType.Rotate180, FlipType.Vertical, 180)] [InlineData(RotateType.Rotate270, FlipType.Vertical, 270)] - public void Rotate_degreesFloat_RotateProcessorWithAnglesSetrue(RotateType angle, FlipType flip, float expectedAngle) + public void RotateDegreesFloatRotateProcessorWithAnglesSet(RotateType angle, FlipType flip, float expectedAngle) { this.operations.RotateFlip(angle, flip); RotateProcessor rotateProcessor = this.Verify>(0); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/RotateTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/RotateTests.cs index a990fa88ca..0fbc9379a1 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/RotateTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/RotateTests.cs @@ -7,6 +7,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Transforms { + using SixLabors.ImageSharp.Processing.Transforms; + using SixLabors.ImageSharp.Processing.Transforms.Processors; + public class RotateTests : BaseImageOperationsExtensionTest { [Theory] diff --git a/tests/ImageSharp.Tests/Processing/Transforms/SkewTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/SkewTest.cs index d2cc5764ed..a4da0cf2f6 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/SkewTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/SkewTest.cs @@ -6,6 +6,9 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Transforms { + using SixLabors.ImageSharp.Processing.Transforms; + using SixLabors.ImageSharp.Processing.Transforms.Processors; + public class SkewTest : BaseImageOperationsExtensionTest { [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs index c5b6b1ad72..3e92f0e1cb 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs @@ -7,6 +7,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Transforms { + using SixLabors.ImageSharp.Processing.Transforms; + public class TransformsHelpersTest { [Fact] diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs index 8e6d60a509..1e768637e8 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs @@ -14,6 +14,7 @@ namespace SixLabors.ImageSharp.Tests using Xunit; using Xunit.Abstractions; using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Transforms; public class ImageComparerTests { From 4bc09cf794267efc732cb71be8e7625588b09120 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 9 Mar 2018 16:24:09 +1100 Subject: [PATCH 05/18] Quantizer --- src/ImageSharp.Drawing/DrawImage.cs | 1 + src/ImageSharp.Drawing/FillRegion.cs | 1 + src/ImageSharp.Drawing/Paths/DrawBeziers.cs | 1 + src/ImageSharp.Drawing/Paths/DrawLines.cs | 1 + src/ImageSharp.Drawing/Paths/DrawPath.cs | 1 + .../Paths/DrawPathCollection.cs | 1 + src/ImageSharp.Drawing/Paths/DrawPolygon.cs | 1 + src/ImageSharp.Drawing/Paths/DrawRectangle.cs | 1 + .../Paths/FillPathBuilder.cs | 1 + .../Paths/FillPathCollection.cs | 1 + src/ImageSharp.Drawing/Paths/FillPaths.cs | 1 + src/ImageSharp.Drawing/Paths/FillPolygon.cs | 1 + src/ImageSharp.Drawing/Paths/FillRectangle.cs | 1 + .../Processors/DrawImageProcessor.cs | 2 +- .../Processors/FillProcessor.cs | 7 +- .../Processors/FillRegionProcessor.cs | 9 +-- src/ImageSharp.Drawing/Text/DrawText.Path.cs | 1 + src/ImageSharp.Drawing/Text/DrawText.cs | 1 + src/ImageSharp/Configuration.cs | 5 +- src/ImageSharp/Formats/Gif/GifEncoder.cs | 5 +- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 13 ++-- .../Formats/Gif/IGifEncoderOptions.cs | 10 +-- .../Formats/Png/IPngEncoderOptions.cs | 7 +- src/ImageSharp/Formats/Png/PngEncoder.cs | 3 +- src/ImageSharp/Formats/Png/PngEncoderCore.cs | 11 ++- .../BinaryErrorDiffusionProcessor.cs | 1 + .../BinaryOrderedDitherProcessor.cs | 1 + .../Processors/BinaryThresholdProcessor.cs | 1 + .../Processors/BoxBlurProcessor.cs | 1 + .../Processors/Convolution2DProcessor.cs | 1 + .../Processors/Convolution2PassProcessor.cs | 1 + .../Processors/ConvolutionProcessor.cs | 1 + .../Processors/EdgeDetector2DProcessor.cs | 1 + .../EdgeDetectorCompassProcessor.cs | 1 + .../Processors/EdgeDetectorProcessor.cs | 1 + .../Processors/GaussianBlurProcessor.cs | 1 + .../Processors/GaussianSharpenProcessor.cs | 1 + .../Processors/IEdgeDetectorProcessor.cs | 1 + .../DefaultInternalImageProcessorContext.cs | 4 +- .../ErrorDiffusionPaletteProcessor.cs | 1 + .../OrderedDitherPaletteProcessor.cs | 1 + .../Processors/PaletteDitherProcessorBase.cs | 1 + .../Processors/OilPaintingProcessor.cs | 1 + .../Effects/Processors/PixelateProcessor.cs | 1 + .../Filters/ColorBlindnessExtensions.cs | 13 ++-- .../Processing/Filters/GrayscaleExtensions.cs | 1 + .../Filters/Processors/FilterProcessor.cs | 3 +- .../IImageProcessingContextFactory.cs | 8 +-- .../IImageProcessingContext{TPixel}.cs | 4 +- .../Processors/BackgroundColorProcessor.cs | 1 + .../Overlays/Processors/GlowProcessor.cs | 1 + .../Overlays/Processors/VignetteProcessor.cs | 1 + .../Processing/ProcessingExtensions.cs | 2 +- .../Processors}/ICloningImageProcessor.cs | 8 +-- .../Processors}/IImageProcessor.cs | 4 +- .../Processing/Processors/ImageProcessor.cs | 6 +- src/ImageSharp/Processing/Quantization/Box.cs | 2 +- .../Quantization/IQuantizer{TPixel}.cs | 6 +- .../Quantization/OctreeQuantizer{TPixel}.cs | 64 ++++++++++------- .../Quantization/PaletteQuantizer{TPixel}.cs | 5 +- .../Processors/QuantizeProcessor.cs | 72 +++++++++++++++++++ .../{Quantization.cs => QuantizationMode.cs} | 4 +- .../{Quantize.cs => QuantizeExtensions.cs} | 49 +++---------- ...e{TPixel}.cs => QuantizedFrame{TPixel}.cs} | 18 ++--- .../Quantization/QuantizerBase{TPixel}.cs | 31 +------- .../Quantization/WuQuantizer{TPixel}.cs | 27 +++---- .../Processors/AutoOrientProcessor.cs | 1 + .../Processors/EntropyCropProcessor.cs | 1 + .../Transforms/Processors/FlipProcessor.cs | 1 + .../Image/EncodeIndexedPng.cs | 3 +- .../ImageSharp.Benchmarks/Image/EncodePng.cs | 3 +- tests/ImageSharp.Benchmarks/Samplers/Glow.cs | 1 + .../FakeImageOperationsProvider.cs | 2 + .../Formats/GeneralFormatTests.cs | 7 +- .../Formats/Png/PngEncoderTests.cs | 5 +- tests/ImageSharp.Tests/ImageOperationTests.cs | 11 ++- .../Processing/Filters/ColorBlindnessTest.cs | 1 + .../Processing/Filters/GrayscaleTest.cs | 1 + .../Quantization/QuantizedImageTests.cs | 10 +-- 79 files changed, 266 insertions(+), 220 deletions(-) rename src/ImageSharp/{ => Processing}/DefaultInternalImageProcessorContext.cs (97%) rename src/ImageSharp/{ => Processing}/IImageProcessingContextFactory.cs (86%) rename src/ImageSharp/{ => Processing}/IImageProcessingContext{TPixel}.cs (96%) rename src/ImageSharp/{ => Processing/Processors}/ICloningImageProcessor.cs (83%) rename src/ImageSharp/{ => Processing/Processors}/IImageProcessor.cs (95%) create mode 100644 src/ImageSharp/Processing/Quantization/Processors/QuantizeProcessor.cs rename src/ImageSharp/Processing/Quantization/{Quantization.cs => QuantizationMode.cs} (90%) rename src/ImageSharp/Processing/Quantization/{Quantize.cs => QuantizeExtensions.cs} (53%) rename src/ImageSharp/Processing/Quantization/{QuantizedImage{TPixel}.cs => QuantizedFrame{TPixel}.cs} (73%) diff --git a/src/ImageSharp.Drawing/DrawImage.cs b/src/ImageSharp.Drawing/DrawImage.cs index f1db72db60..9ff593d3ef 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 2e5d311c6d..343225ab09 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 de4fdd003b..268a8c3c52 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 e5d9a1b3b4..397cd20e71 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 b6c821a60b..b265342a40 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 a126663b05..17d7fed414 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 771ea9e616..7615284d23 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 6b98d1f8e9..db825e2e89 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 fff082f2d9..f9846b8635 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 b252b95d5b..d8fd896782 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 f554ed7581..eb8fcc4eed 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 d8723bc31f..4e3fea9c70 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 52578de178..2f3b676298 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 46e27be78f..dcf71bde02 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 b8cbddcba0..70ac2507a3 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 66a35f1517..40db43a02a 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 274b592058..f1fbd2cec4 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 c0105011e9..cac5ae22f3 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 d41e48678b..06c588af33 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 b548098be3..ad3e85f92f 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 13ca5f2c61..bdb228f520 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 374dea6595..a709b2b9d8 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 6b4b05e311..28020f2600 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 0c40ccf2a0..2cff18410d 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 1ab7a83ce0..29c9d2a142 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 9e96ddcde6..ff2c9348e1 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 8d72ba66fa..b1fb227310 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 39d829c73a..3c29194f6e 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 b3e477f3c0..886fb5d75e 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 bbdd2f9792..ebadd28507 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 51479929f4..0a3393315b 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 eb65091fe0..ee7d93a03e 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 d853fdb8eb..c3530647ac 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 b2f78fc857..bcedd7a3cd 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 ecb6364a87..e0ca838288 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 9b3ad51b7d..6f33e23ec1 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 bb55e60c9b..5f296e29ee 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 e43aff70b8..486929e028 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 7ccc65e27e..05760bb04a 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 4e2a2cb790..e01e3ce3b3 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 213f7ca908..254c44a2ae 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 782d33b533..89cc7cfb64 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 aafc2df888..2bf35d2201 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 23f81e05e4..d45d2093fb 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 6a0caf3b45..b7dc871503 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 be5b69eed9..34ee4d0f37 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 fb094d7bd0..5267a36b43 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 b7b935ecd5..1ec2d191f3 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 0e8efde3b3..f56777bedb 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 c91cc93c2f..e0639d8ad7 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 7477c13906..22250cc185 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 bca63b314b..364eb0b794 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 97faab88f6..9d06c61d4c 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 aeb3c815ec..024ccbced1 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 c7fb565cac..d7fe0465be 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 124b345597..0d27a9e1e8 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 cd1936b653..e6e1166f88 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 82f6146a3e..f2d280477f 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 8b8db61777..5d81049371 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 cd1b4b07b1..8955e14dd4 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 0000000000..e6b1099937 --- /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 df55d3e87a..69857b3844 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 70e2814d85..2b367ffe95 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 52cf1a8d9a..ac87e1c7c5 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 84dfd8dd5c..bda0293322 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 0aadf49732..0c2371cf39 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 a0a5bfa770..fdb58918af 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 668d73690d..66b781517a 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 28c1c97946..9d945a8695 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 e5eb295449..a8368e99b8 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 53522a51f3..f81cc4d854 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 2771aa2e0f..261241a693 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 db1e7903de..294cbc0a17 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 463d5c7d80..b78a8083e2 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 d2ea982aee..7f983e1e42 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 a5d6d2eb96..5bc846c3b6 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 d1e592c736..cfe716c737 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 5195894450..ee649eaa60 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 18fd29237c..8ca04ac23c 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 From c93c3c7a7192759d01a16af6a8c8efac6bcb7ab9 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 9 Mar 2018 16:55:14 +1100 Subject: [PATCH 06/18] Complete Quantization and Dithering --- .../Binarization/BinaryDiffuseExtensions.cs | 2 +- .../Binarization/BinaryDitherExtensions.cs | 2 +- .../BinaryErrorDiffusionProcessor.cs | 2 +- .../BinaryOrderedDitherProcessor.cs | 2 +- .../{ => Processing}/Dithering/DHALF.TXT | 0 .../{ => Processing}/Dithering/DITHER.TXT | 0 .../Processing/Dithering/DiffuseExtensions.cs | 43 +++++++++++-------- .../Processing/Dithering/DitherExtensions.cs | 32 +++++++------- .../ErrorDiffusion/AtkinsonDiffuser.cs | 4 +- .../Dithering/ErrorDiffusion/BurksDiffuser.cs | 3 +- .../Dithering/ErrorDiffusion/Diffusers.cs | 2 +- .../ErrorDiffusion/ErrorDiffuserBase.cs | 2 +- .../ErrorDiffusion/FloydSteinbergDiffuser.cs | 3 +- .../ErrorDiffusion/IErrorDiffuser.cs | 2 +- .../JarvisJudiceNinkeDiffuser.cs | 3 +- .../ErrorDiffusion/Sierra2Diffuser.cs | 3 +- .../ErrorDiffusion/Sierra3Diffuser.cs | 3 +- .../ErrorDiffusion/SierraLiteDiffuser.cs | 3 +- .../ErrorDiffusion/StevensonArceDiffuser.cs | 5 +-- .../ErrorDiffusion/StuckiDiffuser.cs | 3 +- .../Dithering/Ordered/BayerDither2x2.cs | 2 +- .../Dithering/Ordered/BayerDither4x4.cs | 2 +- .../Dithering/Ordered/BayerDither8x8.cs | 2 +- .../Dithering/Ordered/Ditherers.cs | 2 +- .../Dithering/Ordered/IOrderedDither.cs | 2 +- .../Dithering/Ordered/OrderedDither.cs | 4 +- .../Dithering/Ordered/OrderedDither3x3.cs | 2 +- .../Dithering/Ordered/OrderedDitherFactory.cs | 2 +- .../ErrorDiffusionPaletteProcessor.cs | 2 +- .../OrderedDitherPaletteProcessor.cs | 2 +- .../Dithering/error_diffusion.txt | 0 .../Quantization/IQuantizer{TPixel}.cs | 2 +- .../Quantization/QuantizerBase{TPixel}.cs | 8 ++-- .../Binarization/BinaryDitherTest.cs | 5 ++- .../Binarization/OrderedDitherFactoryTests.cs | 3 +- .../Processing/Dithering/DitherTest.cs | 3 +- .../Binarization/BinaryDitherTests.cs | 17 ++++---- .../Processors/Dithering/DitherTests.cs | 25 +++++------ 38 files changed, 102 insertions(+), 102 deletions(-) rename src/ImageSharp/{ => Processing}/Dithering/DHALF.TXT (100%) rename src/ImageSharp/{ => Processing}/Dithering/DITHER.TXT (100%) rename src/ImageSharp/{ => Processing}/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs (88%) rename src/ImageSharp/{ => Processing}/Dithering/ErrorDiffusion/BurksDiffuser.cs (91%) rename src/ImageSharp/{ => Processing}/Dithering/ErrorDiffusion/Diffusers.cs (96%) rename src/ImageSharp/{ => Processing}/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs (98%) rename src/ImageSharp/{ => Processing}/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs (91%) rename src/ImageSharp/{ => Processing}/Dithering/ErrorDiffusion/IErrorDiffuser.cs (94%) rename src/ImageSharp/{ => Processing}/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs (92%) rename src/ImageSharp/{ => Processing}/Dithering/ErrorDiffusion/Sierra2Diffuser.cs (91%) rename src/ImageSharp/{ => Processing}/Dithering/ErrorDiffusion/Sierra3Diffuser.cs (91%) rename src/ImageSharp/{ => Processing}/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs (91%) rename src/ImageSharp/{ => Processing}/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs (91%) rename src/ImageSharp/{ => Processing}/Dithering/ErrorDiffusion/StuckiDiffuser.cs (91%) rename src/ImageSharp/{ => Processing}/Dithering/Ordered/BayerDither2x2.cs (88%) rename src/ImageSharp/{ => Processing}/Dithering/Ordered/BayerDither4x4.cs (88%) rename src/ImageSharp/{ => Processing}/Dithering/Ordered/BayerDither8x8.cs (88%) rename src/ImageSharp/{ => Processing}/Dithering/Ordered/Ditherers.cs (94%) rename src/ImageSharp/{ => Processing}/Dithering/Ordered/IOrderedDither.cs (95%) rename src/ImageSharp/{ => Processing}/Dithering/Ordered/OrderedDither.cs (90%) rename src/ImageSharp/{ => Processing}/Dithering/Ordered/OrderedDither3x3.cs (88%) rename src/ImageSharp/{ => Processing}/Dithering/Ordered/OrderedDitherFactory.cs (98%) rename src/ImageSharp/{ => Processing}/Dithering/error_diffusion.txt (100%) diff --git a/src/ImageSharp/Processing/Binarization/BinaryDiffuseExtensions.cs b/src/ImageSharp/Processing/Binarization/BinaryDiffuseExtensions.cs index d06a9b75be..a2859b011b 100644 --- a/src/ImageSharp/Processing/Binarization/BinaryDiffuseExtensions.cs +++ b/src/ImageSharp/Processing/Binarization/BinaryDiffuseExtensions.cs @@ -1,9 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Binarization.Processors; +using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Binarization diff --git a/src/ImageSharp/Processing/Binarization/BinaryDitherExtensions.cs b/src/ImageSharp/Processing/Binarization/BinaryDitherExtensions.cs index 039fc57b7e..e66be55de2 100644 --- a/src/ImageSharp/Processing/Binarization/BinaryDitherExtensions.cs +++ b/src/ImageSharp/Processing/Binarization/BinaryDitherExtensions.cs @@ -1,9 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Binarization.Processors; +using SixLabors.ImageSharp.Processing.Dithering.Ordered; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Binarization diff --git a/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs index ff2c9348e1..74a3fdd869 100644 --- a/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs @@ -3,9 +3,9 @@ using System; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; diff --git a/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs index b1fb227310..9f03144494 100644 --- a/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs @@ -3,9 +3,9 @@ using System; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Dithering.Ordered; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; diff --git a/src/ImageSharp/Dithering/DHALF.TXT b/src/ImageSharp/Processing/Dithering/DHALF.TXT similarity index 100% rename from src/ImageSharp/Dithering/DHALF.TXT rename to src/ImageSharp/Processing/Dithering/DHALF.TXT diff --git a/src/ImageSharp/Dithering/DITHER.TXT b/src/ImageSharp/Processing/Dithering/DITHER.TXT similarity index 100% rename from src/ImageSharp/Dithering/DITHER.TXT rename to src/ImageSharp/Processing/Dithering/DITHER.TXT diff --git a/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs b/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs index 01f138b097..a20ba01ad1 100644 --- a/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs +++ b/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs @@ -1,8 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; using SixLabors.ImageSharp.Processing.Dithering.Processors; using SixLabors.Primitives; @@ -13,6 +13,27 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// public static class DiffuseExtensions { + /// + /// Dithers the image reducing it to a web-safe palette using error diffusion. + /// + /// The pixel format. + /// The image this method extends. + /// The . + public static IImageProcessingContext Diffuse(this IImageProcessingContext source) + where TPixel : struct, IPixel + => Diffuse(source, Diffusers.FloydSteinberg, .5F); + + /// + /// Dithers the image reducing it to a web-safe palette using error diffusion. + /// + /// The pixel format. + /// The image this method extends. + /// The threshold to apply binarization of the image. Must be between 0 and 1. + /// The . + public static IImageProcessingContext Diffuse(this IImageProcessingContext source, float threshold) + where TPixel : struct, IPixel + => Diffuse(source, Diffusers.FloydSteinberg, threshold); + /// /// Dithers the image reducing it to a web-safe palette using error diffusion. /// @@ -23,10 +44,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// The . public static IImageProcessingContext Diffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold) where TPixel : struct, IPixel - { - source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold)); - return source; - } + => source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold)); /// /// Dithers the image reducing it to a web-safe palette using error diffusion. @@ -41,10 +59,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// The . public static IImageProcessingContext Diffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold), rectangle); - return source; - } + => source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold), rectangle); /// /// Dithers the image reducing it to the given palette using error diffusion. @@ -57,10 +72,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// The . public static IImageProcessingContext Diffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold, TPixel[] palette) where TPixel : struct, IPixel - { - source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold, palette)); - return source; - } + => source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold, palette)); /// /// Dithers the image reducing it to the given palette using error diffusion. @@ -76,9 +88,6 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// The . public static IImageProcessingContext Diffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold, TPixel[] palette, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold, palette), rectangle); - return source; - } + => source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold, palette), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Dithering/DitherExtensions.cs b/src/ImageSharp/Processing/Dithering/DitherExtensions.cs index f3debe8cbf..e91c450cdd 100644 --- a/src/ImageSharp/Processing/Dithering/DitherExtensions.cs +++ b/src/ImageSharp/Processing/Dithering/DitherExtensions.cs @@ -1,8 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Dithering.Ordered; using SixLabors.ImageSharp.Processing.Dithering.Processors; using SixLabors.Primitives; @@ -13,6 +13,16 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// public static class DitherExtensions { + /// + /// Dithers the image reducing it to a web-safe palette using Bayer4x4 ordered dithering. + /// + /// The pixel format. + /// The image this method extends. + /// The . + public static IImageProcessingContext Dither(this IImageProcessingContext source) + where TPixel : struct, IPixel + => Dither(source, Ditherers.BayerDither4x4); + /// /// Dithers the image reducing it to a web-safe palette using ordered dithering. /// @@ -22,10 +32,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// The . public static IImageProcessingContext Dither(this IImageProcessingContext source, IOrderedDither dither) where TPixel : struct, IPixel - { - source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither)); - return source; - } + => source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither)); /// /// Dithers the image reducing it to the given palette using ordered dithering. @@ -37,10 +44,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// The . public static IImageProcessingContext Dither(this IImageProcessingContext source, IOrderedDither dither, TPixel[] palette) where TPixel : struct, IPixel - { - source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither, palette)); - return source; - } + => source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither, palette)); /// /// Dithers the image reducing it to a web-safe palette using ordered dithering. @@ -54,10 +58,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// The . public static IImageProcessingContext Dither(this IImageProcessingContext source, IOrderedDither dither, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither), rectangle); - return source; - } + => source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither), rectangle); /// /// Dithers the image reducing it to the given palette using ordered dithering. @@ -72,9 +73,6 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// The . public static IImageProcessingContext Dither(this IImageProcessingContext source, IOrderedDither dither, TPixel[] palette, Rectangle rectangle) where TPixel : struct, IPixel - { - source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither, palette), rectangle); - return source; - } + => source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither, palette), rectangle); } } \ No newline at end of file diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs similarity index 88% rename from src/ImageSharp/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs index f5219b216a..2b13980fc4 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs +++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs @@ -1,11 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering.Base; -using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Primitives; -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion { /// /// Applies error diffusion based dithering using the Atkinson image dithering algorithm. diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/BurksDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/BurksDiffuser.cs similarity index 91% rename from src/ImageSharp/Dithering/ErrorDiffusion/BurksDiffuser.cs rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/BurksDiffuser.cs index 9505417e51..b4b439c9a8 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/BurksDiffuser.cs +++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/BurksDiffuser.cs @@ -1,10 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering.Base; using SixLabors.ImageSharp.Primitives; -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion { /// /// Applies error diffusion based dithering using the Burks image dithering algorithm. diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/Diffusers.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Diffusers.cs similarity index 96% rename from src/ImageSharp/Dithering/ErrorDiffusion/Diffusers.cs rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/Diffusers.cs index 6e2055e34f..dda163e553 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/Diffusers.cs +++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Diffusers.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion { /// /// Contains reusable static instances of known error diffusion algorithms diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs similarity index 98% rename from src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs index ddfac86a15..3bc1df0bb2 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs +++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs @@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; -namespace SixLabors.ImageSharp.Dithering.Base +namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion { /// /// The base class for performing error diffusion based dithering. diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs similarity index 91% rename from src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs index dd06ed199d..290d77864e 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs +++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs @@ -1,10 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering.Base; using SixLabors.ImageSharp.Primitives; -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion { /// /// Applies error diffusion based dithering using the Floyd–Steinberg image dithering algorithm. diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/IErrorDiffuser.cs similarity index 94% rename from src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/IErrorDiffuser.cs index dabc4e6822..795aa65062 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs +++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/IErrorDiffuser.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion { /// /// Encapsulates properties and methods required to perform diffused error dithering on an image. diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs similarity index 92% rename from src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs index 48d2f3a97d..816447ec9e 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs +++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs @@ -1,10 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering.Base; using SixLabors.ImageSharp.Primitives; -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion { /// /// Applies error diffusion based dithering using the JarvisJudiceNinke image dithering algorithm. diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra2Diffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Sierra2Diffuser.cs similarity index 91% rename from src/ImageSharp/Dithering/ErrorDiffusion/Sierra2Diffuser.cs rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/Sierra2Diffuser.cs index 3aa37798d1..0b7e13c84a 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra2Diffuser.cs +++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Sierra2Diffuser.cs @@ -1,10 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering.Base; using SixLabors.ImageSharp.Primitives; -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion { /// /// Applies error diffusion based dithering using the Sierra2 image dithering algorithm. diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra3Diffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Sierra3Diffuser.cs similarity index 91% rename from src/ImageSharp/Dithering/ErrorDiffusion/Sierra3Diffuser.cs rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/Sierra3Diffuser.cs index e6875b1d40..937b3a8cbd 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra3Diffuser.cs +++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Sierra3Diffuser.cs @@ -1,10 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering.Base; using SixLabors.ImageSharp.Primitives; -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion { /// /// Applies error diffusion based dithering using the Sierra3 image dithering algorithm. diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs similarity index 91% rename from src/ImageSharp/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs index 371f39fe54..c9594e9e21 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs +++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs @@ -1,10 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering.Base; using SixLabors.ImageSharp.Primitives; -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion { /// /// Applies error diffusion based dithering using the SierraLite image dithering algorithm. diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs similarity index 91% rename from src/ImageSharp/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs index beda8efbf0..749502a034 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs +++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs @@ -1,10 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering.Base; using SixLabors.ImageSharp.Primitives; -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion { /// /// Applies error diffusion based dithering using the Stevenson-Arce image dithering algorithm. @@ -31,4 +30,4 @@ namespace SixLabors.ImageSharp.Dithering { } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/StuckiDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/StuckiDiffuser.cs similarity index 91% rename from src/ImageSharp/Dithering/ErrorDiffusion/StuckiDiffuser.cs rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/StuckiDiffuser.cs index 54c448c28a..077c02cbd4 100644 --- a/src/ImageSharp/Dithering/ErrorDiffusion/StuckiDiffuser.cs +++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/StuckiDiffuser.cs @@ -1,10 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering.Base; using SixLabors.ImageSharp.Primitives; -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion { /// /// Applies error diffusion based dithering using the Stucki image dithering algorithm. diff --git a/src/ImageSharp/Dithering/Ordered/BayerDither2x2.cs b/src/ImageSharp/Processing/Dithering/Ordered/BayerDither2x2.cs similarity index 88% rename from src/ImageSharp/Dithering/Ordered/BayerDither2x2.cs rename to src/ImageSharp/Processing/Dithering/Ordered/BayerDither2x2.cs index 1d844c8a79..2d674787a2 100644 --- a/src/ImageSharp/Dithering/Ordered/BayerDither2x2.cs +++ b/src/ImageSharp/Processing/Dithering/Ordered/BayerDither2x2.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.Ordered { /// /// Applies order dithering using the 2x2 Bayer dithering matrix. diff --git a/src/ImageSharp/Dithering/Ordered/BayerDither4x4.cs b/src/ImageSharp/Processing/Dithering/Ordered/BayerDither4x4.cs similarity index 88% rename from src/ImageSharp/Dithering/Ordered/BayerDither4x4.cs rename to src/ImageSharp/Processing/Dithering/Ordered/BayerDither4x4.cs index 4e9f20beb9..edc57441a3 100644 --- a/src/ImageSharp/Dithering/Ordered/BayerDither4x4.cs +++ b/src/ImageSharp/Processing/Dithering/Ordered/BayerDither4x4.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.Ordered { /// /// Applies order dithering using the 4x4 Bayer dithering matrix. diff --git a/src/ImageSharp/Dithering/Ordered/BayerDither8x8.cs b/src/ImageSharp/Processing/Dithering/Ordered/BayerDither8x8.cs similarity index 88% rename from src/ImageSharp/Dithering/Ordered/BayerDither8x8.cs rename to src/ImageSharp/Processing/Dithering/Ordered/BayerDither8x8.cs index 3ff179a06a..b79216208b 100644 --- a/src/ImageSharp/Dithering/Ordered/BayerDither8x8.cs +++ b/src/ImageSharp/Processing/Dithering/Ordered/BayerDither8x8.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.Ordered { /// /// Applies order dithering using the 8x8 Bayer dithering matrix. diff --git a/src/ImageSharp/Dithering/Ordered/Ditherers.cs b/src/ImageSharp/Processing/Dithering/Ordered/Ditherers.cs similarity index 94% rename from src/ImageSharp/Dithering/Ordered/Ditherers.cs rename to src/ImageSharp/Processing/Dithering/Ordered/Ditherers.cs index 53e94dca49..65da1dbc46 100644 --- a/src/ImageSharp/Dithering/Ordered/Ditherers.cs +++ b/src/ImageSharp/Processing/Dithering/Ordered/Ditherers.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.Ordered { /// /// Contains reusable static instances of known ordered dither matrices diff --git a/src/ImageSharp/Dithering/Ordered/IOrderedDither.cs b/src/ImageSharp/Processing/Dithering/Ordered/IOrderedDither.cs similarity index 95% rename from src/ImageSharp/Dithering/Ordered/IOrderedDither.cs rename to src/ImageSharp/Processing/Dithering/Ordered/IOrderedDither.cs index 339f2861d9..29b96ab45a 100644 --- a/src/ImageSharp/Dithering/Ordered/IOrderedDither.cs +++ b/src/ImageSharp/Processing/Dithering/Ordered/IOrderedDither.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.Ordered { /// /// Encapsulates properties and methods required to perform ordered dithering on an image. diff --git a/src/ImageSharp/Dithering/Ordered/OrderedDither.cs b/src/ImageSharp/Processing/Dithering/Ordered/OrderedDither.cs similarity index 90% rename from src/ImageSharp/Dithering/Ordered/OrderedDither.cs rename to src/ImageSharp/Processing/Dithering/Ordered/OrderedDither.cs index 6fa90545a3..9fd274ab78 100644 --- a/src/ImageSharp/Dithering/Ordered/OrderedDither.cs +++ b/src/ImageSharp/Processing/Dithering/Ordered/OrderedDither.cs @@ -4,7 +4,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.Ordered { /// /// An ordered dithering matrix with equal sides of arbitrary length @@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Dithering this.modulusY = ditherMatrix.Rows; // Adjust the matrix range for 0-255 - // It looks like it's actually possible to dither an image using it's own colors. We should investigate for V2 + // TODO: It looks like it's actually possible to dither an image using it's own colors. We should investigate for V2 // https://stackoverflow.com/questions/12422407/monochrome-dithering-in-javascript-bayer-atkinson-floyd-steinberg int multiplier = 256 / ditherMatrix.Count; for (int y = 0; y < ditherMatrix.Rows; y++) diff --git a/src/ImageSharp/Dithering/Ordered/OrderedDither3x3.cs b/src/ImageSharp/Processing/Dithering/Ordered/OrderedDither3x3.cs similarity index 88% rename from src/ImageSharp/Dithering/Ordered/OrderedDither3x3.cs rename to src/ImageSharp/Processing/Dithering/Ordered/OrderedDither3x3.cs index 0436b35e9c..dd20817cf6 100644 --- a/src/ImageSharp/Dithering/Ordered/OrderedDither3x3.cs +++ b/src/ImageSharp/Processing/Dithering/Ordered/OrderedDither3x3.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.Ordered { /// /// Applies order dithering using the 3x3 dithering matrix. diff --git a/src/ImageSharp/Dithering/Ordered/OrderedDitherFactory.cs b/src/ImageSharp/Processing/Dithering/Ordered/OrderedDitherFactory.cs similarity index 98% rename from src/ImageSharp/Dithering/Ordered/OrderedDitherFactory.cs rename to src/ImageSharp/Processing/Dithering/Ordered/OrderedDitherFactory.cs index 78bc5fff98..7538aa50ed 100644 --- a/src/ImageSharp/Dithering/Ordered/OrderedDitherFactory.cs +++ b/src/ImageSharp/Processing/Dithering/Ordered/OrderedDitherFactory.cs @@ -4,7 +4,7 @@ using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Primitives; -namespace SixLabors.ImageSharp.Dithering +namespace SixLabors.ImageSharp.Processing.Dithering.Ordered { /// /// A factory for creating ordered dither matrices. diff --git a/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs index e01e3ce3b3..05eb5d0e3c 100644 --- a/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs @@ -3,9 +3,9 @@ using System; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; diff --git a/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs index 254c44a2ae..713800cb11 100644 --- a/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs @@ -3,9 +3,9 @@ using System; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Dithering.Ordered; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; diff --git a/src/ImageSharp/Dithering/error_diffusion.txt b/src/ImageSharp/Processing/Dithering/error_diffusion.txt similarity index 100% rename from src/ImageSharp/Dithering/error_diffusion.txt rename to src/ImageSharp/Processing/Dithering/error_diffusion.txt diff --git a/src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs index f2d280477f..841b84496b 100644 --- a/src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs @@ -1,8 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; namespace SixLabors.ImageSharp.Processing.Quantization { diff --git a/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs b/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs index bda0293322..e4cd44ec2d 100644 --- a/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs @@ -5,9 +5,8 @@ using System; using System.Collections.Generic; using System.Numerics; using System.Runtime.CompilerServices; -using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; namespace SixLabors.ImageSharp.Processing.Quantization { @@ -93,7 +92,7 @@ namespace SixLabors.ImageSharp.Processing.Quantization } /// - /// Execute a second pass through the bitmap + /// Execute a second pass through the image /// /// The source image. /// The output pixel array @@ -102,7 +101,8 @@ namespace SixLabors.ImageSharp.Processing.Quantization protected abstract void SecondPass(ImageFrame source, byte[] output, int width, int height); /// - /// Retrieve the palette for the quantized image. Can be called more than once so make sure calls are cached. + /// Retrieve the palette for the quantized image. + /// Can be called more than once so make sure calls are cached. /// /// /// diff --git a/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs index 8879bf9919..58845d2b9a 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs @@ -1,15 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; + using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Binarization { using SixLabors.ImageSharp.Processing.Binarization; using SixLabors.ImageSharp.Processing.Binarization.Processors; + using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; + using SixLabors.ImageSharp.Processing.Dithering.Ordered; public class BinaryDitherTest : BaseImageOperationsExtensionTest { diff --git a/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs b/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs index e9a97992aa..89e48cfa3f 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs @@ -1,13 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering; -using SixLabors.ImageSharp.Memory; using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Binarization { using SixLabors.ImageSharp.Primitives; + using SixLabors.ImageSharp.Processing.Dithering.Ordered; public class OrderedDitherFactoryTests { diff --git a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs index 3868ecd703..ea0c8eecad 100644 --- a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs +++ b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; using Xunit; @@ -9,6 +8,8 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Binarization { using SixLabors.ImageSharp.Processing.Dithering; + using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; + using SixLabors.ImageSharp.Processing.Dithering.Ordered; using SixLabors.ImageSharp.Processing.Dithering.Processors; public class DitherTest : BaseImageOperationsExtensionTest diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs index f5f0ee7a69..6859580668 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; @@ -13,6 +12,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization { using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Binarization; + using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; + using SixLabors.ImageSharp.Processing.Dithering.Ordered; public class BinaryDitherTests : FileTestBase { @@ -21,12 +22,12 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization TestImages.Png.CalliphoraPartial, TestImages.Png.Bike }; - public static readonly TheoryData Ditherers = new TheoryData + public static readonly TheoryData OrderedDitherers = new TheoryData { - { "Bayer8x8", Dithering.Ditherers.BayerDither8x8 }, - { "Bayer4x4", Dithering.Ditherers.BayerDither4x4 }, - { "Ordered3x3", Dithering.Ditherers.OrderedDither3x3 }, - { "Bayer2x2", Dithering.Ditherers.BayerDither2x2 } + { "Bayer8x8", Ditherers.BayerDither8x8 }, + { "Bayer4x4", Ditherers.BayerDither4x4 }, + { "Ordered3x3", Ditherers.OrderedDither3x3 }, + { "Bayer2x2", Ditherers.BayerDither2x2 } }; public static readonly TheoryData ErrorDiffusers = new TheoryData @@ -48,8 +49,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization private static IErrorDiffuser DefaultErrorDiffuser => Diffusers.Atkinson; [Theory] - [WithFileCollection(nameof(CommonTestImages), nameof(Ditherers), DefaultPixelType)] - [WithTestPatternImages(nameof(Ditherers), 100, 100, DefaultPixelType)] + [WithFileCollection(nameof(CommonTestImages), nameof(OrderedDitherers), DefaultPixelType)] + [WithTestPatternImages(nameof(OrderedDitherers), 100, 100, DefaultPixelType)] public void BinaryDitherFilter_WorksWithAllDitherers(TestImageProvider provider, string name, IOrderedDither ditherer) where TPixel : struct, IPixel { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index 519790655f..2e4bea7e6f 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -1,18 +1,19 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Dithering; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; - +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Dithering; +using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; +using SixLabors.ImageSharp.Processing.Dithering.Ordered; using SixLabors.Primitives; using Xunit; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization { - using SixLabors.ImageSharp.Processing; - using SixLabors.ImageSharp.Processing.Dithering; + public class DitherTests : FileTestBase { @@ -21,12 +22,12 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization TestImages.Png.CalliphoraPartial, TestImages.Png.Bike }; - public static readonly TheoryData Ditherers = new TheoryData + public static readonly TheoryData OrderedDitherers = new TheoryData { - { "Bayer8x8", Dithering.Ditherers.BayerDither8x8 }, - { "Bayer4x4", Dithering.Ditherers.BayerDither4x4 }, - { "Ordered3x3", Dithering.Ditherers.OrderedDither3x3 }, - { "Bayer2x2", Dithering.Ditherers.BayerDither2x2 } + { "Bayer8x8", Ditherers.BayerDither8x8 }, + { "Bayer4x4", Ditherers.BayerDither4x4 }, + { "Ordered3x3", Ditherers.OrderedDither3x3 }, + { "Bayer2x2", Ditherers.BayerDither2x2 } }; public static readonly TheoryData ErrorDiffusers = new TheoryData @@ -43,13 +44,13 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization }; - private static IOrderedDither DefaultDitherer => Dithering.Ditherers.BayerDither4x4; + private static IOrderedDither DefaultDitherer => Ditherers.BayerDither4x4; private static IErrorDiffuser DefaultErrorDiffuser => Diffusers.Atkinson; [Theory] - [WithFileCollection(nameof(CommonTestImages), nameof(Ditherers), DefaultPixelType)] - [WithTestPatternImages(nameof(Ditherers), 100, 100, DefaultPixelType)] + [WithFileCollection(nameof(CommonTestImages), nameof(OrderedDitherers), DefaultPixelType)] + [WithTestPatternImages(nameof(OrderedDitherers), 100, 100, DefaultPixelType)] public void DitherFilter_WorksWithAllDitherers(TestImageProvider provider, string name, IOrderedDither ditherer) where TPixel : struct, IPixel { From 9691d5905afef3ea582031da2c5468a011834b1c Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 9 Mar 2018 16:58:11 +1100 Subject: [PATCH 07/18] Fix test --- .../Processing/Processors/Binarization/BinaryDitherTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs index 6859580668..1859ed109f 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization }; - private static IOrderedDither DefaultDitherer => Dithering.Ditherers.BayerDither4x4; + private static IOrderedDither DefaultDitherer => Ditherers.BayerDither4x4; private static IErrorDiffuser DefaultErrorDiffuser => Diffusers.Atkinson; From aca8636bfd615f322af3b43b842a83ced29ade81 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 9 Mar 2018 23:58:16 +1100 Subject: [PATCH 08/18] Normalize predefined group naming. --- .../Processing/Dithering/DiffuseExtensions.cs | 4 +- .../Diffusers.cs => DiffuseMode.cs} | 6 ++- .../Processing/Dithering/DitherExtensions.cs | 2 +- .../{Ordered/Ditherers.cs => DitherMode.cs} | 6 ++- .../Quantization/QuantizerBase{TPixel}.cs | 3 +- .../Processing/Transforms/PadExtensions.cs | 2 +- .../Processors/AffineTransformProcessor.cs | 1 + .../CenteredAffineTransformProcessor.cs | 1 + .../CenteredProjectiveTransformProcessor.cs | 1 + .../InterpolatedTransformProcessorBase.cs | 2 + .../ProjectiveTransformProcessor.cs | 1 + .../Transforms/Processors/ResizeProcessor.cs | 1 + .../Transforms/Processors/RotateProcessor.cs | 4 +- .../Transforms/Processors/SkewProcessor.cs | 3 +- .../{Resamplers.cs => ResampleMode.cs} | 4 +- .../{ => Resamplers}/BicubicResampler.cs | 2 +- .../{ => Resamplers}/BoxResampler.cs | 2 +- .../{ => Resamplers}/CatmullRomResampler.cs | 2 +- .../{ => Resamplers}/HermiteResampler.cs | 2 +- .../Transforms/{ => Resamplers}/IResampler.cs | 2 +- .../{ => Resamplers}/Lanczos2Resampler.cs | 2 +- .../{ => Resamplers}/Lanczos3Resampler.cs | 2 +- .../{ => Resamplers}/Lanczos5Resampler.cs | 2 +- .../{ => Resamplers}/Lanczos8Resampler.cs | 2 +- .../MitchellNetravaliResampler.cs | 2 +- .../NearestNeighborResampler.cs | 2 +- .../{ => Resamplers}/RobidouxResampler.cs | 2 +- .../RobidouxSharpResampler.cs | 2 +- .../{ => Resamplers}/SplineResampler.cs | 2 +- .../{ => Resamplers}/TriangleResampler.cs | 2 +- .../{ => Resamplers}/WelchResampler.cs | 2 +- .../Processing/Transforms/ResizeExtensions.cs | 9 ++-- .../Processing/Transforms/ResizeMode.cs | 4 +- .../Processing/Transforms/ResizeOptions.cs | 3 +- .../Processing/Transforms/RotateExtensions.cs | 3 +- .../Processing/Transforms/SkewExtensions.cs | 3 +- .../Transforms/TransformExtensions.cs | 5 +- .../ImageSharp.Tests/Drawing/DrawImageTest.cs | 2 +- .../Binarization/BinaryDitherTest.cs | 5 +- .../Processing/Dithering/DitherTest.cs | 6 +-- .../Binarization/BinaryDitherTests.cs | 31 ++++++------ .../Processors/Dithering/DitherTests.cs | 30 ++++++------ .../Transforms/ResizeProfilingBenchmarks.cs | 2 +- .../Processors/Transforms/ResizeTests.cs | 41 ++++++++-------- .../Processors/Transforms/SkewTest.cs | 33 +++++++------ .../Transforms/AffineTransformTests.cs | 49 ++++++++++--------- .../Processing/Transforms/PadTest.cs | 6 +-- .../Processing/Transforms/ResizeTests.cs | 7 +-- 48 files changed, 167 insertions(+), 145 deletions(-) rename src/ImageSharp/Processing/Dithering/{ErrorDiffusion/Diffusers.cs => DiffuseMode.cs} (93%) rename src/ImageSharp/Processing/Dithering/{Ordered/Ditherers.cs => DitherMode.cs} (88%) rename src/ImageSharp/Processing/Transforms/{Resamplers.cs => ResampleMode.cs} (97%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/BicubicResampler.cs (95%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/BoxResampler.cs (90%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/CatmullRomResampler.cs (92%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/HermiteResampler.cs (91%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/IResampler.cs (91%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/Lanczos2Resampler.cs (92%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/Lanczos3Resampler.cs (92%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/Lanczos5Resampler.cs (92%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/Lanczos8Resampler.cs (92%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/MitchellNetravaliResampler.cs (90%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/NearestNeighborResampler.cs (89%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/RobidouxResampler.cs (90%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/RobidouxSharpResampler.cs (90%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/SplineResampler.cs (90%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/TriangleResampler.cs (92%) rename src/ImageSharp/Processing/Transforms/{ => Resamplers}/WelchResampler.cs (91%) diff --git a/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs b/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs index a20ba01ad1..7ae8ec01ef 100644 --- a/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs +++ b/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// The . public static IImageProcessingContext Diffuse(this IImageProcessingContext source) where TPixel : struct, IPixel - => Diffuse(source, Diffusers.FloydSteinberg, .5F); + => Diffuse(source, DiffuseMode.FloydSteinberg, .5F); /// /// Dithers the image reducing it to a web-safe palette using error diffusion. @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// The . public static IImageProcessingContext Diffuse(this IImageProcessingContext source, float threshold) where TPixel : struct, IPixel - => Diffuse(source, Diffusers.FloydSteinberg, threshold); + => Diffuse(source, DiffuseMode.FloydSteinberg, threshold); /// /// Dithers the image reducing it to a web-safe palette using error diffusion. diff --git a/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Diffusers.cs b/src/ImageSharp/Processing/Dithering/DiffuseMode.cs similarity index 93% rename from src/ImageSharp/Processing/Dithering/ErrorDiffusion/Diffusers.cs rename to src/ImageSharp/Processing/Dithering/DiffuseMode.cs index dda163e553..cc74f1230f 100644 --- a/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Diffusers.cs +++ b/src/ImageSharp/Processing/Dithering/DiffuseMode.cs @@ -1,12 +1,14 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion +using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; + +namespace SixLabors.ImageSharp.Processing.Dithering { /// /// Contains reusable static instances of known error diffusion algorithms /// - public static class Diffusers + public static class DiffuseMode { /// /// Gets the error diffuser that implements the Atkinson algorithm. diff --git a/src/ImageSharp/Processing/Dithering/DitherExtensions.cs b/src/ImageSharp/Processing/Dithering/DitherExtensions.cs index e91c450cdd..31ef12a0ac 100644 --- a/src/ImageSharp/Processing/Dithering/DitherExtensions.cs +++ b/src/ImageSharp/Processing/Dithering/DitherExtensions.cs @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering /// The . public static IImageProcessingContext Dither(this IImageProcessingContext source) where TPixel : struct, IPixel - => Dither(source, Ditherers.BayerDither4x4); + => Dither(source, DitherMode.BayerDither4x4); /// /// Dithers the image reducing it to a web-safe palette using ordered dithering. diff --git a/src/ImageSharp/Processing/Dithering/Ordered/Ditherers.cs b/src/ImageSharp/Processing/Dithering/DitherMode.cs similarity index 88% rename from src/ImageSharp/Processing/Dithering/Ordered/Ditherers.cs rename to src/ImageSharp/Processing/Dithering/DitherMode.cs index 65da1dbc46..f5122608c1 100644 --- a/src/ImageSharp/Processing/Dithering/Ordered/Ditherers.cs +++ b/src/ImageSharp/Processing/Dithering/DitherMode.cs @@ -1,12 +1,14 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Dithering.Ordered +using SixLabors.ImageSharp.Processing.Dithering.Ordered; + +namespace SixLabors.ImageSharp.Processing.Dithering { /// /// Contains reusable static instances of known ordered dither matrices /// - public class Ditherers + public class DitherMode { /// /// Gets the order ditherer using the 2x2 Bayer dithering matrix diff --git a/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs b/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs index e4cd44ec2d..96763195d2 100644 --- a/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Numerics; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Dithering; using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; namespace SixLabors.ImageSharp.Processing.Quantization @@ -42,7 +43,7 @@ namespace SixLabors.ImageSharp.Processing.Quantization public bool Dither { get; set; } = true; /// - public IErrorDiffuser DitherType { get; set; } = Diffusers.FloydSteinberg; + public IErrorDiffuser DitherType { get; set; } = DiffuseMode.FloydSteinberg; /// public virtual QuantizedFrame Quantize(ImageFrame image, int maxColors) diff --git a/src/ImageSharp/Processing/Transforms/PadExtensions.cs b/src/ImageSharp/Processing/Transforms/PadExtensions.cs index 7d26cba620..23e9d5d27e 100644 --- a/src/ImageSharp/Processing/Transforms/PadExtensions.cs +++ b/src/ImageSharp/Processing/Transforms/PadExtensions.cs @@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms { Size = new Size(width, height), Mode = ResizeMode.BoxPad, - Sampler = Resamplers.NearestNeighbor + Sampler = ResampleMode.NearestNeighbor }; return source.Resize(options); diff --git a/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs index 3846379cd7..3a58ed7873 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs @@ -10,6 +10,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms.Processors diff --git a/src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs index b9a4a6a76a..adeed55efd 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs @@ -3,6 +3,7 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms.Processors diff --git a/src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs index 513e6da323..5cdcde4839 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs @@ -3,6 +3,7 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms.Processors diff --git a/src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs b/src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs index 303713d6ce..6e663f1e12 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs @@ -4,6 +4,7 @@ using System; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; namespace SixLabors.ImageSharp.Processing.Transforms.Processors { @@ -20,6 +21,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors /// The sampler to perform the transform operation. protected InterpolatedTransformProcessorBase(IResampler sampler) { + Guard.NotNull(sampler, nameof(sampler)); this.Sampler = sampler; } diff --git a/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs index a628d8a049..9f68ab6ca7 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs @@ -10,6 +10,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; // TODO: Doesn't work yet! Implement tests + Finish implementation + Document Matrix4x4 behavior diff --git a/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs index 6e60be8436..7630db6a24 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs @@ -11,6 +11,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms.Processors diff --git a/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs index 9a069f1b6b..6835fbb253 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs @@ -3,11 +3,11 @@ using System; using System.Threading.Tasks; - using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.MetaData.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms.Processors @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors /// The angle of rotation in degrees. /// The source image size public RotateProcessor(float degrees, Size sourceSize) - : this(degrees, Resamplers.Bicubic, sourceSize) + : this(degrees, ResampleMode.Bicubic, sourceSize) { } diff --git a/src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs index 5bb594f2fe..cc3d901d6c 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms.Processors @@ -20,7 +21,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors /// The angle in degrees to perform the skew along the y-axis. /// The source image size public SkewProcessor(float degreesX, float degreesY, Size sourceSize) - : this(degreesX, degreesY, Resamplers.Bicubic, sourceSize) + : this(degreesX, degreesY, ResampleMode.Bicubic, sourceSize) { } diff --git a/src/ImageSharp/Processing/Transforms/Resamplers.cs b/src/ImageSharp/Processing/Transforms/ResampleMode.cs similarity index 97% rename from src/ImageSharp/Processing/Transforms/Resamplers.cs rename to src/ImageSharp/Processing/Transforms/ResampleMode.cs index 791d493d9e..bbbdc3b265 100644 --- a/src/ImageSharp/Processing/Transforms/Resamplers.cs +++ b/src/ImageSharp/Processing/Transforms/ResampleMode.cs @@ -1,12 +1,14 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; + namespace SixLabors.ImageSharp.Processing.Transforms { /// /// Contains reusable static instances of known resampling algorithms /// - public static class Resamplers + public static class ResampleMode { /// /// Gets the Bicubic sampler that implements the bicubic kernel algorithm W(x) diff --git a/src/ImageSharp/Processing/Transforms/BicubicResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/BicubicResampler.cs similarity index 95% rename from src/ImageSharp/Processing/Transforms/BicubicResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/BicubicResampler.cs index 5a48fd4ad3..dd655a8a34 100644 --- a/src/ImageSharp/Processing/Transforms/BicubicResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/BicubicResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the bicubic kernel algorithm W(x) as described on diff --git a/src/ImageSharp/Processing/Transforms/BoxResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/BoxResampler.cs similarity index 90% rename from src/ImageSharp/Processing/Transforms/BoxResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/BoxResampler.cs index fa31ac4fb5..d6f79721c4 100644 --- a/src/ImageSharp/Processing/Transforms/BoxResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/BoxResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the box algorithm. Similar to nearest neighbor when upscaling. diff --git a/src/ImageSharp/Processing/Transforms/CatmullRomResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/CatmullRomResampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/CatmullRomResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/CatmullRomResampler.cs index 03723823bb..7284bf715d 100644 --- a/src/ImageSharp/Processing/Transforms/CatmullRomResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/CatmullRomResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The Catmull-Rom filter is a well known standard Cubic Filter often used as a interpolation function. diff --git a/src/ImageSharp/Processing/Transforms/HermiteResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/HermiteResampler.cs similarity index 91% rename from src/ImageSharp/Processing/Transforms/HermiteResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/HermiteResampler.cs index f41c03e2db..2017a1cb54 100644 --- a/src/ImageSharp/Processing/Transforms/HermiteResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/HermiteResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The Hermite filter is type of smoothed triangular interpolation Filter, diff --git a/src/ImageSharp/Processing/Transforms/IResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/IResampler.cs similarity index 91% rename from src/ImageSharp/Processing/Transforms/IResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/IResampler.cs index fd23a4644d..6bc4feaf08 100644 --- a/src/ImageSharp/Processing/Transforms/IResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/IResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// Encapsulates an interpolation algorithm for resampling images. diff --git a/src/ImageSharp/Processing/Transforms/Lanczos2Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Lanczos2Resampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs index c78926ed23..35735189a0 100644 --- a/src/ImageSharp/Processing/Transforms/Lanczos2Resampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the Lanczos kernel algorithm as described on diff --git a/src/ImageSharp/Processing/Transforms/Lanczos3Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Lanczos3Resampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs index b6d08fc530..fa85767a64 100644 --- a/src/ImageSharp/Processing/Transforms/Lanczos3Resampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the Lanczos kernel algorithm as described on diff --git a/src/ImageSharp/Processing/Transforms/Lanczos5Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Lanczos5Resampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs index b8055f6ce9..ec6b7181a0 100644 --- a/src/ImageSharp/Processing/Transforms/Lanczos5Resampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the Lanczos kernel algorithm as described on diff --git a/src/ImageSharp/Processing/Transforms/Lanczos8Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/Lanczos8Resampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs index 39afe11bbf..c1f6aecf1c 100644 --- a/src/ImageSharp/Processing/Transforms/Lanczos8Resampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the Lanczos kernel algorithm as described on diff --git a/src/ImageSharp/Processing/Transforms/MitchellNetravaliResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/MitchellNetravaliResampler.cs similarity index 90% rename from src/ImageSharp/Processing/Transforms/MitchellNetravaliResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/MitchellNetravaliResampler.cs index 0b1685e110..b7817400bb 100644 --- a/src/ImageSharp/Processing/Transforms/MitchellNetravaliResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/MitchellNetravaliResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the mitchell algorithm as described on diff --git a/src/ImageSharp/Processing/Transforms/NearestNeighborResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/NearestNeighborResampler.cs similarity index 89% rename from src/ImageSharp/Processing/Transforms/NearestNeighborResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/NearestNeighborResampler.cs index c0f019a88d..61155132eb 100644 --- a/src/ImageSharp/Processing/Transforms/NearestNeighborResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/NearestNeighborResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the nearest neighbor algorithm. This uses an unscaled filter diff --git a/src/ImageSharp/Processing/Transforms/RobidouxResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/RobidouxResampler.cs similarity index 90% rename from src/ImageSharp/Processing/Transforms/RobidouxResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/RobidouxResampler.cs index 829e1ee9bd..03a6e8677e 100644 --- a/src/ImageSharp/Processing/Transforms/RobidouxResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/RobidouxResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the Robidoux algorithm. diff --git a/src/ImageSharp/Processing/Transforms/RobidouxSharpResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/RobidouxSharpResampler.cs similarity index 90% rename from src/ImageSharp/Processing/Transforms/RobidouxSharpResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/RobidouxSharpResampler.cs index 4cbf13f58c..83213c3f4e 100644 --- a/src/ImageSharp/Processing/Transforms/RobidouxSharpResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/RobidouxSharpResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the Robidoux Sharp algorithm. diff --git a/src/ImageSharp/Processing/Transforms/SplineResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/SplineResampler.cs similarity index 90% rename from src/ImageSharp/Processing/Transforms/SplineResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/SplineResampler.cs index 3448d5fb8c..45f18a4a01 100644 --- a/src/ImageSharp/Processing/Transforms/SplineResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/SplineResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the spline algorithm. diff --git a/src/ImageSharp/Processing/Transforms/TriangleResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/TriangleResampler.cs similarity index 92% rename from src/ImageSharp/Processing/Transforms/TriangleResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/TriangleResampler.cs index 2f5783e207..0fde54486e 100644 --- a/src/ImageSharp/Processing/Transforms/TriangleResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/TriangleResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the triangle (bilinear) algorithm. diff --git a/src/ImageSharp/Processing/Transforms/WelchResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs similarity index 91% rename from src/ImageSharp/Processing/Transforms/WelchResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs index de60f9f247..01a07fed57 100644 --- a/src/ImageSharp/Processing/Transforms/WelchResampler.cs +++ b/src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Processing.Transforms +namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers { /// /// The function implements the welch algorithm. diff --git a/src/ImageSharp/Processing/Transforms/ResizeExtensions.cs b/src/ImageSharp/Processing/Transforms/ResizeExtensions.cs index 1580aa6366..4101d3cff4 100644 --- a/src/ImageSharp/Processing/Transforms/ResizeExtensions.cs +++ b/src/ImageSharp/Processing/Transforms/ResizeExtensions.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms @@ -34,7 +35,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, Size size) where TPixel : struct, IPixel - => Resize(source, size.Width, size.Height, Resamplers.Bicubic, false); + => Resize(source, size.Width, size.Height, ResampleMode.Bicubic, false); /// /// Resizes an image to the given . @@ -47,7 +48,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, Size size, bool compand) where TPixel : struct, IPixel - => Resize(source, size.Width, size.Height, Resamplers.Bicubic, compand); + => Resize(source, size.Width, size.Height, ResampleMode.Bicubic, compand); /// /// Resizes an image to the given width and height. @@ -60,7 +61,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, int width, int height) where TPixel : struct, IPixel - => Resize(source, width, height, Resamplers.Bicubic, false); + => Resize(source, width, height, ResampleMode.Bicubic, false); /// /// Resizes an image to the given width and height. @@ -74,7 +75,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image public static IImageProcessingContext Resize(this IImageProcessingContext source, int width, int height, bool compand) where TPixel : struct, IPixel - => Resize(source, width, height, Resamplers.Bicubic, compand); + => Resize(source, width, height, ResampleMode.Bicubic, compand); /// /// Resizes an image to the given width and height with the given sampler. diff --git a/src/ImageSharp/Processing/Transforms/ResizeMode.cs b/src/ImageSharp/Processing/Transforms/ResizeMode.cs index 248ac20f4e..d81691cd37 100644 --- a/src/ImageSharp/Processing/Transforms/ResizeMode.cs +++ b/src/ImageSharp/Processing/Transforms/ResizeMode.cs @@ -4,7 +4,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms { /// - /// Enumerated resize modes to apply to resized images. + /// Enumerated resize modes to apply to images. /// public enum ResizeMode { @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// /// Pads the image to fit the bound of the container without resizing the /// original source. - /// When downscaling, performs the same functionality as + /// When downscaling, performs the same functionality as /// BoxPad, diff --git a/src/ImageSharp/Processing/Transforms/ResizeOptions.cs b/src/ImageSharp/Processing/Transforms/ResizeOptions.cs index afa3142e51..8d63847485 100644 --- a/src/ImageSharp/Processing/Transforms/ResizeOptions.cs +++ b/src/ImageSharp/Processing/Transforms/ResizeOptions.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms @@ -35,7 +36,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// /// Gets or sets the sampler to perform the resize operation. /// - public IResampler Sampler { get; set; } = Resamplers.Bicubic; + public IResampler Sampler { get; set; } = ResampleMode.Bicubic; /// /// Gets or sets a value indicating whether to compress diff --git a/src/ImageSharp/Processing/Transforms/RotateExtensions.cs b/src/ImageSharp/Processing/Transforms/RotateExtensions.cs index 9001bc3ff5..e4a233ba45 100644 --- a/src/ImageSharp/Processing/Transforms/RotateExtensions.cs +++ b/src/ImageSharp/Processing/Transforms/RotateExtensions.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; namespace SixLabors.ImageSharp.Processing.Transforms { @@ -31,7 +32,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// The public static IImageProcessingContext Rotate(this IImageProcessingContext source, float degrees) where TPixel : struct, IPixel - => Rotate(source, degrees, Resamplers.Bicubic); + => Rotate(source, degrees, ResampleMode.Bicubic); /// /// Rotates an image by the given angle in degrees using the specified sampling algorithm. diff --git a/src/ImageSharp/Processing/Transforms/SkewExtensions.cs b/src/ImageSharp/Processing/Transforms/SkewExtensions.cs index c80619aa9a..686f2c87c8 100644 --- a/src/ImageSharp/Processing/Transforms/SkewExtensions.cs +++ b/src/ImageSharp/Processing/Transforms/SkewExtensions.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; namespace SixLabors.ImageSharp.Processing.Transforms { @@ -21,7 +22,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// The public static IImageProcessingContext Skew(this IImageProcessingContext source, float degreesX, float degreesY) where TPixel : struct, IPixel - => Skew(source, degreesX, degreesY, Resamplers.Bicubic); + => Skew(source, degreesX, degreesY, ResampleMode.Bicubic); /// /// Skews an image by the given angles in degrees using the specified sampling algorithm. diff --git a/src/ImageSharp/Processing/Transforms/TransformExtensions.cs b/src/ImageSharp/Processing/Transforms/TransformExtensions.cs index 7bd37afeff..865511b26d 100644 --- a/src/ImageSharp/Processing/Transforms/TransformExtensions.cs +++ b/src/ImageSharp/Processing/Transforms/TransformExtensions.cs @@ -4,6 +4,7 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Transforms @@ -22,7 +23,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// The public static IImageProcessingContext Transform(this IImageProcessingContext source, Matrix3x2 matrix) where TPixel : struct, IPixel - => Transform(source, matrix, Resamplers.Bicubic); + => Transform(source, matrix, ResampleMode.Bicubic); /// /// Transforms an image by the given matrix using the specified sampling algorithm. @@ -87,7 +88,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms /// The internal static IImageProcessingContext Transform(this IImageProcessingContext source, Matrix4x4 matrix) where TPixel : struct, IPixel - => Transform(source, matrix, Resamplers.Bicubic); + => Transform(source, matrix, ResampleMode.Bicubic); /// /// Applies a projective transform to the image by the given matrix using the specified sampling algorithm. diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs index 177891b94a..07f3aa5541 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs @@ -66,7 +66,7 @@ namespace SixLabors.ImageSharp.Tests // We pass a new rectangle here based on the dest bounds since we've offset the matrix blend.Mutate(x => x.Transform( centeredMatrix, - Resamplers.Bicubic, + ResampleMode.Bicubic, new Rectangle(0, 0, destBounds.Width, destBounds.Height))); var position = new Point((image.Width - blend.Width) / 2, (image.Height - blend.Height) / 2); diff --git a/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs index 58845d2b9a..a742171b19 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs @@ -9,6 +9,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization { using SixLabors.ImageSharp.Processing.Binarization; using SixLabors.ImageSharp.Processing.Binarization.Processors; + using SixLabors.ImageSharp.Processing.Dithering; using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; using SixLabors.ImageSharp.Processing.Dithering.Ordered; @@ -19,8 +20,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization public BinaryDitherTest() { - this.orderedDither = Ditherers.BayerDither4x4; - this.errorDiffuser = Diffusers.FloydSteinberg; + this.orderedDither = DitherMode.BayerDither4x4; + this.errorDiffuser = DiffuseMode.FloydSteinberg; } [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs index ea0c8eecad..69aee9bc81 100644 --- a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs +++ b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; + using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Binarization @@ -25,8 +25,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization public DitherTest() { - this.orderedDither = Ditherers.BayerDither4x4; - this.errorDiffuser = Diffusers.FloydSteinberg; + this.orderedDither = DitherMode.BayerDither4x4; + this.errorDiffuser = DiffuseMode.FloydSteinberg; } [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs index 1859ed109f..2937573395 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs @@ -12,6 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization { using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Binarization; + using SixLabors.ImageSharp.Processing.Dithering; using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; using SixLabors.ImageSharp.Processing.Dithering.Ordered; @@ -24,29 +25,29 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization public static readonly TheoryData OrderedDitherers = new TheoryData { - { "Bayer8x8", Ditherers.BayerDither8x8 }, - { "Bayer4x4", Ditherers.BayerDither4x4 }, - { "Ordered3x3", Ditherers.OrderedDither3x3 }, - { "Bayer2x2", Ditherers.BayerDither2x2 } + { "Bayer8x8", DitherMode.BayerDither8x8 }, + { "Bayer4x4", DitherMode.BayerDither4x4 }, + { "Ordered3x3", DitherMode.OrderedDither3x3 }, + { "Bayer2x2", DitherMode.BayerDither2x2 } }; public static readonly TheoryData ErrorDiffusers = new TheoryData { - { "Atkinson", Diffusers.Atkinson }, - { "Burks", Diffusers.Burks }, - { "FloydSteinberg", Diffusers.FloydSteinberg }, - { "JarvisJudiceNinke", Diffusers.JarvisJudiceNinke }, - { "Sierra2", Diffusers.Sierra2 }, - { "Sierra3", Diffusers.Sierra3 }, - { "SierraLite", Diffusers.SierraLite }, - { "StevensonArce", Diffusers.StevensonArce }, - { "Stucki", Diffusers.Stucki }, + { "Atkinson", DiffuseMode.Atkinson }, + { "Burks", DiffuseMode.Burks }, + { "FloydSteinberg", DiffuseMode.FloydSteinberg }, + { "JarvisJudiceNinke", DiffuseMode.JarvisJudiceNinke }, + { "Sierra2", DiffuseMode.Sierra2 }, + { "Sierra3", DiffuseMode.Sierra3 }, + { "SierraLite", DiffuseMode.SierraLite }, + { "StevensonArce", DiffuseMode.StevensonArce }, + { "Stucki", DiffuseMode.Stucki }, }; - private static IOrderedDither DefaultDitherer => Ditherers.BayerDither4x4; + private static IOrderedDither DefaultDitherer => DitherMode.BayerDither4x4; - private static IErrorDiffuser DefaultErrorDiffuser => Diffusers.Atkinson; + private static IErrorDiffuser DefaultErrorDiffuser => DiffuseMode.Atkinson; [Theory] [WithFileCollection(nameof(CommonTestImages), nameof(OrderedDitherers), DefaultPixelType)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index 2e4bea7e6f..3bb3aedfcf 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -24,29 +24,29 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization public static readonly TheoryData OrderedDitherers = new TheoryData { - { "Bayer8x8", Ditherers.BayerDither8x8 }, - { "Bayer4x4", Ditherers.BayerDither4x4 }, - { "Ordered3x3", Ditherers.OrderedDither3x3 }, - { "Bayer2x2", Ditherers.BayerDither2x2 } + { "Bayer8x8", DitherMode.BayerDither8x8 }, + { "Bayer4x4", DitherMode.BayerDither4x4 }, + { "Ordered3x3", DitherMode.OrderedDither3x3 }, + { "Bayer2x2", DitherMode.BayerDither2x2 } }; public static readonly TheoryData ErrorDiffusers = new TheoryData { - { "Atkinson", Diffusers.Atkinson }, - { "Burks", Diffusers.Burks }, - { "FloydSteinberg", Diffusers.FloydSteinberg }, - { "JarvisJudiceNinke", Diffusers.JarvisJudiceNinke }, - { "Sierra2", Diffusers.Sierra2 }, - { "Sierra3", Diffusers.Sierra3 }, - { "SierraLite", Diffusers.SierraLite }, - { "StevensonArce", Diffusers.StevensonArce }, - { "Stucki", Diffusers.Stucki }, + { "Atkinson", DiffuseMode.Atkinson }, + { "Burks", DiffuseMode.Burks }, + { "FloydSteinberg", DiffuseMode.FloydSteinberg }, + { "JarvisJudiceNinke", DiffuseMode.JarvisJudiceNinke }, + { "Sierra2", DiffuseMode.Sierra2 }, + { "Sierra3", DiffuseMode.Sierra3 }, + { "SierraLite", DiffuseMode.SierraLite }, + { "StevensonArce", DiffuseMode.StevensonArce }, + { "Stucki", DiffuseMode.Stucki }, }; - private static IOrderedDither DefaultDitherer => Ditherers.BayerDither4x4; + private static IOrderedDither DefaultDitherer => DitherMode.BayerDither4x4; - private static IErrorDiffuser DefaultErrorDiffuser => Diffusers.Atkinson; + private static IErrorDiffuser DefaultErrorDiffuser => DiffuseMode.Atkinson; [Theory] [WithFileCollection(nameof(CommonTestImages), nameof(OrderedDitherers), DefaultPixelType)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs index 84030adf16..ab0efbd708 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs @@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms public void PrintWeightsData() { var size = new Size(500, 500); - var proc = new ResizeProcessor(Resamplers.Bicubic, 200, 200, size); + var proc = new ResizeProcessor(ResampleMode.Bicubic, 200, 200, size); WeightsBuffer weights = proc.PrecomputeWeights(Configuration.Default.MemoryManager, proc.Width, size.Width); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs index 38201d4d6f..82abb90288 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -2,11 +2,10 @@ // Licensed under the Apache License, Version 2.0. using System; - using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; - +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; using Xunit; @@ -22,20 +21,20 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms public static readonly TheoryData AllReSamplers = new TheoryData { - { "Bicubic", Resamplers.Bicubic }, - { "Triangle", Resamplers.Triangle}, - { "NearestNeighbor", Resamplers.NearestNeighbor }, - { "Box", Resamplers.Box }, + { "Bicubic", ResampleMode.Bicubic }, + { "Triangle", ResampleMode.Triangle}, + { "NearestNeighbor", ResampleMode.NearestNeighbor }, + { "Box", ResampleMode.Box }, // { "Lanczos2", KnownResamplers.Lanczos2 }, TODO: Add expected file - { "Lanczos3", Resamplers.Lanczos3 }, - { "Lanczos5", Resamplers.Lanczos5 }, - { "MitchellNetravali", Resamplers.MitchellNetravali }, - { "Lanczos8", Resamplers.Lanczos8 }, - { "Hermite", Resamplers.Hermite }, - { "Spline", Resamplers.Spline }, - { "Robidoux", Resamplers.Robidoux }, - { "RobidouxSharp", Resamplers.RobidouxSharp }, - { "Welch", Resamplers.Welch } + { "Lanczos3", ResampleMode.Lanczos3 }, + { "Lanczos5", ResampleMode.Lanczos5 }, + { "MitchellNetravali", ResampleMode.MitchellNetravali }, + { "Lanczos8", ResampleMode.Lanczos8 }, + { "Hermite", ResampleMode.Hermite }, + { "Spline", ResampleMode.Spline }, + { "Robidoux", ResampleMode.Robidoux }, + { "RobidouxSharp", ResampleMode.RobidouxSharp }, + { "Welch", ResampleMode.Welch } }; [Theory] @@ -104,7 +103,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { using (Image image = provider.GetImage()) { - image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2, Resamplers.NearestNeighbor)); + image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2, ResampleMode.NearestNeighbor)); // Comparer fights decoder with gif-s. Could not use CompareToReferenceOutput here :( image.DebugSave(provider, extension: Extensions.Gif); @@ -121,7 +120,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms var sourceRectangle = new Rectangle(image.Width / 8, image.Height / 8, image.Width / 4, image.Height / 4); var destRectangle = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); - image.Mutate(x => x.Resize(image.Width, image.Height, Resamplers.Bicubic, sourceRectangle, destRectangle, false)); + image.Mutate(x => x.Resize(image.Width, image.Height, ResampleMode.Bicubic, sourceRectangle, destRectangle, false)); image.DebugSave(provider); image.CompareToReferenceOutput(provider); @@ -302,7 +301,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(2, 0)] public static void BicubicWindowOscillatesCorrectly(float x, float expected) { - var sampler = Resamplers.Bicubic; + var sampler = ResampleMode.Bicubic; float result = sampler.GetValue(x); Assert.Equal(result, expected); @@ -316,7 +315,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(2, 0)] public static void TriangleWindowOscillatesCorrectly(float x, float expected) { - var sampler = Resamplers.Triangle; + var sampler = ResampleMode.Triangle; float result = sampler.GetValue(x); Assert.Equal(result, expected); @@ -330,7 +329,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(2, 0)] public static void Lanczos3WindowOscillatesCorrectly(float x, float expected) { - var sampler = Resamplers.Lanczos3; + var sampler = ResampleMode.Lanczos3; float result = sampler.GetValue(x); Assert.Equal(result, expected); @@ -344,7 +343,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [InlineData(4, 0)] public static void Lanczos5WindowOscillatesCorrectly(float x, float expected) { - var sampler = Resamplers.Lanczos5; + var sampler = ResampleMode.Lanczos5; float result = sampler.GetValue(x); Assert.Equal(result, expected); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs index c092881c62..174aadf602 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs @@ -12,6 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Transforms; + using SixLabors.ImageSharp.Processing.Transforms.Resamplers; public class SkewTest : FileTestBase { @@ -25,21 +26,21 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms public static readonly List ResamplerNames = new List { - nameof(Resamplers.Bicubic), - nameof(Resamplers.Box), - nameof(Resamplers.CatmullRom), - nameof(Resamplers.Hermite), - nameof(Resamplers.Lanczos2), - nameof(Resamplers.Lanczos3), - nameof(Resamplers.Lanczos5), - nameof(Resamplers.Lanczos8), - nameof(Resamplers.MitchellNetravali), - nameof(Resamplers.NearestNeighbor), - nameof(Resamplers.Robidoux), - nameof(Resamplers.RobidouxSharp), - nameof(Resamplers.Spline), - nameof(Resamplers.Triangle), - nameof(Resamplers.Welch), + nameof(ResampleMode.Bicubic), + nameof(ResampleMode.Box), + nameof(ResampleMode.CatmullRom), + nameof(ResampleMode.Hermite), + nameof(ResampleMode.Lanczos2), + nameof(ResampleMode.Lanczos3), + nameof(ResampleMode.Lanczos5), + nameof(ResampleMode.Lanczos8), + nameof(ResampleMode.MitchellNetravali), + nameof(ResampleMode.NearestNeighbor), + nameof(ResampleMode.Robidoux), + nameof(ResampleMode.RobidouxSharp), + nameof(ResampleMode.Spline), + nameof(ResampleMode.Triangle), + nameof(ResampleMode.Welch), }; [Theory] @@ -72,7 +73,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms private static IResampler GetResampler(string name) { - PropertyInfo property = typeof(Resamplers).GetTypeInfo().GetProperty(name); + PropertyInfo property = typeof(ResampleMode).GetTypeInfo().GetProperty(name); if (property == null) { diff --git a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs index 85c35ba275..6637b97405 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs @@ -3,6 +3,7 @@ using System.Numerics; using System.Reflection; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; using Xunit; using Xunit.Abstractions; @@ -38,30 +39,30 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms public static readonly TheoryData ResamplerNames = new TheoryData { - nameof(Resamplers.Bicubic), - nameof(Resamplers.Box), - nameof(Resamplers.CatmullRom), - nameof(Resamplers.Hermite), - nameof(Resamplers.Lanczos2), - nameof(Resamplers.Lanczos3), - nameof(Resamplers.Lanczos5), - nameof(Resamplers.Lanczos8), - nameof(Resamplers.MitchellNetravali), - nameof(Resamplers.NearestNeighbor), - nameof(Resamplers.Robidoux), - nameof(Resamplers.RobidouxSharp), - nameof(Resamplers.Spline), - nameof(Resamplers.Triangle), - nameof(Resamplers.Welch), + nameof(ResampleMode.Bicubic), + nameof(ResampleMode.Box), + nameof(ResampleMode.CatmullRom), + nameof(ResampleMode.Hermite), + nameof(ResampleMode.Lanczos2), + nameof(ResampleMode.Lanczos3), + nameof(ResampleMode.Lanczos5), + nameof(ResampleMode.Lanczos8), + nameof(ResampleMode.MitchellNetravali), + nameof(ResampleMode.NearestNeighbor), + nameof(ResampleMode.Robidoux), + nameof(ResampleMode.RobidouxSharp), + nameof(ResampleMode.Spline), + nameof(ResampleMode.Triangle), + nameof(ResampleMode.Welch), }; public static readonly TheoryData Transform_DoesNotCreateEdgeArtifacts_ResamplerNames = new TheoryData { - nameof(Resamplers.NearestNeighbor), - nameof(Resamplers.Triangle), - nameof(Resamplers.Bicubic), - nameof(Resamplers.Lanczos8), + nameof(ResampleMode.NearestNeighbor), + nameof(ResampleMode.Triangle), + nameof(ResampleMode.Bicubic), + nameof(ResampleMode.Lanczos8), }; public AffineTransformTests(ITestOutputHelper output) @@ -113,7 +114,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms this.PrintMatrix(m); - image.Mutate(i => i.Transform(m, Resamplers.Bicubic)); + image.Mutate(i => i.Transform(m, ResampleMode.Bicubic)); string testOutputDetails = $"R({angleDeg})_S({sx},{sy})_T({tx},{ty})"; image.DebugSave(provider, testOutputDetails); @@ -130,7 +131,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { Matrix3x2 m = this.MakeManuallyCenteredMatrix(angleDeg, s, image); - image.Mutate(i => i.Transform(m, Resamplers.Bicubic)); + image.Mutate(i => i.Transform(m, ResampleMode.Bicubic)); string testOutputDetails = $"R({angleDeg})_S({s})"; image.DebugSave(provider, testOutputDetails); @@ -163,7 +164,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { var m = Matrix3x2.CreateScale(2.0F, 1.5F); - image.Mutate(i => i.Transform(m, Resamplers.Spline, rectangle)); + image.Mutate(i => i.Transform(m, ResampleMode.Spline, rectangle)); image.DebugSave(provider); image.CompareToReferenceOutput(provider); @@ -181,7 +182,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { var m = Matrix3x2.CreateScale(1.0F, 2.0F); - image.Mutate(i => i.Transform(m, Resamplers.Spline, rectangle)); + image.Mutate(i => i.Transform(m, ResampleMode.Spline, rectangle)); image.DebugSave(provider); image.CompareToReferenceOutput(provider); @@ -225,7 +226,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms private static IResampler GetResampler(string name) { - PropertyInfo property = typeof(Resamplers).GetTypeInfo().GetProperty(name); + PropertyInfo property = typeof(ResampleMode).GetTypeInfo().GetProperty(name); if (property == null) { diff --git a/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs index bb227496d8..46fc027126 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs @@ -1,9 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors; - +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Transforms @@ -18,7 +16,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 500; int height = 565; - IResampler sampler = Resamplers.NearestNeighbor; + IResampler sampler = ResampleMode.NearestNeighbor; this.operations.Pad(width, height); ResizeProcessor resizeProcessor = this.Verify>(); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs index b2170069f2..f9e09657cd 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.Processing.Transforms; using SixLabors.ImageSharp.Processing.Transforms.Processors; +using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; using Xunit; @@ -27,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 50; int height = 100; - IResampler sampler = Resamplers.Lanczos3; + IResampler sampler = ResampleMode.Lanczos3; this.operations.Resize(width, height, sampler); ResizeProcessor resizeProcessor = this.Verify>(); @@ -41,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 50; int height = 100; - IResampler sampler = Resamplers.Lanczos3; + IResampler sampler = ResampleMode.Lanczos3; bool compand = true; // ReSharper disable once ConditionIsAlwaysTrueOrFalse @@ -59,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int width = 50; int height = 100; - IResampler sampler = Resamplers.Lanczos3; + IResampler sampler = ResampleMode.Lanczos3; bool compand = true; ResizeMode mode = ResizeMode.Stretch; From 8bda02579f73540ca8743ab886e394320da30de2 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 10 Mar 2018 00:55:23 +1100 Subject: [PATCH 09/18] Refactor Image, ImageFrame + IImage --- .../Processors/DrawImageProcessor.cs | 1 - .../Advanced/AdvancedImageExtensions.cs | 2 +- src/ImageSharp/Advanced/IPixelSource.cs | 3 - .../Common/Decoder/JpegImagePostProcessor.cs | 3 +- src/ImageSharp/Helpers/ImageExtensions.cs | 61 ------------------- src/ImageSharp/IImage.cs | 26 ++++++++ .../{Image => }/IImageFrameCollection.cs | 0 src/ImageSharp/{Image => }/IImageInfo.cs | 0 src/ImageSharp/{Image => }/Image.Decode.cs | 0 src/ImageSharp/{Image => }/Image.FromBytes.cs | 0 src/ImageSharp/{Image => }/Image.FromFile.cs | 0 .../{Image => }/Image.FromStream.cs | 0 .../{Image => }/Image.LoadPixelData.cs | 0 src/ImageSharp/Image/IImage.cs | 14 ----- src/ImageSharp/{Image => }/ImageExtensions.cs | 0 .../{Image => }/ImageFrame.LoadPixelData.cs | 0 .../{Image => }/ImageFrameCollection.cs | 0 .../{Image => }/ImageFrame{TPixel}.cs | 18 ++++-- src/ImageSharp/{Image => }/ImageInfo.cs | 0 src/ImageSharp/{Image => }/Image{TPixel}.cs | 15 +++-- .../{Image => }/PixelAccessorExtensions.cs | 0 .../{Image => }/PixelAccessor{TPixel}.cs | 0 .../BinaryErrorDiffusionProcessor.cs | 1 - .../BinaryOrderedDitherProcessor.cs | 1 - .../Processors/BinaryThresholdProcessor.cs | 1 - .../Processors/Convolution2PassProcessor.cs | 3 +- .../Processors/ConvolutionProcessor.cs | 1 - .../DefaultInternalImageProcessorContext.cs | 6 +- .../ErrorDiffusionPaletteProcessor.cs | 1 - .../OrderedDitherPaletteProcessor.cs | 1 - .../Processors/OilPaintingProcessor.cs | 1 - .../Filters/Processors/FilterProcessor.cs | 1 - .../Overlays/Processors/GlowProcessor.cs | 1 - .../Overlays/Processors/VignetteProcessor.cs | 6 +- .../Processors/AffineTransformProcessor.cs | 1 - .../Transforms/Processors/FlipProcessor.cs | 1 - .../ProjectiveTransformProcessor.cs | 1 - .../Transforms/Processors/RotateProcessor.cs | 1 - src/ImageSharp/{Image => }/ReadOrigin.cs | 0 tests/ImageSharp.Benchmarks/Samplers/Glow.cs | 2 - .../ImageSharp.Tests/Drawing/DrawImageTest.cs | 1 - .../FakeImageOperationsProvider.cs | 1 - .../Formats/Jpg/GenericBlock8x8Tests.cs | 3 - .../Image/ImageRotationTests.cs | 1 - .../Processors/Transforms/ResizeTests.cs | 1 - .../Transforms/AffineTransformTests.cs | 1 - .../ImageComparison/ExactImageComparer.cs | 1 - .../ImageComparison/ImageComparer.cs | 1 - .../ImageComparison/TolerantImageComparer.cs | 1 - 49 files changed, 58 insertions(+), 126 deletions(-) delete mode 100644 src/ImageSharp/Helpers/ImageExtensions.cs create mode 100644 src/ImageSharp/IImage.cs rename src/ImageSharp/{Image => }/IImageFrameCollection.cs (100%) rename src/ImageSharp/{Image => }/IImageInfo.cs (100%) rename src/ImageSharp/{Image => }/Image.Decode.cs (100%) rename src/ImageSharp/{Image => }/Image.FromBytes.cs (100%) rename src/ImageSharp/{Image => }/Image.FromFile.cs (100%) rename src/ImageSharp/{Image => }/Image.FromStream.cs (100%) rename src/ImageSharp/{Image => }/Image.LoadPixelData.cs (100%) delete mode 100644 src/ImageSharp/Image/IImage.cs rename src/ImageSharp/{Image => }/ImageExtensions.cs (100%) rename src/ImageSharp/{Image => }/ImageFrame.LoadPixelData.cs (100%) rename src/ImageSharp/{Image => }/ImageFrameCollection.cs (100%) rename src/ImageSharp/{Image => }/ImageFrame{TPixel}.cs (94%) rename src/ImageSharp/{Image => }/ImageInfo.cs (100%) rename src/ImageSharp/{Image => }/Image{TPixel}.cs (94%) rename src/ImageSharp/{Image => }/PixelAccessorExtensions.cs (100%) rename src/ImageSharp/{Image => }/PixelAccessor{TPixel}.cs (100%) rename src/ImageSharp/{Image => }/ReadOrigin.cs (100%) diff --git a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs index dcf71bde02..53997b6184 100644 --- a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs @@ -4,7 +4,6 @@ using System; using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; diff --git a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs index 24d2dd4cc4..cbd8db748f 100644 --- a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs +++ b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs @@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Advanced /// /// Returns a reference to the 0th element of the Pixel buffer, /// allowing direct manipulation of pixel data through unsafe operations. - /// The pixel buffer is a contigous memory area containing Width*Height TPixel elements layed out in row-major order. + /// The pixel buffer is a contiguous memory area containing Width*Height TPixel elements laid out in row-major order. /// /// The Pixel format. /// The source image frame diff --git a/src/ImageSharp/Advanced/IPixelSource.cs b/src/ImageSharp/Advanced/IPixelSource.cs index c9edf118c6..a321e877ba 100644 --- a/src/ImageSharp/Advanced/IPixelSource.cs +++ b/src/ImageSharp/Advanced/IPixelSource.cs @@ -1,10 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.MetaData; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Advanced diff --git a/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegImagePostProcessor.cs b/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegImagePostProcessor.cs index 2adf3e02d0..483242c768 100644 --- a/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegImagePostProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegImagePostProcessor.cs @@ -2,7 +2,6 @@ using System; using System.Linq; using System.Numerics; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; @@ -116,7 +115,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder } /// - /// Execute one step rocessing pixel rows into 'destination'. + /// Execute one step processing pixel rows into 'destination'. /// /// The pixel type /// The destination image. diff --git a/src/ImageSharp/Helpers/ImageExtensions.cs b/src/ImageSharp/Helpers/ImageExtensions.cs deleted file mode 100644 index dbf2e34a42..0000000000 --- a/src/ImageSharp/Helpers/ImageExtensions.cs +++ /dev/null @@ -1,61 +0,0 @@ -// 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.Runtime.CompilerServices; -using System.Text; -using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Formats; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.Primitives; - -namespace SixLabors.ImageSharp.Helpers -{ - /// - /// Extension methods over Image{TPixel} - /// - public static partial class ImageExtensions - { - /// - /// Gets the bounds of the image. - /// - /// The Pixel format. - /// The source image - /// Returns the bounds of the image - public static Rectangle Bounds(this Image source) - where TPixel : struct, IPixel - => new Rectangle(0, 0, source.Width, source.Height); - - /// - /// Gets the bounds of the image. - /// - /// The Pixel format. - /// The source image - /// Returns the bounds of the image - public static Rectangle Bounds(this ImageFrame source) - where TPixel : struct, IPixel - => new Rectangle(0, 0, source.Width, source.Height); - - /// - /// Gets the size of the image. - /// - /// The Pixel format. - /// The source image - /// Returns the bounds of the image - public static Size Size(this Image source) - where TPixel : struct, IPixel - => new Size(source.Width, source.Height); - - /// - /// Gets the size of the image. - /// - /// The Pixel format. - /// The source image - /// Returns the bounds of the image - public static Size Size(this ImageFrame source) - where TPixel : struct, IPixel - => new Size(source.Width, source.Height); - } -} diff --git a/src/ImageSharp/IImage.cs b/src/ImageSharp/IImage.cs new file mode 100644 index 0000000000..4612daa2d4 --- /dev/null +++ b/src/ImageSharp/IImage.cs @@ -0,0 +1,26 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using System; +using SixLabors.Primitives; + +namespace SixLabors.ImageSharp +{ + /// + /// Encapsulates the properties and methods that describe an image. + /// + public interface IImage : IImageInfo, IDisposable + { + /// + /// Gets the size of the image. + /// + /// The + Size Size(); + + /// + /// Gets the bounds of the image. + /// + /// The + Rectangle Bounds(); + } +} \ No newline at end of file diff --git a/src/ImageSharp/Image/IImageFrameCollection.cs b/src/ImageSharp/IImageFrameCollection.cs similarity index 100% rename from src/ImageSharp/Image/IImageFrameCollection.cs rename to src/ImageSharp/IImageFrameCollection.cs diff --git a/src/ImageSharp/Image/IImageInfo.cs b/src/ImageSharp/IImageInfo.cs similarity index 100% rename from src/ImageSharp/Image/IImageInfo.cs rename to src/ImageSharp/IImageInfo.cs diff --git a/src/ImageSharp/Image/Image.Decode.cs b/src/ImageSharp/Image.Decode.cs similarity index 100% rename from src/ImageSharp/Image/Image.Decode.cs rename to src/ImageSharp/Image.Decode.cs diff --git a/src/ImageSharp/Image/Image.FromBytes.cs b/src/ImageSharp/Image.FromBytes.cs similarity index 100% rename from src/ImageSharp/Image/Image.FromBytes.cs rename to src/ImageSharp/Image.FromBytes.cs diff --git a/src/ImageSharp/Image/Image.FromFile.cs b/src/ImageSharp/Image.FromFile.cs similarity index 100% rename from src/ImageSharp/Image/Image.FromFile.cs rename to src/ImageSharp/Image.FromFile.cs diff --git a/src/ImageSharp/Image/Image.FromStream.cs b/src/ImageSharp/Image.FromStream.cs similarity index 100% rename from src/ImageSharp/Image/Image.FromStream.cs rename to src/ImageSharp/Image.FromStream.cs diff --git a/src/ImageSharp/Image/Image.LoadPixelData.cs b/src/ImageSharp/Image.LoadPixelData.cs similarity index 100% rename from src/ImageSharp/Image/Image.LoadPixelData.cs rename to src/ImageSharp/Image.LoadPixelData.cs diff --git a/src/ImageSharp/Image/IImage.cs b/src/ImageSharp/Image/IImage.cs deleted file mode 100644 index b9e2cee616..0000000000 --- a/src/ImageSharp/Image/IImage.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; - -namespace SixLabors.ImageSharp -{ - /// - /// Encapsulates the properties and methods that describe an image. - /// - public interface IImage : IImageInfo, IDisposable - { - } -} \ No newline at end of file diff --git a/src/ImageSharp/Image/ImageExtensions.cs b/src/ImageSharp/ImageExtensions.cs similarity index 100% rename from src/ImageSharp/Image/ImageExtensions.cs rename to src/ImageSharp/ImageExtensions.cs diff --git a/src/ImageSharp/Image/ImageFrame.LoadPixelData.cs b/src/ImageSharp/ImageFrame.LoadPixelData.cs similarity index 100% rename from src/ImageSharp/Image/ImageFrame.LoadPixelData.cs rename to src/ImageSharp/ImageFrame.LoadPixelData.cs diff --git a/src/ImageSharp/Image/ImageFrameCollection.cs b/src/ImageSharp/ImageFrameCollection.cs similarity index 100% rename from src/ImageSharp/Image/ImageFrameCollection.cs rename to src/ImageSharp/ImageFrameCollection.cs diff --git a/src/ImageSharp/Image/ImageFrame{TPixel}.cs b/src/ImageSharp/ImageFrame{TPixel}.cs similarity index 94% rename from src/ImageSharp/Image/ImageFrame{TPixel}.cs rename to src/ImageSharp/ImageFrame{TPixel}.cs index 833a22f7c7..888aff905e 100644 --- a/src/ImageSharp/Image/ImageFrame{TPixel}.cs +++ b/src/ImageSharp/ImageFrame{TPixel}.cs @@ -2,12 +2,10 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Diagnostics; using System.Numerics; using System.Runtime.CompilerServices; using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.MetaData; using SixLabors.ImageSharp.PixelFormats; @@ -104,7 +102,7 @@ namespace SixLabors.ImageSharp /// /// Gets the meta data of the frame. /// - public ImageFrameMetaData MetaData { get; private set; } + public ImageFrameMetaData MetaData { get; } /// /// Gets or sets the pixel at the specified position. @@ -127,6 +125,18 @@ namespace SixLabors.ImageSharp } } + /// + /// Gets the size of the frame. + /// + /// The + public Size Size() => new Size(this.Width, this.Height); + + /// + /// Gets the bounds of the frame. + /// + /// The + public Rectangle Bounds() => new Rectangle(0, 0, this.Width, this.Height); + /// /// Gets a reference to the pixel at the specified position. /// @@ -168,7 +178,7 @@ namespace SixLabors.ImageSharp { if (this.Size() != target.Size()) { - throw new ArgumentException("ImageFrame.CopyTo(): target must be of the same size!", nameof(target)); + throw new ArgumentException("ImageFrame.CopyTo(): target must be of the same size!", nameof(target)); } SpanHelper.Copy(this.GetPixelSpan(), target.Span); diff --git a/src/ImageSharp/Image/ImageInfo.cs b/src/ImageSharp/ImageInfo.cs similarity index 100% rename from src/ImageSharp/Image/ImageInfo.cs rename to src/ImageSharp/ImageInfo.cs diff --git a/src/ImageSharp/Image/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs similarity index 94% rename from src/ImageSharp/Image/Image{TPixel}.cs rename to src/ImageSharp/Image{TPixel}.cs index f264d8a59d..66ae13db89 100644 --- a/src/ImageSharp/Image/Image{TPixel}.cs +++ b/src/ImageSharp/Image{TPixel}.cs @@ -10,6 +10,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.MetaData; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.Primitives; namespace SixLabors.ImageSharp { @@ -20,8 +21,8 @@ namespace SixLabors.ImageSharp public sealed partial class Image : IImage, IConfigurable where TPixel : struct, IPixel { - private Configuration configuration; - private ImageFrameCollection frames; + private readonly Configuration configuration; + private readonly ImageFrameCollection frames; /// /// Initializes a new instance of the class @@ -44,7 +45,7 @@ namespace SixLabors.ImageSharp /// The width of the image in pixels. /// The height of the image in pixels. public Image(int width, int height) - : this(null, width, height) + : this(Configuration.Default, width, height) { } @@ -97,7 +98,7 @@ namespace SixLabors.ImageSharp public int Height => this.frames.RootFrame.Height; /// - public ImageMetaData MetaData { get; private set; } = new ImageMetaData(); + public ImageMetaData MetaData { get; } /// /// Gets the frames. @@ -122,6 +123,12 @@ namespace SixLabors.ImageSharp set => this.PixelSource.PixelBuffer[x, y] = value; } + /// + public Size Size() => new Size(this.Width, this.Height); + + /// + public Rectangle Bounds() => new Rectangle(0, 0, this.Width, this.Height); + /// /// Saves the image to the given stream using the given image encoder. /// diff --git a/src/ImageSharp/Image/PixelAccessorExtensions.cs b/src/ImageSharp/PixelAccessorExtensions.cs similarity index 100% rename from src/ImageSharp/Image/PixelAccessorExtensions.cs rename to src/ImageSharp/PixelAccessorExtensions.cs diff --git a/src/ImageSharp/Image/PixelAccessor{TPixel}.cs b/src/ImageSharp/PixelAccessor{TPixel}.cs similarity index 100% rename from src/ImageSharp/Image/PixelAccessor{TPixel}.cs rename to src/ImageSharp/PixelAccessor{TPixel}.cs diff --git a/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs index 74a3fdd869..6588bbe5b3 100644 --- a/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs @@ -3,7 +3,6 @@ using System; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; using SixLabors.ImageSharp.Processing.Processors; diff --git a/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs index 9f03144494..bd4b3660a1 100644 --- a/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs @@ -3,7 +3,6 @@ using System; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Dithering.Ordered; using SixLabors.ImageSharp.Processing.Processors; diff --git a/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs index 3c29194f6e..455c6ad8cd 100644 --- a/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs +++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryThresholdProcessor.cs @@ -4,7 +4,6 @@ using System; using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; diff --git a/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs index 0a3393315b..8f96546aeb 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs @@ -4,7 +4,6 @@ using System; using System.Numerics; using System.Threading.Tasks; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; @@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors /// The structure that specifies the portion of the image object to draw. /// /// The kernel operator. - /// The parellel options + /// The parallel options private void ApplyConvolution( Buffer2D targetPixels, Buffer2D sourcePixels, diff --git a/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs index ee7d93a03e..8f7a1caab7 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs @@ -5,7 +5,6 @@ using System; using System.Numerics; using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; diff --git a/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs b/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs index 05760bb04a..b71430e13e 100644 --- a/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs +++ b/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; @@ -81,9 +80,6 @@ namespace SixLabors.ImageSharp.Processing return this.ApplyProcessor(processor, this.GetCurrentBounds()); } - private Rectangle GetCurrentBounds() - { - return this.destination?.Bounds() ?? this.source.Bounds(); - } + private Rectangle GetCurrentBounds() => this.destination?.Bounds() ?? this.source.Bounds(); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs index 05eb5d0e3c..c90e91a6b6 100644 --- a/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs @@ -3,7 +3,6 @@ using System; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; using SixLabors.ImageSharp.Processing.Processors; diff --git a/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs index 713800cb11..ce9b7fb3ea 100644 --- a/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs @@ -3,7 +3,6 @@ using System; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Dithering.Ordered; using SixLabors.ImageSharp.Processing.Processors; diff --git a/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs b/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs index 2bf35d2201..9a6d93d1a3 100644 --- a/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs +++ b/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs @@ -5,7 +5,6 @@ using System; using System.Numerics; using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; diff --git a/src/ImageSharp/Processing/Filters/Processors/FilterProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/FilterProcessor.cs index 5267a36b43..18163b7548 100644 --- a/src/ImageSharp/Processing/Filters/Processors/FilterProcessor.cs +++ b/src/ImageSharp/Processing/Filters/Processors/FilterProcessor.cs @@ -5,7 +5,6 @@ using System; using System.Numerics; using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; diff --git a/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs index 22250cc185..5f9b8f5af9 100644 --- a/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs @@ -5,7 +5,6 @@ using System; using System.Numerics; using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; diff --git a/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs index 364eb0b794..961c0f9f07 100644 --- a/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs @@ -5,7 +5,6 @@ using System; using System.Numerics; using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; @@ -92,8 +91,9 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors TPixel vignetteColor = this.VignetteColor; Vector2 centre = Rectangle.Center(sourceRectangle); - float finalRadiusX = this.RadiusX.Calculate(source.Size()); - float finalRadiusY = this.RadiusY.Calculate(source.Size()); + Size sourceSize = source.Size(); + float finalRadiusX = this.RadiusX.Calculate(sourceSize); + float finalRadiusY = this.RadiusY.Calculate(sourceSize); float rX = finalRadiusX > 0 ? MathF.Min(finalRadiusX, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F; float rY = finalRadiusY > 0 ? MathF.Min(finalRadiusY, sourceRectangle.Height * .5F) : sourceRectangle.Height * .5F; float maxDistance = MathF.Sqrt((rX * rX) + (rY * rY)); diff --git a/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs index 3a58ed7873..b9f3dc4bf5 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Numerics; using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms.Resamplers; diff --git a/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs index 9d945a8695..4c6cb166bf 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs @@ -4,7 +4,6 @@ using System; using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; diff --git a/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs index 9f68ab6ca7..eb40c3f87f 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Numerics; using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms.Resamplers; diff --git a/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs index 6835fbb253..0cf42cbb72 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs @@ -4,7 +4,6 @@ using System; using System.Threading.Tasks; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.MetaData.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms.Resamplers; diff --git a/src/ImageSharp/Image/ReadOrigin.cs b/src/ImageSharp/ReadOrigin.cs similarity index 100% rename from src/ImageSharp/Image/ReadOrigin.cs rename to src/ImageSharp/ReadOrigin.cs diff --git a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs index 261241a693..51b1366490 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs @@ -10,14 +10,12 @@ namespace SixLabors.ImageSharp.Benchmarks using SixLabors.ImageSharp.PixelFormats; using CoreSize = SixLabors.Primitives.Size; - using SixLabors.ImageSharp.Processing; using System.Numerics; using System; using System.Threading.Tasks; using SixLabors.ImageSharp.Memory; using SixLabors.Primitives; - using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Processing.Overlays.Processors; using SixLabors.ImageSharp.Processing.Processors; diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs index 07f3aa5541..e36396a4e9 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs @@ -3,7 +3,6 @@ using System; using System.Numerics; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; diff --git a/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs b/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs index 294cbc0a17..cc2143afe1 100644 --- a/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs +++ b/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs index 193e26fcbd..31c95fae6c 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs @@ -2,12 +2,9 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { using System; - using System.Numerics; using SixLabors.ImageSharp.Formats.Jpeg.Common; - using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; - using SixLabors.Primitives; using Xunit; diff --git a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs index a18b8326ab..29c1cb871c 100644 --- a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Helpers; using SixLabors.Primitives; using Xunit; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs index 82abb90288..46e7b119e2 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. using System; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Transforms.Resamplers; diff --git a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs index 6637b97405..02144e0735 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs @@ -7,7 +7,6 @@ using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using SixLabors.Primitives; using Xunit; using Xunit.Abstractions; -using SixLabors.ImageSharp.Helpers; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Processing.Transforms diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs index dbe2523661..32ff87be63 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs @@ -3,7 +3,6 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison using System; using System.Collections.Generic; using SixLabors.ImageSharp.Advanced; - using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs index 920e633795..ca7d7c6a86 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs index e68a1fbfea..52ea7e45d7 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs @@ -5,7 +5,6 @@ using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Advanced; - using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; From 4573913520946a11e20c18c9489b144b0a020057 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 10 Mar 2018 01:31:29 +1100 Subject: [PATCH 10/18] Move drawing files into structured folders --- .../{ => Drawing}/Brushes/Brushes.cs | 0 .../{ => Drawing}/Brushes/IBrush.cs | 0 .../Brushes/ImageBrush{TPixel}.cs | 5 +---- .../Brushes/PatternBrush{TPixel}.cs | 0 .../Brushes/Processors/BrushApplicator.cs | 10 ++++----- .../Brushes/RecolorBrush{TPixel}.cs | 21 +++++++------------ .../Brushes/SolidBrush{TPixel}.cs | 3 +-- .../{ => Drawing}/Pens/IPen.cs | 0 .../{ => Drawing}/Pens/Pens.cs | 0 .../{ => Drawing}/Pens/Pen{TPixel}.cs | 2 +- .../ImageSharp.Drawing.csproj | 2 +- .../{ => Primitives}/Region.cs | 3 +-- .../{ => Processing/Overlays}/DrawImage.cs | 0 .../{ => Processing/Overlays}/FillRegion.cs | 1 + .../Processors/DrawImageProcessor.cs | 0 .../Overlays}/Processors/FillProcessor.cs | 0 .../Processors/FillRegionProcessor.cs | 1 + .../Paths/DrawBezierExtensions.cs} | 4 ++-- .../{ => Processing}/Paths/DrawLines.cs | 0 .../{ => Processing}/Paths/DrawPath.cs | 0 .../Paths/DrawPathCollection.cs | 0 .../{ => Processing}/Paths/DrawPolygon.cs | 0 .../{ => Processing}/Paths/DrawRectangle.cs | 0 .../{ => Processing}/Paths/FillPathBuilder.cs | 0 .../Paths/FillPathCollection.cs | 0 .../{ => Processing}/Paths/FillPaths.cs | 0 .../{ => Processing}/Paths/FillPolygon.cs | 0 .../{ => Processing}/Paths/FillRectangle.cs | 0 .../{ => Processing}/Paths/ShapePath.cs | 0 .../{ => Processing}/Paths/ShapeRegion.cs | 7 +++---- .../{ => Processing}/Text/DrawText.Path.cs | 0 .../{ => Processing}/Text/DrawText.cs | 0 .../Text/TextGraphicsOptions.cs | 0 33 files changed, 24 insertions(+), 35 deletions(-) rename src/ImageSharp.Drawing/{ => Drawing}/Brushes/Brushes.cs (100%) rename src/ImageSharp.Drawing/{ => Drawing}/Brushes/IBrush.cs (100%) rename src/ImageSharp.Drawing/{ => Drawing}/Brushes/ImageBrush{TPixel}.cs (97%) rename src/ImageSharp.Drawing/{ => Drawing}/Brushes/PatternBrush{TPixel}.cs (100%) rename src/ImageSharp.Drawing/{ => Drawing}/Brushes/Processors/BrushApplicator.cs (93%) rename src/ImageSharp.Drawing/{ => Drawing}/Brushes/RecolorBrush{TPixel}.cs (90%) rename src/ImageSharp.Drawing/{ => Drawing}/Brushes/SolidBrush{TPixel}.cs (98%) rename src/ImageSharp.Drawing/{ => Drawing}/Pens/IPen.cs (100%) rename src/ImageSharp.Drawing/{ => Drawing}/Pens/Pens.cs (100%) rename src/ImageSharp.Drawing/{ => Drawing}/Pens/Pen{TPixel}.cs (98%) rename src/ImageSharp.Drawing/{ => Primitives}/Region.cs (95%) rename src/ImageSharp.Drawing/{ => Processing/Overlays}/DrawImage.cs (100%) rename src/ImageSharp.Drawing/{ => Processing/Overlays}/FillRegion.cs (99%) rename src/ImageSharp.Drawing/{ => Processing/Overlays}/Processors/DrawImageProcessor.cs (100%) rename src/ImageSharp.Drawing/{ => Processing/Overlays}/Processors/FillProcessor.cs (100%) rename src/ImageSharp.Drawing/{ => Processing/Overlays}/Processors/FillRegionProcessor.cs (99%) rename src/ImageSharp.Drawing/{Paths/DrawBeziers.cs => Processing/Paths/DrawBezierExtensions.cs} (97%) rename src/ImageSharp.Drawing/{ => Processing}/Paths/DrawLines.cs (100%) rename src/ImageSharp.Drawing/{ => Processing}/Paths/DrawPath.cs (100%) rename src/ImageSharp.Drawing/{ => Processing}/Paths/DrawPathCollection.cs (100%) rename src/ImageSharp.Drawing/{ => Processing}/Paths/DrawPolygon.cs (100%) rename src/ImageSharp.Drawing/{ => Processing}/Paths/DrawRectangle.cs (100%) rename src/ImageSharp.Drawing/{ => Processing}/Paths/FillPathBuilder.cs (100%) rename src/ImageSharp.Drawing/{ => Processing}/Paths/FillPathCollection.cs (100%) rename src/ImageSharp.Drawing/{ => Processing}/Paths/FillPaths.cs (100%) rename src/ImageSharp.Drawing/{ => Processing}/Paths/FillPolygon.cs (100%) rename src/ImageSharp.Drawing/{ => Processing}/Paths/FillRectangle.cs (100%) rename src/ImageSharp.Drawing/{ => Processing}/Paths/ShapePath.cs (100%) rename src/ImageSharp.Drawing/{ => Processing}/Paths/ShapeRegion.cs (92%) rename src/ImageSharp.Drawing/{ => Processing}/Text/DrawText.Path.cs (100%) rename src/ImageSharp.Drawing/{ => Processing}/Text/DrawText.cs (100%) rename src/ImageSharp.Drawing/{ => Processing}/Text/TextGraphicsOptions.cs (100%) diff --git a/src/ImageSharp.Drawing/Brushes/Brushes.cs b/src/ImageSharp.Drawing/Drawing/Brushes/Brushes.cs similarity index 100% rename from src/ImageSharp.Drawing/Brushes/Brushes.cs rename to src/ImageSharp.Drawing/Drawing/Brushes/Brushes.cs diff --git a/src/ImageSharp.Drawing/Brushes/IBrush.cs b/src/ImageSharp.Drawing/Drawing/Brushes/IBrush.cs similarity index 100% rename from src/ImageSharp.Drawing/Brushes/IBrush.cs rename to src/ImageSharp.Drawing/Drawing/Brushes/IBrush.cs diff --git a/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs b/src/ImageSharp.Drawing/Drawing/Brushes/ImageBrush{TPixel}.cs similarity index 97% rename from src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs rename to src/ImageSharp.Drawing/Drawing/Brushes/ImageBrush{TPixel}.cs index 320c94c96b..91965e62ea 100644 --- a/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Drawing/Brushes/ImageBrush{TPixel}.cs @@ -4,7 +4,6 @@ using System; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Drawing.Brushes.Processors; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; @@ -43,9 +42,7 @@ namespace SixLabors.ImageSharp.Drawing.Brushes /// public BrushApplicator CreateApplicator(ImageFrame source, RectangleF region, GraphicsOptions options) - { - return new ImageBrushApplicator(source, this.image, region, options); - } + => new ImageBrushApplicator(source, this.image, region, options); /// /// The image brush applicator. diff --git a/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs b/src/ImageSharp.Drawing/Drawing/Brushes/PatternBrush{TPixel}.cs similarity index 100% rename from src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs rename to src/ImageSharp.Drawing/Drawing/Brushes/PatternBrush{TPixel}.cs diff --git a/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs b/src/ImageSharp.Drawing/Drawing/Brushes/Processors/BrushApplicator.cs similarity index 93% rename from src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs rename to src/ImageSharp.Drawing/Drawing/Brushes/Processors/BrushApplicator.cs index d8ea435586..78b394bf22 100644 --- a/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs +++ b/src/ImageSharp.Drawing/Drawing/Brushes/Processors/BrushApplicator.cs @@ -31,12 +31,12 @@ namespace SixLabors.ImageSharp.Drawing.Brushes.Processors } /// - /// Gets the blendder + /// Gets the blender /// internal PixelBlender Blender { get; } /// - /// Gets the destinaion + /// Gets the destination /// protected ImageFrame Target { get; } @@ -48,8 +48,8 @@ namespace SixLabors.ImageSharp.Drawing.Brushes.Processors /// /// Gets the color for a single pixel. /// - /// The x cordinate. - /// The y cordinate. + /// The x coordinate. + /// The y coordinate. /// The a that should be applied to the pixel. internal abstract TPixel this[int x, int y] { get; } @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Drawing.Brushes.Processors public abstract void Dispose(); /// - /// Applies the opactiy weighting for each pixel in a scanline to the target based on the pattern contained in the brush. + /// Applies the opacity weighting for each pixel in a scanline to the target based on the pattern contained in the brush. /// /// The a collection of opacity values between 0 and 1 to be merged with the brushed color value before being applied to the target. /// The x position in the target pixel space that the start of the scanline data corresponds to. diff --git a/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs b/src/ImageSharp.Drawing/Drawing/Brushes/RecolorBrush{TPixel}.cs similarity index 90% rename from src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs rename to src/ImageSharp.Drawing/Drawing/Brushes/RecolorBrush{TPixel}.cs index 39afd965c8..ac2588038f 100644 --- a/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Drawing/Brushes/RecolorBrush{TPixel}.cs @@ -5,7 +5,6 @@ using System; using System.Numerics; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Drawing.Brushes.Processors; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; @@ -23,21 +22,18 @@ namespace SixLabors.ImageSharp.Drawing.Brushes /// Initializes a new instance of the class. /// /// Color of the source. - /// Color of the target. + /// Color of the target. /// The threshold as a value between 0 and 1. - public RecolorBrush(TPixel sourceColor, TPixel targeTPixel, float threshold) + public RecolorBrush(TPixel sourceColor, TPixel targetColor, float threshold) { this.SourceColor = sourceColor; this.Threshold = threshold; - this.TargeTPixel = targeTPixel; + this.TargetColor = targetColor; } /// /// Gets the threshold. /// - /// - /// The threshold. - /// public float Threshold { get; } /// @@ -51,15 +47,12 @@ namespace SixLabors.ImageSharp.Drawing.Brushes /// /// Gets the target color. /// - /// - /// The color of the target. - /// - public TPixel TargeTPixel { get; } + public TPixel TargetColor { get; } /// public BrushApplicator CreateApplicator(ImageFrame source, RectangleF region, GraphicsOptions options) { - return new RecolorBrushApplicator(source, this.SourceColor, this.TargeTPixel, this.Threshold, options); + return new RecolorBrushApplicator(source, this.SourceColor, this.TargetColor, this.Threshold, options); } /// @@ -158,8 +151,8 @@ namespace SixLabors.ImageSharp.Drawing.Brushes int offsetX = x + i; - // no doubt this one can be optermised further but I can't imagine its - // actually being used and can probably be removed/interalised for now + // No doubt this one can be optimized further but I can't imagine its + // actually being used and can probably be removed/internalized for now overlaySpan[i] = this[offsetX, y]; } diff --git a/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs b/src/ImageSharp.Drawing/Drawing/Brushes/SolidBrush{TPixel}.cs similarity index 98% rename from src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs rename to src/ImageSharp.Drawing/Drawing/Brushes/SolidBrush{TPixel}.cs index 9630c707ef..3aff3aea15 100644 --- a/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Drawing/Brushes/SolidBrush{TPixel}.cs @@ -2,10 +2,9 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Numerics; + using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Drawing.Brushes.Processors; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; diff --git a/src/ImageSharp.Drawing/Pens/IPen.cs b/src/ImageSharp.Drawing/Drawing/Pens/IPen.cs similarity index 100% rename from src/ImageSharp.Drawing/Pens/IPen.cs rename to src/ImageSharp.Drawing/Drawing/Pens/IPen.cs diff --git a/src/ImageSharp.Drawing/Pens/Pens.cs b/src/ImageSharp.Drawing/Drawing/Pens/Pens.cs similarity index 100% rename from src/ImageSharp.Drawing/Pens/Pens.cs rename to src/ImageSharp.Drawing/Drawing/Pens/Pens.cs diff --git a/src/ImageSharp.Drawing/Pens/Pen{TPixel}.cs b/src/ImageSharp.Drawing/Drawing/Pens/Pen{TPixel}.cs similarity index 98% rename from src/ImageSharp.Drawing/Pens/Pen{TPixel}.cs rename to src/ImageSharp.Drawing/Drawing/Pens/Pen{TPixel}.cs index 74e4c6596d..d2748e1112 100644 --- a/src/ImageSharp.Drawing/Pens/Pen{TPixel}.cs +++ b/src/ImageSharp.Drawing/Drawing/Pens/Pen{TPixel}.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Drawing.Pens /// section 1 will be width long (making a square) and will be filled by the brush /// section 2 will be width * 2 long and will be empty /// section 3 will be width/2 long and will be filled - /// the the pattern will imidiatly repeat without gap. + /// the the pattern will immediately repeat without gap. /// public class Pen : IPen where TPixel : struct, IPixel diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index 3e320dccc7..2c4a286d63 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -46,7 +46,7 @@ ..\..\ImageSharp.ruleset - SixLabors.ImageSharp.Drawing + SixLabors.ImageSharp true diff --git a/src/ImageSharp.Drawing/Region.cs b/src/ImageSharp.Drawing/Primitives/Region.cs similarity index 95% rename from src/ImageSharp.Drawing/Region.cs rename to src/ImageSharp.Drawing/Primitives/Region.cs index c5e7c1cfd4..c85e373fb3 100644 --- a/src/ImageSharp.Drawing/Region.cs +++ b/src/ImageSharp.Drawing/Primitives/Region.cs @@ -1,10 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Drawing +namespace SixLabors.ImageSharp.Primitives { /// /// Represents a region of an image. diff --git a/src/ImageSharp.Drawing/DrawImage.cs b/src/ImageSharp.Drawing/Processing/Overlays/DrawImage.cs similarity index 100% rename from src/ImageSharp.Drawing/DrawImage.cs rename to src/ImageSharp.Drawing/Processing/Overlays/DrawImage.cs diff --git a/src/ImageSharp.Drawing/FillRegion.cs b/src/ImageSharp.Drawing/Processing/Overlays/FillRegion.cs similarity index 99% rename from src/ImageSharp.Drawing/FillRegion.cs rename to src/ImageSharp.Drawing/Processing/Overlays/FillRegion.cs index 343225ab09..b9fb8650a7 100644 --- a/src/ImageSharp.Drawing/FillRegion.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/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.Primitives; using SixLabors.ImageSharp.Processing; namespace SixLabors.ImageSharp diff --git a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processing/Overlays/Processors/DrawImageProcessor.cs similarity index 100% rename from src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs rename to src/ImageSharp.Drawing/Processing/Overlays/Processors/DrawImageProcessor.cs diff --git a/src/ImageSharp.Drawing/Processors/FillProcessor.cs b/src/ImageSharp.Drawing/Processing/Overlays/Processors/FillProcessor.cs similarity index 100% rename from src/ImageSharp.Drawing/Processors/FillProcessor.cs rename to src/ImageSharp.Drawing/Processing/Overlays/Processors/FillProcessor.cs diff --git a/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs b/src/ImageSharp.Drawing/Processing/Overlays/Processors/FillRegionProcessor.cs similarity index 99% rename from src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs rename to src/ImageSharp.Drawing/Processing/Overlays/Processors/FillRegionProcessor.cs index 40db43a02a..dfd66d7fc5 100644 --- a/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/Processors/FillRegionProcessor.cs @@ -7,6 +7,7 @@ using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Brushes.Processors; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; diff --git a/src/ImageSharp.Drawing/Paths/DrawBeziers.cs b/src/ImageSharp.Drawing/Processing/Paths/DrawBezierExtensions.cs similarity index 97% rename from src/ImageSharp.Drawing/Paths/DrawBeziers.cs rename to src/ImageSharp.Drawing/Processing/Paths/DrawBezierExtensions.cs index 268a8c3c52..7476f3a75a 100644 --- a/src/ImageSharp.Drawing/Paths/DrawBeziers.cs +++ b/src/ImageSharp.Drawing/Processing/Paths/DrawBezierExtensions.cs @@ -13,9 +13,9 @@ using SixLabors.Shapes; namespace SixLabors.ImageSharp { /// - /// Extension methods for the type. + /// EAdds extensions that allow the drawing of Bezier paths to the type. /// - public static partial class ImageExtensions + public static class DrawBezierExtensions { /// /// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush diff --git a/src/ImageSharp.Drawing/Paths/DrawLines.cs b/src/ImageSharp.Drawing/Processing/Paths/DrawLines.cs similarity index 100% rename from src/ImageSharp.Drawing/Paths/DrawLines.cs rename to src/ImageSharp.Drawing/Processing/Paths/DrawLines.cs diff --git a/src/ImageSharp.Drawing/Paths/DrawPath.cs b/src/ImageSharp.Drawing/Processing/Paths/DrawPath.cs similarity index 100% rename from src/ImageSharp.Drawing/Paths/DrawPath.cs rename to src/ImageSharp.Drawing/Processing/Paths/DrawPath.cs diff --git a/src/ImageSharp.Drawing/Paths/DrawPathCollection.cs b/src/ImageSharp.Drawing/Processing/Paths/DrawPathCollection.cs similarity index 100% rename from src/ImageSharp.Drawing/Paths/DrawPathCollection.cs rename to src/ImageSharp.Drawing/Processing/Paths/DrawPathCollection.cs diff --git a/src/ImageSharp.Drawing/Paths/DrawPolygon.cs b/src/ImageSharp.Drawing/Processing/Paths/DrawPolygon.cs similarity index 100% rename from src/ImageSharp.Drawing/Paths/DrawPolygon.cs rename to src/ImageSharp.Drawing/Processing/Paths/DrawPolygon.cs diff --git a/src/ImageSharp.Drawing/Paths/DrawRectangle.cs b/src/ImageSharp.Drawing/Processing/Paths/DrawRectangle.cs similarity index 100% rename from src/ImageSharp.Drawing/Paths/DrawRectangle.cs rename to src/ImageSharp.Drawing/Processing/Paths/DrawRectangle.cs diff --git a/src/ImageSharp.Drawing/Paths/FillPathBuilder.cs b/src/ImageSharp.Drawing/Processing/Paths/FillPathBuilder.cs similarity index 100% rename from src/ImageSharp.Drawing/Paths/FillPathBuilder.cs rename to src/ImageSharp.Drawing/Processing/Paths/FillPathBuilder.cs diff --git a/src/ImageSharp.Drawing/Paths/FillPathCollection.cs b/src/ImageSharp.Drawing/Processing/Paths/FillPathCollection.cs similarity index 100% rename from src/ImageSharp.Drawing/Paths/FillPathCollection.cs rename to src/ImageSharp.Drawing/Processing/Paths/FillPathCollection.cs diff --git a/src/ImageSharp.Drawing/Paths/FillPaths.cs b/src/ImageSharp.Drawing/Processing/Paths/FillPaths.cs similarity index 100% rename from src/ImageSharp.Drawing/Paths/FillPaths.cs rename to src/ImageSharp.Drawing/Processing/Paths/FillPaths.cs diff --git a/src/ImageSharp.Drawing/Paths/FillPolygon.cs b/src/ImageSharp.Drawing/Processing/Paths/FillPolygon.cs similarity index 100% rename from src/ImageSharp.Drawing/Paths/FillPolygon.cs rename to src/ImageSharp.Drawing/Processing/Paths/FillPolygon.cs diff --git a/src/ImageSharp.Drawing/Paths/FillRectangle.cs b/src/ImageSharp.Drawing/Processing/Paths/FillRectangle.cs similarity index 100% rename from src/ImageSharp.Drawing/Paths/FillRectangle.cs rename to src/ImageSharp.Drawing/Processing/Paths/FillRectangle.cs diff --git a/src/ImageSharp.Drawing/Paths/ShapePath.cs b/src/ImageSharp.Drawing/Processing/Paths/ShapePath.cs similarity index 100% rename from src/ImageSharp.Drawing/Paths/ShapePath.cs rename to src/ImageSharp.Drawing/Processing/Paths/ShapePath.cs diff --git a/src/ImageSharp.Drawing/Paths/ShapeRegion.cs b/src/ImageSharp.Drawing/Processing/Paths/ShapeRegion.cs similarity index 92% rename from src/ImageSharp.Drawing/Paths/ShapeRegion.cs rename to src/ImageSharp.Drawing/Processing/Paths/ShapeRegion.cs index cc27f7fbb8..9e1f1bc35d 100644 --- a/src/ImageSharp.Drawing/Paths/ShapeRegion.cs +++ b/src/ImageSharp.Drawing/Processing/Paths/ShapeRegion.cs @@ -2,9 +2,8 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Buffers; -using System.Numerics; -using SixLabors.ImageSharp.Memory; + +using SixLabors.ImageSharp.Primitives; using SixLabors.Primitives; using SixLabors.Shapes; @@ -48,7 +47,7 @@ namespace SixLabors.ImageSharp.Drawing var end = new PointF(this.Bounds.Right + 1, y); // TODO: This is a temporary workaround because of the lack of Span API-s on IPath. We should use MemoryManager.Allocate() here! - PointF[] innerBuffer = new PointF[buffer.Length]; + var innerBuffer = new PointF[buffer.Length]; int count = this.Shape.FindIntersections(start, end, innerBuffer, 0); for (int i = 0; i < count; i++) diff --git a/src/ImageSharp.Drawing/Text/DrawText.Path.cs b/src/ImageSharp.Drawing/Processing/Text/DrawText.Path.cs similarity index 100% rename from src/ImageSharp.Drawing/Text/DrawText.Path.cs rename to src/ImageSharp.Drawing/Processing/Text/DrawText.Path.cs diff --git a/src/ImageSharp.Drawing/Text/DrawText.cs b/src/ImageSharp.Drawing/Processing/Text/DrawText.cs similarity index 100% rename from src/ImageSharp.Drawing/Text/DrawText.cs rename to src/ImageSharp.Drawing/Processing/Text/DrawText.cs diff --git a/src/ImageSharp.Drawing/Text/TextGraphicsOptions.cs b/src/ImageSharp.Drawing/Processing/Text/TextGraphicsOptions.cs similarity index 100% rename from src/ImageSharp.Drawing/Text/TextGraphicsOptions.cs rename to src/ImageSharp.Drawing/Processing/Text/TextGraphicsOptions.cs From 563077d87d16238f191d04780134c9db58a2dbcd Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 11 Mar 2018 00:26:43 +1100 Subject: [PATCH 11/18] Combine drawing methods to new Overlays namespace. --- .../Drawing/Brushes/IBrush.cs | 1 - .../Drawing/Brushes/RecolorBrush{TPixel}.cs | 2 +- .../Drawing/Brushes/SolidBrush{TPixel}.cs | 1 - src/ImageSharp.Drawing/Drawing/Pens/IPen.cs | 6 +- src/ImageSharp.Drawing/Drawing/Pens/Pens.cs | 11 +-- .../Drawing/Pens/Pen{TPixel}.cs | 13 ++- .../Paths => Primitives}/ShapePath.cs | 13 +-- .../Paths => Primitives}/ShapeRegion.cs | 4 +- .../DrawBezierExtensions.cs | 55 +++++------- .../{DrawImage.cs => DrawImageExtensions.cs} | 66 +++++--------- .../DrawLineExtensions.cs} | 45 ++++------ .../DrawPathCollectionExtensions.cs} | 40 +++------ .../DrawPathExtensions.cs} | 45 ++++------ .../DrawPolygonExtensions.cs} | 47 ++++------ .../DrawRectangleExtensions.cs} | 59 +++++-------- .../FillPathBuilderExtensions.cs} | 35 +++----- .../FillPathCollectionExtensions.cs} | 34 +++---- .../FillPathExtensions.cs} | 35 +++----- .../FillPolygonExtensions.cs} | 36 +++----- .../FillRectangleExtensions.cs} | 37 +++----- ...{FillRegion.cs => FillRegionExtensions.cs} | 88 ++++++++----------- .../Overlays/Processors/DrawImageProcessor.cs | 70 +++++++++++++-- ...ext.Path.cs => DrawTextExtensions.Path.cs} | 54 ++++-------- .../{DrawText.cs => DrawTextExtensions.cs} | 56 +++++------- .../Processing/Text/TextGraphicsOptions.cs | 7 +- src/ImageSharp/Formats/Jpeg/JpegEncoder.cs | 1 + src/ImageSharp/Primitives/ValueSize.cs | 4 +- .../Processors/BackgroundColorProcessor.cs | 6 +- .../Overlays/Processors/GlowProcessor.cs | 23 +++-- .../Overlays/Processors/VignetteProcessor.cs | 4 +- .../Drawing/DrawBeziers.cs | 17 ++-- .../Drawing/DrawLines.cs | 2 + .../Drawing/DrawPolygon.cs | 17 ++-- .../Drawing/FillPolygon.cs | 22 +++-- .../Drawing/FillRectangle.cs | 19 ++-- .../Drawing/FillWithPattern.cs | 2 + .../ImageSharp.Tests/Drawing/BeziersTests.cs | 15 +--- .../ImageSharp.Tests/Drawing/BlendedShapes.cs | 12 +-- .../ImageSharp.Tests/Drawing/DrawImageTest.cs | 1 + .../ImageSharp.Tests/Drawing/DrawPathTests.cs | 12 +-- .../Drawing/FillPatternTests.cs | 2 + .../Drawing/FillRegionProcessorTests.cs | 6 +- .../Drawing/LineComplexPolygonTests.cs | 5 +- tests/ImageSharp.Tests/Drawing/LineTests.cs | 5 +- .../Drawing/Paths/FillPath.cs | 26 +++--- .../Drawing/Paths/FillPathCollection.cs | 24 ++--- .../Drawing/Paths/FillPolygon.cs | 29 +++--- .../Drawing/Paths/FillRectangle.cs | 7 +- .../Drawing/Paths/ShapeRegionTests.cs | 2 + .../ImageSharp.Tests/Drawing/PolygonTests.cs | 11 +-- .../Drawing/RecolorImageTest.cs | 4 +- .../Drawing/SolidBezierTests.cs | 5 +- .../Drawing/SolidComplexPolygonTests.cs | 5 +- .../Drawing/SolidPolygonTests.cs | 7 +- .../Drawing/Text/DrawText.Path.cs | 1 + .../ImageSharp.Tests/Drawing/Text/DrawText.cs | 3 +- .../Drawing/Text/OutputText.cs | 2 + .../Drawing/Text/TextGraphicsOptionsTests.cs | 2 + tests/ImageSharp.Tests/Issues/Issue412.cs | 10 +-- .../Processing/Effects/BackgroundColorTest.cs | 11 +-- .../ImageProviders/SolidProvider.cs | 1 + 61 files changed, 506 insertions(+), 679 deletions(-) rename src/ImageSharp.Drawing/{Processing/Paths => Primitives}/ShapePath.cs (68%) rename src/ImageSharp.Drawing/{Processing/Paths => Primitives}/ShapeRegion.cs (95%) rename src/ImageSharp.Drawing/Processing/{Paths => Overlays}/DrawBezierExtensions.cs (72%) rename src/ImageSharp.Drawing/Processing/Overlays/{DrawImage.cs => DrawImageExtensions.cs} (78%) rename src/ImageSharp.Drawing/Processing/{Paths/DrawLines.cs => Overlays/DrawLineExtensions.cs} (78%) rename src/ImageSharp.Drawing/Processing/{Paths/DrawPathCollection.cs => Overlays/DrawPathCollectionExtensions.cs} (82%) rename src/ImageSharp.Drawing/Processing/{Paths/DrawPath.cs => Overlays/DrawPathExtensions.cs} (79%) rename src/ImageSharp.Drawing/Processing/{Paths/DrawPolygon.cs => Overlays/DrawPolygonExtensions.cs} (78%) rename src/ImageSharp.Drawing/Processing/{Paths/DrawRectangle.cs => Overlays/DrawRectangleExtensions.cs} (69%) rename src/ImageSharp.Drawing/Processing/{Paths/FillPathBuilder.cs => Overlays/FillPathBuilderExtensions.cs} (79%) rename src/ImageSharp.Drawing/Processing/{Paths/FillPathCollection.cs => Overlays/FillPathCollectionExtensions.cs} (79%) rename src/ImageSharp.Drawing/Processing/{Paths/FillPaths.cs => Overlays/FillPathExtensions.cs} (77%) rename src/ImageSharp.Drawing/Processing/{Paths/FillPolygon.cs => Overlays/FillPolygonExtensions.cs} (75%) rename src/ImageSharp.Drawing/Processing/{Paths/FillRectangle.cs => Overlays/FillRectangleExtensions.cs} (69%) rename src/ImageSharp.Drawing/Processing/Overlays/{FillRegion.cs => FillRegionExtensions.cs} (80%) rename src/ImageSharp.Drawing/Processing/Text/{DrawText.Path.cs => DrawTextExtensions.Path.cs} (84%) rename src/ImageSharp.Drawing/Processing/Text/{DrawText.cs => DrawTextExtensions.cs} (83%) diff --git a/src/ImageSharp.Drawing/Drawing/Brushes/IBrush.cs b/src/ImageSharp.Drawing/Drawing/Brushes/IBrush.cs index bb907281b0..41d9081ebe 100644 --- a/src/ImageSharp.Drawing/Drawing/Brushes/IBrush.cs +++ b/src/ImageSharp.Drawing/Drawing/Brushes/IBrush.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Drawing.Brushes.Processors; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; diff --git a/src/ImageSharp.Drawing/Drawing/Brushes/RecolorBrush{TPixel}.cs b/src/ImageSharp.Drawing/Drawing/Brushes/RecolorBrush{TPixel}.cs index ac2588038f..4cef8cc83a 100644 --- a/src/ImageSharp.Drawing/Drawing/Brushes/RecolorBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Drawing/Brushes/RecolorBrush{TPixel}.cs @@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.Drawing.Brushes this.targetColor = targetColor.ToVector4(); this.targetColorPixel = targetColor; - // Lets hack a min max extreams for a color space by letting the IPackedPixel clamp our values to something in the correct spaces :) + // Lets hack a min max extremes for a color space by letting the IPackedPixel clamp our values to something in the correct spaces :) var maxColor = default(TPixel); maxColor.PackFromVector4(new Vector4(float.MaxValue)); var minColor = default(TPixel); diff --git a/src/ImageSharp.Drawing/Drawing/Brushes/SolidBrush{TPixel}.cs b/src/ImageSharp.Drawing/Drawing/Brushes/SolidBrush{TPixel}.cs index 3aff3aea15..1511ce86c6 100644 --- a/src/ImageSharp.Drawing/Drawing/Brushes/SolidBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Drawing/Brushes/SolidBrush{TPixel}.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. using System; - using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Drawing.Brushes.Processors; using SixLabors.ImageSharp.Memory; diff --git a/src/ImageSharp.Drawing/Drawing/Pens/IPen.cs b/src/ImageSharp.Drawing/Drawing/Pens/IPen.cs index 0680ec2f56..ed7de14610 100644 --- a/src/ImageSharp.Drawing/Drawing/Pens/IPen.cs +++ b/src/ImageSharp.Drawing/Drawing/Pens/IPen.cs @@ -1,8 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using System; using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Drawing.Pens @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Drawing.Pens } /// - /// Iterface represting the pattern and size of the stroke to apply with a Pen. + /// Interface representing the pattern and size of the stroke to apply with a Pen. /// public interface IPen { @@ -33,6 +33,6 @@ namespace SixLabors.ImageSharp.Drawing.Pens /// /// Gets the stoke pattern. /// - System.ReadOnlySpan StrokePattern { get; } + ReadOnlySpan StrokePattern { get; } } } diff --git a/src/ImageSharp.Drawing/Drawing/Pens/Pens.cs b/src/ImageSharp.Drawing/Drawing/Pens/Pens.cs index 6478b1b813..4eb2d5d204 100644 --- a/src/ImageSharp.Drawing/Drawing/Pens/Pens.cs +++ b/src/ImageSharp.Drawing/Drawing/Pens/Pens.cs @@ -7,14 +7,15 @@ using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Drawing.Pens { /// - /// Common Pen styles + /// Contains a collection of common Pen styles /// public static class Pens { - private static readonly float[] DashDotPattern = new[] { 3f, 1f, 1f, 1f }; - private static readonly float[] DashDotDotPattern = new[] { 3f, 1f, 1f, 1f, 1f, 1f }; - private static readonly float[] DottedPattern = new[] { 1f, 1f }; - private static readonly float[] DashedPattern = new[] { 3f, 1f }; + private static readonly float[] DashDotPattern = { 3f, 1f, 1f, 1f }; + private static readonly float[] DashDotDotPattern = { 3f, 1f, 1f, 1f, 1f, 1f }; + private static readonly float[] DottedPattern = { 1f, 1f }; + private static readonly float[] DashedPattern = { 3f, 1f }; + internal static readonly float[] EmptyPattern = new float[0]; /// /// Create a solid pen with out any drawing patterns diff --git a/src/ImageSharp.Drawing/Drawing/Pens/Pen{TPixel}.cs b/src/ImageSharp.Drawing/Drawing/Pens/Pen{TPixel}.cs index d2748e1112..3956dde0c9 100644 --- a/src/ImageSharp.Drawing/Drawing/Pens/Pen{TPixel}.cs +++ b/src/ImageSharp.Drawing/Drawing/Pens/Pen{TPixel}.cs @@ -2,9 +2,7 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Numerics; using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Drawing.Pens @@ -24,11 +22,10 @@ namespace SixLabors.ImageSharp.Drawing.Pens public class Pen : IPen where TPixel : struct, IPixel { - private static readonly float[] EmptyPattern = new float[0]; private readonly float[] pattern; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The color. /// The width. @@ -39,7 +36,7 @@ namespace SixLabors.ImageSharp.Drawing.Pens } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The brush. /// The width. @@ -52,7 +49,7 @@ namespace SixLabors.ImageSharp.Drawing.Pens } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The color. /// The width. @@ -62,12 +59,12 @@ namespace SixLabors.ImageSharp.Drawing.Pens } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The brush. /// The width. public Pen(IBrush brush, float width) - : this(brush, width, EmptyPattern) + : this(brush, width, Pens.EmptyPattern) { } diff --git a/src/ImageSharp.Drawing/Processing/Paths/ShapePath.cs b/src/ImageSharp.Drawing/Primitives/ShapePath.cs similarity index 68% rename from src/ImageSharp.Drawing/Processing/Paths/ShapePath.cs rename to src/ImageSharp.Drawing/Primitives/ShapePath.cs index 4c22787195..6b4ccd917d 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/ShapePath.cs +++ b/src/ImageSharp.Drawing/Primitives/ShapePath.cs @@ -1,14 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Buffers; -using System.Numerics; - -using SixLabors.ImageSharp.Memory; using SixLabors.Shapes; -namespace SixLabors.ImageSharp.Drawing +namespace SixLabors.ImageSharp.Primitives { /// /// A mapping between a and a region. @@ -20,10 +15,10 @@ namespace SixLabors.ImageSharp.Drawing /// /// The shape. /// The pen to apply to the shape. - // SixLabors.shape willbe moving to a Span/ReadOnlySpan based API shortly use ToArray for now. - public ShapePath(IPath shape, Pens.IPen pen) + // TODO: SixLabors.shape will be moving to a Span/ReadOnlySpan based API shortly use ToArray for now. + public ShapePath(IPath shape, Drawing.Pens.IPen pen) : base(shape.GenerateOutline(pen.StrokeWidth, pen.StrokePattern.ToArray())) { } } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/ShapeRegion.cs b/src/ImageSharp.Drawing/Primitives/ShapeRegion.cs similarity index 95% rename from src/ImageSharp.Drawing/Processing/Paths/ShapeRegion.cs rename to src/ImageSharp.Drawing/Primitives/ShapeRegion.cs index 9e1f1bc35d..cfd1945d08 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/ShapeRegion.cs +++ b/src/ImageSharp.Drawing/Primitives/ShapeRegion.cs @@ -2,12 +2,10 @@ // Licensed under the Apache License, Version 2.0. using System; - -using SixLabors.ImageSharp.Primitives; using SixLabors.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp.Drawing +namespace SixLabors.ImageSharp.Primitives { /// /// A mapping between a and a region. diff --git a/src/ImageSharp.Drawing/Processing/Paths/DrawBezierExtensions.cs b/src/ImageSharp.Drawing/Processing/Overlays/DrawBezierExtensions.cs similarity index 72% rename from src/ImageSharp.Drawing/Processing/Paths/DrawBezierExtensions.cs rename to src/ImageSharp.Drawing/Processing/Overlays/DrawBezierExtensions.cs index 7476f3a75a..974c7a6500 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/DrawBezierExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/DrawBezierExtensions.cs @@ -1,24 +1,21 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Numerics; -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; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// EAdds extensions that allow the drawing of Bezier paths to the type. + /// Adds extensions that allow the drawing of Bezier paths to the type. /// public static class DrawBezierExtensions { /// - /// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush + /// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush /// /// The type of the color. /// The image this method extends. @@ -28,13 +25,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points)), options); /// - /// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush + /// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush /// /// The type of the color. /// The image this method extends. @@ -43,13 +38,11 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points))); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points))); /// - /// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush + /// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush /// /// The type of the color. /// The image this method extends. @@ -58,13 +51,11 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points) - where TPixel : struct, IPixel - { - return source.DrawBeziers(new SolidBrush(color), thickness, points); - } + where TPixel : struct, IPixel + => source.DrawBeziers(new SolidBrush(color), thickness, points); /// - /// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush + /// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush /// /// The type of the color. /// The image this method extends. @@ -74,13 +65,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawBeziers(new SolidBrush(color), thickness, points, options); - } + where TPixel : struct, IPixel + => source.DrawBeziers(new SolidBrush(color), thickness, points, options); /// - /// Draws the provided Points as an open Bezier path with the supplied pen + /// Draws the provided points as an open Bezier path with the supplied pen /// /// The type of the color. /// The image this method extends. @@ -89,13 +78,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IPen pen, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(pen, new Path(new CubicBezierLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Draw(pen, new Path(new CubicBezierLineSegment(points)), options); /// - /// Draws the provided Points as an open Bezier path with the supplied pen + /// Draws the provided points as an open Bezier path with the supplied pen /// /// The type of the color. /// The image this method extends. @@ -103,9 +90,7 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IPen pen, PointF[] points) - where TPixel : struct, IPixel - { - return source.Draw(pen, new Path(new CubicBezierLineSegment(points))); - } + where TPixel : struct, IPixel + => source.Draw(pen, new Path(new CubicBezierLineSegment(points))); } } diff --git a/src/ImageSharp.Drawing/Processing/Overlays/DrawImage.cs b/src/ImageSharp.Drawing/Processing/Overlays/DrawImageExtensions.cs similarity index 78% rename from src/ImageSharp.Drawing/Processing/Overlays/DrawImage.cs rename to src/ImageSharp.Drawing/Processing/Overlays/DrawImageExtensions.cs index 9ff593d3ef..1fa16da492 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/DrawImage.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/DrawImageExtensions.cs @@ -1,34 +1,17 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +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 drawing of images to the type. /// - public static partial class ImageExtensions + public static class DrawImageExtensions { - /// - /// Draws the given image together with the current one by blending their pixels. - /// - /// The image this method extends. - /// The image to blend with the currently processing image. - /// The pixel format. - /// The location to draw the blended image. - /// The options. - /// The . - public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, GraphicsOptions options) - where TPixel : struct, IPixel - { - source.ApplyProcessor(new DrawImageProcessor(image, location, options)); - return source; - } - /// /// Draws the given image together with the current one by blending their pixels. /// @@ -39,11 +22,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Blend(this IImageProcessingContext source, Image image, float opacity) where TPixel : struct, IPixel - { - GraphicsOptions options = GraphicsOptions.Default; - options.BlendPercentage = opacity; - return DrawImage(source, image, Point.Empty, options); - } + => source.ApplyProcessor(new DrawImageProcessor(image, opacity)); /// /// Draws the given image together with the current one by blending their pixels. @@ -56,12 +35,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Blend(this IImageProcessingContext source, Image image, PixelBlenderMode blender, float opacity) where TPixel : struct, IPixel - { - GraphicsOptions options = GraphicsOptions.Default; - options.BlendPercentage = opacity; - options.BlenderMode = blender; - return DrawImage(source, image, Point.Empty, options); - } + => source.ApplyProcessor(new DrawImageProcessor(image, opacity, blender)); /// /// Draws the given image together with the current one by blending their pixels. @@ -74,7 +48,7 @@ namespace SixLabors.ImageSharp public static IImageProcessingContext Blend(this IImageProcessingContext source, Image image, GraphicsOptions options) where TPixel : struct, IPixel { - return DrawImage(source, image, Point.Empty, options); + return source.ApplyProcessor(new DrawImageProcessor(image, options)); } /// @@ -88,11 +62,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, float opacity, Point location) where TPixel : struct, IPixel - { - GraphicsOptions options = GraphicsOptions.Default; - options.BlendPercentage = opacity; - return source.DrawImage(image, location, options); - } + => source.ApplyProcessor(new DrawImageProcessor(image, location, opacity)); /// /// Draws the given image together with the current one by blending their pixels. @@ -106,11 +76,19 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelBlenderMode blender, float opacity, Point location) where TPixel : struct, IPixel - { - GraphicsOptions options = GraphicsOptions.Default; - options.BlenderMode = blender; - options.BlendPercentage = opacity; - return source.DrawImage(image, location, options); - } + => source.ApplyProcessor(new DrawImageProcessor(image, location, opacity, blender)); + + /// + /// Draws the given image together with the current one by blending their pixels. + /// + /// The image this method extends. + /// The image to blend with the currently processing image. + /// The pixel format. + /// The location to draw the blended image. + /// The options containing the blend mode and opacity. + /// The . + public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, GraphicsOptions options) + where TPixel : struct, IPixel + => source.ApplyProcessor(new DrawImageProcessor(image, location, options)); } } \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/DrawLines.cs b/src/ImageSharp.Drawing/Processing/Overlays/DrawLineExtensions.cs similarity index 78% rename from src/ImageSharp.Drawing/Processing/Paths/DrawLines.cs rename to src/ImageSharp.Drawing/Processing/Overlays/DrawLineExtensions.cs index 397cd20e71..8bf42a07f9 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/DrawLines.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/DrawLineExtensions.cs @@ -1,21 +1,18 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Numerics; -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; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the drawing of lines to the type. /// - public static partial class ImageExtensions + public static class DrawLineExtensions { /// /// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush @@ -28,10 +25,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points)), options); /// /// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush @@ -43,10 +38,8 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points))); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points))); /// /// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush @@ -58,10 +51,8 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawLines(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points) - where TPixel : struct, IPixel - { - return source.DrawLines(new SolidBrush(color), thickness, points); - } + where TPixel : struct, IPixel + => source.DrawLines(new SolidBrush(color), thickness, points); /// /// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush @@ -74,10 +65,8 @@ namespace SixLabors.ImageSharp /// The options. /// The .> public static IImageProcessingContext DrawLines(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawLines(new SolidBrush(color), thickness, points, options); - } + where TPixel : struct, IPixel + => source.DrawLines(new SolidBrush(color), thickness, points, options); /// /// Draws the provided Points as an open Linear path with the supplied pen @@ -89,10 +78,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IPen pen, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(pen, new Path(new LinearLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Draw(pen, new Path(new LinearLineSegment(points)), options); /// /// Draws the provided Points as an open Linear path with the supplied pen @@ -103,9 +90,7 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IPen pen, PointF[] points) - where TPixel : struct, IPixel - { - return source.Draw(pen, new Path(new LinearLineSegment(points))); - } + where TPixel : struct, IPixel + => source.Draw(pen, new Path(new LinearLineSegment(points))); } } diff --git a/src/ImageSharp.Drawing/Processing/Paths/DrawPathCollection.cs b/src/ImageSharp.Drawing/Processing/Overlays/DrawPathCollectionExtensions.cs similarity index 82% rename from src/ImageSharp.Drawing/Processing/Paths/DrawPathCollection.cs rename to src/ImageSharp.Drawing/Processing/Overlays/DrawPathCollectionExtensions.cs index 17d7fed414..191a73a36b 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/DrawPathCollection.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/DrawPathCollectionExtensions.cs @@ -1,19 +1,17 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -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 +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the drawing of collections of polygon outlines to the type. /// - public static partial class ImageExtensions + public static class DrawPathCollectionExtensions { /// /// Draws the outline of the polygon with the provided pen. @@ -44,10 +42,8 @@ namespace SixLabors.ImageSharp /// The paths. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPathCollection paths) - where TPixel : struct, IPixel - { - return source.Draw(pen, paths, GraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.Draw(pen, paths, GraphicsOptions.Default); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -60,10 +56,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, IPathCollection paths, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), paths, options); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), paths, options); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -75,10 +69,8 @@ namespace SixLabors.ImageSharp /// The paths. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, IPathCollection paths) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), paths); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), paths); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -91,10 +83,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, IPathCollection paths, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new SolidBrush(color), thickness, paths, options); - } + where TPixel : struct, IPixel + => source.Draw(new SolidBrush(color), thickness, paths, options); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -106,9 +96,7 @@ namespace SixLabors.ImageSharp /// The paths. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, IPathCollection paths) - where TPixel : struct, IPixel - { - return source.Draw(new SolidBrush(color), thickness, paths); - } + where TPixel : struct, IPixel + => source.Draw(new SolidBrush(color), thickness, paths); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/DrawPath.cs b/src/ImageSharp.Drawing/Processing/Overlays/DrawPathExtensions.cs similarity index 79% rename from src/ImageSharp.Drawing/Processing/Paths/DrawPath.cs rename to src/ImageSharp.Drawing/Processing/Overlays/DrawPathExtensions.cs index b265342a40..7f86ddee65 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/DrawPath.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/DrawPathExtensions.cs @@ -1,19 +1,18 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the drawing of polygon outlines to the type. /// - public static partial class ImageExtensions + public static class DrawPathExtensions { /// /// Draws the outline of the polygon with the provided pen. @@ -25,10 +24,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPath path, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(pen.StrokeFill, new ShapePath(path, pen), options); - } + where TPixel : struct, IPixel + => source.Fill(pen.StrokeFill, new ShapePath(path, pen), options); /// /// Draws the outline of the polygon with the provided pen. @@ -39,10 +36,8 @@ namespace SixLabors.ImageSharp /// The path. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPath path) - where TPixel : struct, IPixel - { - return source.Draw(pen, path, GraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.Draw(pen, path, GraphicsOptions.Default); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -55,10 +50,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, IPath path, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), path, options); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), path, options); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -70,10 +63,8 @@ namespace SixLabors.ImageSharp /// The path. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, IPath path) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), path); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), path); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -86,10 +77,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, IPath path, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new SolidBrush(color), thickness, path, options); - } + where TPixel : struct, IPixel + => source.Draw(new SolidBrush(color), thickness, path, options); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -101,9 +90,7 @@ namespace SixLabors.ImageSharp /// The path. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, IPath path) - where TPixel : struct, IPixel - { - return source.Draw(new SolidBrush(color), thickness, path); - } + where TPixel : struct, IPixel + => source.Draw(new SolidBrush(color), thickness, path); } } diff --git a/src/ImageSharp.Drawing/Processing/Paths/DrawPolygon.cs b/src/ImageSharp.Drawing/Processing/Overlays/DrawPolygonExtensions.cs similarity index 78% rename from src/ImageSharp.Drawing/Processing/Paths/DrawPolygon.cs rename to src/ImageSharp.Drawing/Processing/Overlays/DrawPolygonExtensions.cs index 7615284d23..f56ab19d83 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/DrawPolygon.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/DrawPolygonExtensions.cs @@ -1,21 +1,18 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Numerics; -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; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the drawing of closed linear polygons to the type. /// - public static partial class ImageExtensions + public static class DrawPolygonExtensions { /// /// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness. @@ -28,10 +25,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points)), options); /// /// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness. @@ -43,10 +38,8 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points))); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points))); /// /// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness. @@ -58,10 +51,8 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points) - where TPixel : struct, IPixel - { - return source.DrawPolygon(new SolidBrush(color), thickness, points); - } + where TPixel : struct, IPixel + => source.DrawPolygon(new SolidBrush(color), thickness, points); /// /// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness. @@ -74,10 +65,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawPolygon(new SolidBrush(color), thickness, points, options); - } + where TPixel : struct, IPixel + => source.DrawPolygon(new SolidBrush(color), thickness, points, options); /// /// Draws the provided Points as a closed Linear Polygon with the provided Pen. @@ -88,10 +77,8 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IPen pen, PointF[] points) - where TPixel : struct, IPixel - { - return source.Draw(pen, new Polygon(new LinearLineSegment(points)), GraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.Draw(pen, new Polygon(new LinearLineSegment(points)), GraphicsOptions.Default); /// /// Draws the provided Points as a closed Linear Polygon with the provided Pen. @@ -103,9 +90,7 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IPen pen, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(pen, new Polygon(new LinearLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Draw(pen, new Polygon(new LinearLineSegment(points)), options); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/DrawRectangle.cs b/src/ImageSharp.Drawing/Processing/Overlays/DrawRectangleExtensions.cs similarity index 69% rename from src/ImageSharp.Drawing/Processing/Paths/DrawRectangle.cs rename to src/ImageSharp.Drawing/Processing/Overlays/DrawRectangleExtensions.cs index db825e2e89..df0c1bf153 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/DrawRectangle.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/DrawRectangleExtensions.cs @@ -1,22 +1,21 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -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; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the drawing of rectangles to the type. /// - public static partial class ImageExtensions + public static class DrawRectangleExtensions { /// - /// Draws the outline of the polygon with the provided pen. + /// Draws the outline of the rectangle with the provided pen. /// /// The type of the color. /// The image this method extends. @@ -25,13 +24,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, RectangleF shape, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(pen, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options); - } + where TPixel : struct, IPixel + => source.Draw(pen, new RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options); /// - /// Draws the outline of the polygon with the provided pen. + /// Draws the outline of the rectangle with the provided pen. /// /// The type of the color. /// The image this method extends. @@ -39,13 +36,11 @@ namespace SixLabors.ImageSharp /// The shape. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, RectangleF shape) - where TPixel : struct, IPixel - { - return source.Draw(pen, shape, GraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.Draw(pen, shape, GraphicsOptions.Default); /// - /// Draws the outline of the polygon with the provided brush at the provided thickness. + /// Draws the outline of the rectangle with the provided brush at the provided thickness. /// /// The type of the color. /// The image this method extends. @@ -55,13 +50,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, RectangleF shape, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), shape, options); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), shape, options); /// - /// Draws the outline of the polygon with the provided brush at the provided thickness. + /// Draws the outline of the rectangle with the provided brush at the provided thickness. /// /// The type of the color. /// The image this method extends. @@ -70,13 +63,11 @@ namespace SixLabors.ImageSharp /// The shape. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, RectangleF shape) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), shape); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), shape); /// - /// Draws the outline of the polygon with the provided brush at the provided thickness. + /// Draws the outline of the rectangle with the provided brush at the provided thickness. /// /// The type of the color. /// The image this method extends. @@ -86,13 +77,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, RectangleF shape, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new SolidBrush(color), thickness, shape, options); - } + where TPixel : struct, IPixel + => source.Draw(new SolidBrush(color), thickness, shape, options); /// - /// Draws the outline of the polygon with the provided brush at the provided thickness. + /// Draws the outline of the rectangle with the provided brush at the provided thickness. /// /// The type of the color. /// The image this method extends. @@ -101,9 +90,7 @@ namespace SixLabors.ImageSharp /// The shape. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, RectangleF shape) - where TPixel : struct, IPixel - { - return source.Draw(new SolidBrush(color), thickness, shape); - } + where TPixel : struct, IPixel + => source.Draw(new SolidBrush(color), thickness, shape); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/FillPathBuilder.cs b/src/ImageSharp.Drawing/Processing/Overlays/FillPathBuilderExtensions.cs similarity index 79% rename from src/ImageSharp.Drawing/Processing/Paths/FillPathBuilder.cs rename to src/ImageSharp.Drawing/Processing/Overlays/FillPathBuilderExtensions.cs index f9846b8635..e40eaa4139 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/FillPathBuilder.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/FillPathBuilderExtensions.cs @@ -2,21 +2,20 @@ // Licensed under the Apache License, Version 2.0. 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 +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the filling of polygons with various brushes to the type. /// - public static partial class ImageExtensions + public static class FillPathBuilderExtensions { /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided polygon with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -42,13 +41,11 @@ namespace SixLabors.ImageSharp /// The path. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, Action path) - where TPixel : struct, IPixel - { - return source.Fill(brush, path, GraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.Fill(brush, path, GraphicsOptions.Default); /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided polygon with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -57,13 +54,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Action path, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), path, options); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), path, options); /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided polygon with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -71,9 +66,7 @@ namespace SixLabors.ImageSharp /// The path. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Action path) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), path); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), path); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/FillPathCollection.cs b/src/ImageSharp.Drawing/Processing/Overlays/FillPathCollectionExtensions.cs similarity index 79% rename from src/ImageSharp.Drawing/Processing/Paths/FillPathCollection.cs rename to src/ImageSharp.Drawing/Processing/Overlays/FillPathCollectionExtensions.cs index d8fd896782..7021b5c87d 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/FillPathCollection.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/FillPathCollectionExtensions.cs @@ -1,21 +1,19 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the filling of collections of polygon outlines to the type. /// - public static partial class ImageExtensions + public static class FillPathCollectionExtensions { /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided polygon with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -43,13 +41,11 @@ namespace SixLabors.ImageSharp /// The paths. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, IPathCollection paths) - where TPixel : struct, IPixel - { - return source.Fill(brush, paths, GraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.Fill(brush, paths, GraphicsOptions.Default); /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided polygon with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -58,13 +54,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, IPathCollection paths, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), paths, options); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), paths, options); /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided polygon with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -72,9 +66,7 @@ namespace SixLabors.ImageSharp /// The paths. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, IPathCollection paths) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), paths); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), paths); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/FillPaths.cs b/src/ImageSharp.Drawing/Processing/Overlays/FillPathExtensions.cs similarity index 77% rename from src/ImageSharp.Drawing/Processing/Paths/FillPaths.cs rename to src/ImageSharp.Drawing/Processing/Overlays/FillPathExtensions.cs index eb8fcc4eed..779a6e94fa 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/FillPaths.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/FillPathExtensions.cs @@ -1,18 +1,17 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the filling of polygon outlines to the type. /// - public static partial class ImageExtensions + public static class FillPathExtensions { /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. @@ -24,10 +23,8 @@ namespace SixLabors.ImageSharp /// The graphics options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, IPath path, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(brush, new ShapeRegion(path), options); - } + where TPixel : struct, IPixel + => source.Fill(brush, new ShapeRegion(path), options); /// /// Flood fills the image in the shape of the provided polygon with the specified brush. @@ -38,10 +35,8 @@ namespace SixLabors.ImageSharp /// The path. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, IPath path) - where TPixel : struct, IPixel - { - return source.Fill(brush, new ShapeRegion(path), GraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.Fill(brush, new ShapeRegion(path), GraphicsOptions.Default); /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. @@ -53,10 +48,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, IPath path, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), path, options); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), path, options); /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. @@ -67,9 +60,7 @@ namespace SixLabors.ImageSharp /// The path. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, IPath path) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), path); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), path); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/FillPolygon.cs b/src/ImageSharp.Drawing/Processing/Overlays/FillPolygonExtensions.cs similarity index 75% rename from src/ImageSharp.Drawing/Processing/Paths/FillPolygon.cs rename to src/ImageSharp.Drawing/Processing/Overlays/FillPolygonExtensions.cs index 4e3fea9c70..700b3e18f6 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/FillPolygon.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/FillPolygonExtensions.cs @@ -1,21 +1,17 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -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; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the filling of closed linear polygons to the type. /// - public static partial class ImageExtensions + public static class FillPolygonExtensions { /// /// Flood fills the image in the shape of a Linear polygon described by the points @@ -27,10 +23,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext FillPolygon(this IImageProcessingContext source, IBrush brush, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(brush, new Polygon(new LinearLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Fill(brush, new Polygon(new LinearLineSegment(points)), options); /// /// Flood fills the image in the shape of a Linear polygon described by the points @@ -41,10 +35,8 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext FillPolygon(this IImageProcessingContext source, IBrush brush, PointF[] points) - where TPixel : struct, IPixel - { - return source.Fill(brush, new Polygon(new LinearLineSegment(points))); - } + where TPixel : struct, IPixel + => source.Fill(brush, new Polygon(new LinearLineSegment(points))); /// /// Flood fills the image in the shape of a Linear polygon described by the points @@ -56,10 +48,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext FillPolygon(this IImageProcessingContext source, TPixel color, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points)), options); /// /// Flood fills the image in the shape of a Linear polygon described by the points @@ -70,9 +60,7 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext FillPolygon(this IImageProcessingContext source, TPixel color, PointF[] points) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points))); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points))); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/FillRectangle.cs b/src/ImageSharp.Drawing/Processing/Overlays/FillRectangleExtensions.cs similarity index 69% rename from src/ImageSharp.Drawing/Processing/Paths/FillRectangle.cs rename to src/ImageSharp.Drawing/Processing/Overlays/FillRectangleExtensions.cs index 2f3b676298..a7ba82d49f 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/FillRectangle.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/FillRectangleExtensions.cs @@ -1,21 +1,20 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; +using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the filling of rectangles to the type. /// - public static partial class ImageExtensions + public static class FillRectangleExtensions { /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided rectangle with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -25,12 +24,10 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, RectangleF shape, GraphicsOptions options) where TPixel : struct, IPixel - { - return source.Fill(brush, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options); - } + => source.Fill(brush, new RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options); /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided rectangle with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -39,12 +36,10 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, RectangleF shape) where TPixel : struct, IPixel - { - return source.Fill(brush, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height)); - } + => source.Fill(brush, new RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height)); /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided rectangle with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -53,13 +48,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, RectangleF shape, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), shape, options); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), shape, options); /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided rectangle with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -68,8 +61,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, RectangleF shape) where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), shape); - } + => source.Fill(new SolidBrush(color), shape); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Overlays/FillRegion.cs b/src/ImageSharp.Drawing/Processing/Overlays/FillRegionExtensions.cs similarity index 80% rename from src/ImageSharp.Drawing/Processing/Overlays/FillRegion.cs rename to src/ImageSharp.Drawing/Processing/Overlays/FillRegionExtensions.cs index b9fb8650a7..0f1176e9d3 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/FillRegion.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/FillRegionExtensions.cs @@ -1,34 +1,18 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; -using SixLabors.ImageSharp.Processing; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the filling of regions with various brushes to the type. /// - public static partial class ImageExtensions + public static class FillRegionExtensions { - /// - /// Flood fills the image with the specified brush. - /// - /// The type of the color. - /// The image this method extends. - /// The details how to fill the region of interest. - /// The graphics options. - /// The . - public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.ApplyProcessor(new FillProcessor(brush, options)); - } - /// /// Flood fills the image with the specified brush. /// @@ -38,9 +22,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush) where TPixel : struct, IPixel - { - return source.Fill(brush, GraphicsOptions.Default); - } + => source.Fill(brush, GraphicsOptions.Default); /// /// Flood fills the image with the specified color. @@ -51,9 +33,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color) where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color)); - } + => source.Fill(new SolidBrush(color)); /// /// Flood fills the image with in the region with the specified brush. @@ -62,27 +42,23 @@ namespace SixLabors.ImageSharp /// The image this method extends. /// The brush. /// The region. - /// The graphics options. /// The . - public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, Region region, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.ApplyProcessor(new FillRegionProcessor(brush, region, options)); - } + public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, Region region) + where TPixel : struct, IPixel + => source.Fill(brush, region, GraphicsOptions.Default); /// - /// Flood fills the image with in the region with the specified brush. + /// Flood fills the image with in the region with the specified color. /// /// The type of the color. /// The image this method extends. - /// The brush. + /// The color. /// The region. + /// The options. /// The . - public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, Region region) - where TPixel : struct, IPixel - { - return source.Fill(brush, region, GraphicsOptions.Default); - } + public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Region region, GraphicsOptions options) + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), region, options); /// /// Flood fills the image with in the region with the specified color. @@ -91,26 +67,34 @@ namespace SixLabors.ImageSharp /// The image this method extends. /// The color. /// The region. - /// The options. /// The . - public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Region region, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), region, options); - } + public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Region region) + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), region); /// - /// Flood fills the image with in the region with the specified color. + /// Flood fills the image with in the region with the specified brush. /// /// The type of the color. /// The image this method extends. - /// The color. + /// The brush. /// The region. + /// The graphics options. /// The . - public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Region region) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), region); - } + public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, Region region, GraphicsOptions options) + where TPixel : struct, IPixel + => source.ApplyProcessor(new FillRegionProcessor(brush, region, options)); + + /// + /// Flood fills the image with the specified brush. + /// + /// The type of the color. + /// The image this method extends. + /// The details how to fill the region of interest. + /// The graphics options. + /// The . + public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, GraphicsOptions options) + where TPixel : struct, IPixel + => source.ApplyProcessor(new FillProcessor(brush, options)); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Overlays/Processors/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processing/Overlays/Processors/DrawImageProcessor.cs index 53997b6184..a41496d2a9 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/Processors/DrawImageProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/Processors/DrawImageProcessor.cs @@ -9,7 +9,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Drawing.Processors +namespace SixLabors.ImageSharp.Processing.Overlays.Processors { /// /// Combines two images together by blending the pixels. @@ -18,19 +18,79 @@ namespace SixLabors.ImageSharp.Drawing.Processors internal class DrawImageProcessor : ImageProcessor where TPixel : struct, IPixel { + /// + /// Initializes a new instance of the class. + /// + /// The image to blend with the currently processing image. + /// The opacity of the image to blend. Must be between 0 and 1. + public DrawImageProcessor(Image image, float opacity) + : this(image, Point.Empty, opacity) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The image to blend with the currently processing image. + /// + /// The options containing the opacity of the image to blend and blending mode. + /// Opacity must be between 0 and 1. + /// + public DrawImageProcessor(Image image, GraphicsOptions options) + : this(image, Point.Empty, options) + { + } + /// /// Initializes a new instance of the class. /// /// The image to blend with the currently processing image. /// The location to draw the blended image. - /// The opacity of the image to blend. Between 0 and 1. + /// The opacity of the image to blend. Must be between 0 and 1. + public DrawImageProcessor(Image image, Point location, float opacity) + : this(image, location, opacity, GraphicsOptions.Default.BlenderMode) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The image to blend with the currently processing image. + /// The location to draw the blended image. + /// + /// The options containing the opacity of the image to blend and blending mode. + /// Opacity must be between 0 and 1. + /// public DrawImageProcessor(Image image, Point location, GraphicsOptions options) + : this(image, location, options.BlendPercentage, options.BlenderMode) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The image to blend with the currently processing image. + /// The opacity of the image to blend. Must be between 0 and 1. + /// The blending mode to use when drawing the image. + public DrawImageProcessor(Image image, float opacity, PixelBlenderMode blenderMode) + : this(image, Point.Empty, opacity, blenderMode) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The image to blend with the currently processing image. + /// The location to draw the blended image. + /// The opacity of the image to blend. Must be between 0 and 1. + /// The blending mode to use when drawing the image. + public DrawImageProcessor(Image image, Point location, float opacity, PixelBlenderMode blenderMode) { - Guard.MustBeBetweenOrEqualTo(options.BlendPercentage, 0, 1, nameof(options.BlendPercentage)); + Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity)); this.Image = image; - this.Opacity = options.BlendPercentage; - this.Blender = PixelOperations.Instance.GetPixelBlender(options.BlenderMode); + this.Opacity = opacity; + this.Blender = PixelOperations.Instance.GetPixelBlender(blenderMode); this.Location = location; } diff --git a/src/ImageSharp.Drawing/Processing/Text/DrawText.Path.cs b/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.Path.cs similarity index 84% rename from src/ImageSharp.Drawing/Processing/Text/DrawText.Path.cs rename to src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.Path.cs index f1fbd2cec4..6c009169f4 100644 --- a/src/ImageSharp.Drawing/Processing/Text/DrawText.Path.cs +++ b/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.Path.cs @@ -1,21 +1,19 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Numerics; using SixLabors.Fonts; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Text { /// - /// Extension methods for the type. + /// Adds extensions that allow the drawing of text along given paths to the type. /// - public static partial class ImageExtensions + public static partial class DrawTextExtensions { /// /// Draws the text onto the the image filled via the brush. @@ -30,10 +28,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, TPixel color, IPath path) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, color, path, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, color, path, TextGraphicsOptions.Default); /// /// Draws the text onto the the image filled via the brush. @@ -49,10 +45,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, TPixel color, IPath path, TextGraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, Brushes.Solid(color), null, path, options); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, Brushes.Solid(color), null, path, options); /// /// Draws the text onto the the image filled via the brush. @@ -67,10 +61,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IBrush brush, IPath path) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, brush, path, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, brush, path, TextGraphicsOptions.Default); /// /// Draws the text onto the the image filled via the brush. @@ -86,10 +78,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IBrush brush, IPath path, TextGraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, brush, null, path, options); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, brush, null, path, options); /// /// Draws the text onto the the image outlined via the pen. @@ -104,10 +94,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IPen pen, IPath path) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, pen, path, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, pen, path, TextGraphicsOptions.Default); /// /// Draws the text onto the the image outlined via the pen. @@ -123,10 +111,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IPen pen, IPath path, TextGraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, null, pen, path, options); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, null, pen, path, options); /// /// Draws the text onto the the image filled via the brush then outlined via the pen. @@ -142,10 +128,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IBrush brush, IPen pen, IPath path) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, brush, pen, path, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, brush, pen, path, TextGraphicsOptions.Default); /// /// Draws the text onto the the image filled via the brush then outlined via the pen. @@ -192,4 +176,4 @@ namespace SixLabors.ImageSharp return source; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Text/DrawText.cs b/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.cs similarity index 83% rename from src/ImageSharp.Drawing/Processing/Text/DrawText.cs rename to src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.cs index cac5ae22f3..7e43fb17c1 100644 --- a/src/ImageSharp.Drawing/Processing/Text/DrawText.cs +++ b/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.cs @@ -1,22 +1,20 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Numerics; using SixLabors.Fonts; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Text { /// - /// Extension methods for the type. + /// Adds extensions that allow the drawing of text to the type. /// - public static partial class ImageExtensions + public static partial class DrawTextExtensions { private static readonly int DefaultTextDpi = 72; @@ -33,10 +31,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, TPixel color, PointF location) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, color, location, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, color, location, TextGraphicsOptions.Default); /// /// Draws the text onto the the image filled via the brush. @@ -52,10 +48,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, TPixel color, PointF location, TextGraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, Brushes.Solid(color), null, location, options); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, Brushes.Solid(color), null, location, options); /// /// Draws the text onto the the image filled via the brush. @@ -70,10 +64,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IBrush brush, PointF location) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, brush, location, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, brush, location, TextGraphicsOptions.Default); /// /// Draws the text onto the the image filled via the brush. @@ -89,10 +81,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IBrush brush, PointF location, TextGraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, brush, null, location, options); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, brush, null, location, options); /// /// Draws the text onto the the image outlined via the pen. @@ -107,10 +97,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IPen pen, PointF location) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, pen, location, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, pen, location, TextGraphicsOptions.Default); /// /// Draws the text onto the the image outlined via the pen. @@ -126,10 +114,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IPen pen, PointF location, TextGraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, null, pen, location, options); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, null, pen, location, options); /// /// Draws the text onto the the image filled via the brush then outlined via the pen. @@ -145,13 +131,11 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IBrush brush, IPen pen, PointF location) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, brush, pen, location, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, brush, pen, location, TextGraphicsOptions.Default); /// - /// Draws the text onto the the image filled via the brush then outlined via the pen. + /// Draws the text using the default resolution of 72dpi onto the the image filled via the brush then outlined via the pen. /// /// The type of the color. /// The image this method extends. @@ -195,4 +179,4 @@ namespace SixLabors.ImageSharp return source; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Text/TextGraphicsOptions.cs b/src/ImageSharp.Drawing/Processing/Text/TextGraphicsOptions.cs index c230a8c79e..bba473ddb8 100644 --- a/src/ImageSharp.Drawing/Processing/Text/TextGraphicsOptions.cs +++ b/src/ImageSharp.Drawing/Processing/Text/TextGraphicsOptions.cs @@ -1,9 +1,10 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. + using SixLabors.Fonts; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Drawing +namespace SixLabors.ImageSharp.Processing.Text { /// /// Options for influencing the drawing functions. @@ -29,8 +30,8 @@ namespace SixLabors.ImageSharp.Drawing private float wrapTextWidth; - private SixLabors.Fonts.HorizontalAlignment? horizontalAlignment; - private SixLabors.Fonts.VerticalAlignment? verticalAlignment; + private HorizontalAlignment? horizontalAlignment; + private VerticalAlignment? verticalAlignment; /// /// Initializes a new instance of the struct. diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs index 8850f581c1..60b00c0f5b 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs @@ -20,6 +20,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// /// Gets or sets the quality, that will be used to encode the image. Quality /// index must be between 0 and 100 (compression from max to min). + /// Defaults to 75. /// public int Quality { get; set; } = 75; diff --git a/src/ImageSharp/Primitives/ValueSize.cs b/src/ImageSharp/Primitives/ValueSize.cs index e64d838e6a..8af9ba2e48 100644 --- a/src/ImageSharp/Primitives/ValueSize.cs +++ b/src/ImageSharp/Primitives/ValueSize.cs @@ -38,12 +38,12 @@ namespace SixLabors.ImageSharp.Primitives Absolute, /// - /// The value is a percentage of the Images Width + /// The value is a percentage of the image width /// PercentageOfWidth, /// - /// The value is a percentage of the Images height + /// The value is a percentage of the images height /// PercentageOfHeight } diff --git a/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs index e0639d8ad7..b676f6a122 100644 --- a/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors /// The options defining blending algorithm and amount. public BackgroundColorProcessor(TPixel color, GraphicsOptions options) { - this.Value = color; + this.Color = color; this.GraphicsOptions = options; } @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors /// /// Gets the background color value. /// - public TPixel Value { get; } + public TPixel Color { get; } /// protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) @@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors // TODO: Use Span.Fill? for (int i = 0; i < width; i++) { - colorSpan[i] = this.Value; + colorSpan[i] = this.Color; amountSpan[i] = this.GraphicsOptions.BlendPercentage; } diff --git a/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs index 5f9b8f5af9..ac5d3dc82e 100644 --- a/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs @@ -27,10 +27,8 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors /// /// The color or the glow. public GlowProcessor(TPixel color) + : this(color, 0) { - this.GlowColor = color; - this.GraphicsOptions = GraphicsOptions.Default; - this.blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions.BlenderMode); } /// @@ -39,11 +37,18 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors /// The color or the glow. /// The radius of the glow. public GlowProcessor(TPixel color, ValueSize radius) + : this(color, radius, GraphicsOptions.Default) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The color or the glow. + /// The options effecting blending and composition. + public GlowProcessor(TPixel color, GraphicsOptions options) + : this(color, 0, options) { - this.GlowColor = color; - this.Radius = radius; - this.GraphicsOptions = GraphicsOptions.Default; - this.blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions.BlenderMode); } /// @@ -83,7 +88,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors int startX = sourceRectangle.X; int endX = sourceRectangle.Right; TPixel glowColor = this.GlowColor; - Vector2 centre = Rectangle.Center(sourceRectangle); + Vector2 center = Rectangle.Center(sourceRectangle); float finalRadius = this.Radius.Calculate(source.Size()); @@ -130,7 +135,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors int offsetX = minX - startX; for (int i = 0; i < width; i++) { - float distance = Vector2.Distance(centre, new Vector2(i + offsetX, offsetY)); + float distance = Vector2.Distance(center, new Vector2(i + offsetX, offsetY)); amountsSpan[i] = (this.GraphicsOptions.BlendPercentage * (1 - (.95F * (distance / maxDistance)))).Clamp(0, 1); } diff --git a/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs index 961c0f9f07..ec286db626 100644 --- a/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs @@ -27,10 +27,8 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors /// /// The color of the vignette. public VignetteProcessor(TPixel color) + : this(color, GraphicsOptions.Default) { - this.VignetteColor = color; - this.GraphicsOptions = GraphicsOptions.Default; - this.blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions.BlenderMode); } /// diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs index a8042c77cf..9b7b8f4e62 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs @@ -3,17 +3,16 @@ // Licensed under the Apache License, Version 2.0. // +using System.Drawing; +using System.Drawing.Drawing2D; +using System.IO; +using System.Numerics; +using BenchmarkDotNet.Attributes; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; + namespace SixLabors.ImageSharp.Benchmarks { - using System.Drawing; - using System.Drawing.Drawing2D; - using System.IO; - using System.Numerics; - - using BenchmarkDotNet.Attributes; - - using SixLabors.ImageSharp.Processing; - public class DrawBeziers : BenchmarkBase { [Benchmark(Baseline = true, Description = "System.Drawing Draw Beziers")] diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs index f89d9a6846..d12b064cbd 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.Processing.Overlays; + namespace SixLabors.ImageSharp.Benchmarks { using System.Drawing; diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs index aa24088ae0..3f2a030504 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs @@ -3,18 +3,17 @@ // Licensed under the Apache License, Version 2.0. // +using System.Drawing; +using System.Drawing.Drawing2D; +using BenchmarkDotNet.Attributes; +using System.IO; +using System.Numerics; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; + namespace SixLabors.ImageSharp.Benchmarks { - using System.Drawing; - using System.Drawing.Drawing2D; - - using BenchmarkDotNet.Attributes; - - using System.IO; - 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 9075e02e89..a6f8b2c080 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs @@ -3,26 +3,24 @@ // Licensed under the Apache License, Version 2.0. // +using System.Drawing; +using System.Drawing.Drawing2D; +using System.IO; +using System.Numerics; +using SixLabors.Shapes; +using BenchmarkDotNet.Attributes; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; + namespace SixLabors.ImageSharp.Benchmarks { - using System.Drawing; - using System.Drawing.Drawing2D; - using System.IO; - using System.Numerics; - using SixLabors.Shapes; - - using BenchmarkDotNet.Attributes; - - using SixLabors.ImageSharp.PixelFormats; - using SixLabors.ImageSharp.Processing; - public class FillPolygon : BenchmarkBase { private readonly Polygon shape; public FillPolygon() { - this.shape = new SixLabors.Shapes.Polygon(new LinearLineSegment(new Vector2(10, 10), + this.shape = new Polygon(new LinearLineSegment(new Vector2(10, 10), new Vector2(550, 50), new Vector2(200, 400))); } diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs b/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs index 1fd2dbe826..b60a068f19 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs @@ -3,19 +3,18 @@ // Licensed under the Apache License, Version 2.0. // +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Numerics; +using BenchmarkDotNet.Attributes; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; +using CoreRectangle = SixLabors.Primitives.Rectangle; +using CoreSize = SixLabors.Primitives.Size; + namespace SixLabors.ImageSharp.Benchmarks { - using System.Drawing; - using System.Drawing.Drawing2D; - - using BenchmarkDotNet.Attributes; - using CoreRectangle = SixLabors.Primitives.Rectangle; - using CoreSize = SixLabors.Primitives.Size; - - using System.Numerics; - using SixLabors.ImageSharp.PixelFormats; - using SixLabors.ImageSharp.Processing; public class FillRectangle : BenchmarkBase { diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs b/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs index 64132e479e..3d840de46c 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.Processing.Overlays; + namespace SixLabors.ImageSharp.Benchmarks { using System.Drawing; diff --git a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs index af1364af43..9ab772208b 100644 --- a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs +++ b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs @@ -1,20 +1,13 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; using System.Numerics; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Tests.Drawing; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing { - using SixLabors.ImageSharp.Processing; - using SixLabors.ImageSharp.Processing.Overlays; - public class Beziers : FileTestBase { [Fact] @@ -71,9 +64,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Vector2(240, 30), new Vector2(300, 400) })); - image.Save($"{path}/Opacity.png"); + image.Save($"{path}/Opacity.png"); - //shift background color towards forground color by the opacity amount + //shift background color towards foreground color by the opacity amount Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f)); using (PixelAccessor sourcePixels = image.Lock()) diff --git a/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs b/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs index bea0d8b07d..3138b8c707 100644 --- a/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs +++ b/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs @@ -4,8 +4,8 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Primitives; using Xunit; @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing public class BlendedShapes { public static IEnumerable modes = ((PixelBlenderMode[])Enum.GetValues(typeof(PixelBlenderMode))) - .Select(x=> new object[] { x }); + .Select(x => new object[] { x }); [Theory] [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { var scaleX = (img.Width / 100); var scaleY = (img.Height / 100); - img.Mutate(x=>x + img.Mutate(x => x .Fill(NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY)) .Fill(NamedColors.HotPink, new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY), new ImageSharp.GraphicsOptions(true) { @@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { var scaleX = (img.Width / 100); var scaleY = (img.Height / 100); - img.Mutate(x=>x.Fill(NamedColors.DarkBlue, new Rectangle(0* scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); + img.Mutate(x => x.Fill(NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); img.Mutate(x => x.Fill(NamedColors.HotPink, new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY), new ImageSharp.GraphicsOptions(true) { BlenderMode = mode @@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { var scaleX = (img.Width / 100); var scaleY = (img.Height / 100); - img.Mutate(x=>x.Fill(NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40, 100 * scaleX, 20* scaleY))); + img.Mutate(x => x.Fill(NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40, 100 * scaleX, 20 * scaleY))); img.Mutate(x => x.Fill(NamedColors.HotPink, new Rectangle(20 * scaleX, 0, 30 * scaleX, 100 * scaleY), new ImageSharp.GraphicsOptions(true) { BlenderMode = mode @@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { var scaleX = (img.Width / 100); var scaleY = (img.Height / 100); - img.Mutate(x => x.Fill(NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40* scaleY, 100 * scaleX, 20 * scaleY))); + img.Mutate(x => x.Fill(NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); img.Mutate(x => x.Fill(NamedColors.Black, new SixLabors.Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY), new ImageSharp.GraphicsOptions(true) { BlenderMode = mode diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs index e36396a4e9..eb8e48b7ea 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs @@ -5,6 +5,7 @@ using System; using System.Numerics; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Primitives; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs index 3902e874ce..58aebb2dfb 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs @@ -1,19 +1,15 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.IO; using System.Numerics; using SixLabors.ImageSharp.Drawing.Pens; -using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Shapes; using Xunit; -using ShapePath = SixLabors.Shapes.Path; namespace SixLabors.ImageSharp.Tests.Drawing { - using SixLabors.ImageSharp.Processing; - using SixLabors.ImageSharp.Processing.Overlays; - public class DrawPathTests : FileTestBase { [Fact] @@ -31,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Vector2(60, 10), new Vector2(10, 400)); - ShapePath p = new ShapePath(linerSegemnt, bazierSegment); + Path p = new Path(linerSegemnt, bazierSegment); image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -69,7 +65,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Vector2(60, 10), new Vector2(10, 400)); - ShapePath p = new ShapePath(linerSegemnt, bazierSegment); + Path p = new Path(linerSegemnt, bazierSegment); using (Image image = new Image(500, 500)) { diff --git a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs index da2589ed54..79bf918036 100644 --- a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs @@ -7,6 +7,8 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Overlays; + using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing diff --git a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs index 21113f48cb..48e3c62044 100644 --- a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs @@ -2,18 +2,18 @@ // Licensed under the Apache License, Version 2.0. using System.Numerics; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.Drawing.Processors; using Moq; using Xunit; using SixLabors.ImageSharp.Drawing.Brushes; +using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Tests.Drawing { - using SixLabors.ImageSharp.Processing; - public class FillRegionProcessorTests { [Theory] diff --git a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs index 8eb8d21592..6cfd89b7bf 100644 --- a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs @@ -1,12 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.IO; using System.Numerics; -using SixLabors.ImageSharp.Drawing; + using SixLabors.ImageSharp.Drawing.Pens; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Tests.Drawing; using SixLabors.Shapes; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/LineTests.cs b/tests/ImageSharp.Tests/Drawing/LineTests.cs index 7b26d9e1db..3659a4b283 100644 --- a/tests/ImageSharp.Tests/Drawing/LineTests.cs +++ b/tests/ImageSharp.Tests/Drawing/LineTests.cs @@ -1,11 +1,10 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.IO; using System.Numerics; -using SixLabors.ImageSharp.Drawing; + using SixLabors.ImageSharp.Drawing.Pens; -using SixLabors.ImageSharp.PixelFormats; + using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs index a88a5b09cd..28820ceb45 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs @@ -1,13 +1,11 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using System.Numerics; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Processors; -using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Shapes; using Xunit; @@ -28,7 +26,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths [Fact] public void CorrectlySetsBrushAndPath() { - this.operations.Fill(brush, path); + this.operations.Fill(this.brush, this.path); var processor = this.Verify>(); Assert.Equal(GraphicsOptions.Default, processor.Options); @@ -39,28 +37,28 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); - Assert.Equal(brush, processor.Brush); + Assert.Equal(this.brush, processor.Brush); } [Fact] public void CorrectlySetsBrushPathOptions() { - this.operations.Fill(brush, path, noneDefault); + this.operations.Fill(this.brush, this.path, this.noneDefault); var processor = this.Verify>(); - Assert.Equal(noneDefault, processor.Options); + Assert.Equal(this.noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); - Assert.Equal(brush, processor.Brush); + Assert.Equal(this.brush, processor.Brush); } [Fact] public void CorrectlySetsColorAndPath() { - this.operations.Fill(color, path); + this.operations.Fill(this.color, this.path); var processor = this.Verify>(); Assert.Equal(GraphicsOptions.Default, processor.Options); @@ -70,23 +68,23 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType>(processor.Brush); - Assert.Equal(color, brush.Color); + Assert.Equal(this.color, brush.Color); } [Fact] public void CorrectlySetsColorPathAndOptions() { - this.operations.Fill(color, path, noneDefault); + this.operations.Fill(this.color, this.path, this.noneDefault); var processor = this.Verify>(); - Assert.Equal(noneDefault, processor.Options); + Assert.Equal(this.noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType>(processor.Brush); - Assert.Equal(color, brush.Color); + Assert.Equal(this.color, brush.Color); } } } diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs index e8fad9d125..0b4a5e0bf2 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs @@ -8,6 +8,8 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Shapes; using Xunit; @@ -35,13 +37,13 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths public FillPathCollection() { - this.pathCollection = new PathCollection(path1, path2); + this.pathCollection = new PathCollection(this.path1, this.path2); } [Fact] public void CorrectlySetsBrushAndPath() { - this.operations.Fill(brush, pathCollection); + this.operations.Fill(this.brush, this.pathCollection); for (var i = 0; i < 2; i++) { @@ -55,33 +57,33 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); - Assert.Equal(brush, processor.Brush); + Assert.Equal(this.brush, processor.Brush); } } [Fact] public void CorrectlySetsBrushPathOptions() { - this.operations.Fill(brush, pathCollection, noneDefault); + this.operations.Fill(this.brush, this.pathCollection, this.noneDefault); for (var i = 0; i < 2; i++) { FillRegionProcessor processor = this.Verify>(i); - Assert.Equal(noneDefault, processor.Options); + Assert.Equal(this.noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); - Assert.Equal(brush, processor.Brush); + Assert.Equal(this.brush, processor.Brush); } } [Fact] public void CorrectlySetsColorAndPath() { - this.operations.Fill(color, pathCollection); + this.operations.Fill(this.color, this.pathCollection); for (var i = 0; i < 2; i++) { @@ -94,27 +96,27 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType>(processor.Brush); - Assert.Equal(color, brush.Color); + Assert.Equal(this.color, brush.Color); } } [Fact] public void CorrectlySetsColorPathAndOptions() { - this.operations.Fill(color, pathCollection, noneDefault); + this.operations.Fill(this.color, this.pathCollection, this.noneDefault); for (var i = 0; i < 2; i++) { FillRegionProcessor processor = this.Verify>(i); - Assert.Equal(noneDefault, processor.Options); + Assert.Equal(this.noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType>(processor.Brush); - Assert.Equal(color, brush.Color); + Assert.Equal(this.color, brush.Color); } } } diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs index b390c31069..2cd63217ff 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs @@ -1,13 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using System.Numerics; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Drawing; + using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Processors; -using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Shapes; using Xunit; @@ -18,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; SolidBrush brush = Brushes.Solid(Rgba32.HotPink); - SixLabors.Primitives.PointF[] path = new SixLabors.Primitives.PointF[] { + SixLabors.Primitives.PointF[] path = { new Vector2(10,10), new Vector2(20,10), new Vector2(20,10), @@ -29,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths [Fact] public void CorrectlySetsBrushAndPath() { - this.operations.FillPolygon(brush, path); + this.operations.FillPolygon(this.brush, this.path); FillRegionProcessor processor = this.Verify>(); @@ -39,28 +38,28 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segemnt = Assert.IsType(polygon.LineSegments[0]); - Assert.Equal(brush, processor.Brush); + Assert.Equal(this.brush, processor.Brush); } [Fact] public void CorrectlySetsBrushPathAndOptions() { - this.operations.FillPolygon(brush, path, noneDefault); + this.operations.FillPolygon(this.brush, this.path, this.noneDefault); FillRegionProcessor processor = this.Verify>(); - Assert.Equal(noneDefault, processor.Options); + Assert.Equal(this.noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segemnt = Assert.IsType(polygon.LineSegments[0]); - Assert.Equal(brush, processor.Brush); + Assert.Equal(this.brush, processor.Brush); } [Fact] public void CorrectlySetsColorAndPath() { - this.operations.FillPolygon(color, path); + this.operations.FillPolygon(this.color, this.path); FillRegionProcessor processor = this.Verify>(); @@ -71,24 +70,24 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths LinearLineSegment segemnt = Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType>(processor.Brush); - Assert.Equal(color, brush.Color); + Assert.Equal(this.color, brush.Color); } [Fact] public void CorrectlySetsColorPathAndOptions() { - this.operations.FillPolygon(color, path, noneDefault); + this.operations.FillPolygon(this.color, this.path, this.noneDefault); FillRegionProcessor processor = this.Verify>(); - Assert.Equal(noneDefault, processor.Options); + Assert.Equal(this.noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segemnt = Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType>(processor.Brush); - Assert.Equal(color, brush.Color); + Assert.Equal(this.color, brush.Color); } } } diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs index 05e6bb29b3..61c7b2b423 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs @@ -1,11 +1,10 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Processors; -using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Overlays; using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing.Paths @@ -58,7 +57,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths { this.operations.Fill(color, rectangle); FillRegionProcessor processor = this.Verify>(); - + Assert.Equal(GraphicsOptions.Default, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); diff --git a/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs b/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs index 5ca09ad1d2..d0912acee9 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs @@ -1,6 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.Primitives; + namespace SixLabors.ImageSharp.Tests.Drawing.Paths { using System; diff --git a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs index f2d5187e3d..4265aa4d60 100644 --- a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs @@ -1,21 +1,14 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; using System.Numerics; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Tests.Drawing; using SixLabors.Primitives; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; 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 baaa8fe2a3..6207a8b0d1 100644 --- a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs @@ -1,10 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.IO; -using System.Linq; using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Primitives; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs index 1fc1b172fb..70b896cf8a 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.IO; using System.Numerics; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Shapes; @@ -32,7 +31,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing using (Image image = provider.GetImage()) { - + image.Mutate(x => x .BackgroundColor(blue) .Fill(hotPink, new Polygon(new CubicBezierLineSegment(simplePath)))); @@ -53,7 +52,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Vector2(300, 400) }; - Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); + var color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); using (var image = provider.GetImage() as Image) { diff --git a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs index 59ddc43edc..a35bcb4f56 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs @@ -1,11 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.IO; using System.Numerics; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Tests.Drawing; + using SixLabors.Shapes; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs index fbb0f00957..1de6e59d67 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs @@ -2,13 +2,8 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; using System.Numerics; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Tests.Drawing; using SixLabors.Shapes; using Xunit; @@ -23,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByFilledPolygon() { string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); - SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { + SixLabors.Primitives.PointF[] simplePath = { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs index 3f138248eb..939a5bd65c 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs @@ -10,6 +10,7 @@ using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.Drawing.Paths; using SixLabors.Fonts; +using SixLabors.ImageSharp.Processing.Text; using SixLabors.Shapes; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs index d9fe1a76db..85234d0b54 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs @@ -10,6 +10,7 @@ using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.Drawing.Paths; using SixLabors.Fonts; +using SixLabors.ImageSharp.Processing.Text; using SixLabors.Shapes; using Xunit; @@ -187,7 +188,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text } [Fact] - public void BrushAppliesBeforPen() + public void BrushAppliesBeforePen() { this.operations.DrawText( "1", diff --git a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs index 079510c33a..908120d423 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs @@ -13,6 +13,8 @@ using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.Fonts; +using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Text; using SixLabors.Shapes; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs b/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs index 975622e43d..dbbfa186ea 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs @@ -8,6 +8,8 @@ using System.Numerics; using System.Threading.Tasks; using SixLabors.ImageSharp.Drawing; using SixLabors.Fonts; +using SixLabors.ImageSharp.Processing.Text; + using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing.Text diff --git a/tests/ImageSharp.Tests/Issues/Issue412.cs b/tests/ImageSharp.Tests/Issues/Issue412.cs index 77db68281c..8d4e360a5f 100644 --- a/tests/ImageSharp.Tests/Issues/Issue412.cs +++ b/tests/ImageSharp.Tests/Issues/Issue412.cs @@ -1,10 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Text; -using SixLabors.Primitives; -using SixLabors.ImageSharp.Advanced; +using SixLabors.Primitives; + using Xunit; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Overlays; namespace SixLabors.ImageSharp.Tests.Issues { @@ -14,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Issues { [Theory] [WithBlankImages(40, 30, PixelTypes.Rgba32)] - public void AllPixelsExpectedToBeRedWhenAntialisedDisabled(TestImageProvider provider) where TPixel : struct, IPixel + public void AllPixelsExpectedToBeRedWhenAntialiasedDisabled(TestImageProvider provider) where TPixel : struct, IPixel { using (var image = provider.GetImage()) { diff --git a/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs b/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs index ceb25d58ea..ddb9a6d1df 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs @@ -1,9 +1,6 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; -using SixLabors.Primitives; using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects @@ -20,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Effects var processor = this.Verify>(); Assert.Equal(GraphicsOptions.Default, processor.GraphicsOptions); - Assert.Equal(Rgba32.BlanchedAlmond, processor.Value); + Assert.Equal(Rgba32.BlanchedAlmond, processor.Color); } [Fact] @@ -30,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Effects var processor = this.Verify>(this.rect); Assert.Equal(GraphicsOptions.Default, processor.GraphicsOptions); - Assert.Equal(Rgba32.BlanchedAlmond, processor.Value); + Assert.Equal(Rgba32.BlanchedAlmond, processor.Color); } [Fact] @@ -40,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Effects var processor = this.Verify>(); Assert.Equal(this.options, processor.GraphicsOptions); - Assert.Equal(Rgba32.BlanchedAlmond, processor.Value); + Assert.Equal(Rgba32.BlanchedAlmond, processor.Color); } [Fact] @@ -50,7 +47,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Effects var processor = this.Verify>(this.rect); Assert.Equal(this.options, processor.GraphicsOptions); - Assert.Equal(Rgba32.BlanchedAlmond, processor.Value); + Assert.Equal(Rgba32.BlanchedAlmond, processor.Color); } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs index 9901661f4c..c069020718 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs @@ -4,6 +4,7 @@ using System; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Overlays; using Xunit.Abstractions; From b6bafd08275606c85d1ecad31c5167f0ac99ad9e Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 11 Mar 2018 03:30:38 +1100 Subject: [PATCH 12/18] Move Rgba32 inline with other pixel formats --- src/ImageSharp/ColorSpaces/Hsv.cs | 2 ++ src/ImageSharp/ColorSpaces/Rgb.cs | 2 ++ .../Common/Extensions/Vector4Extensions.cs | 2 ++ .../ArrayPoolMemoryManager.CommonFactoryMethods.cs | 4 +++- .../Generated/Rgba32.PixelOperations.Generated.cs | 5 ++--- .../Generated/Rgba32.PixelOperations.Generated.tt | 5 ++--- src/ImageSharp/PixelFormats/Rgba32.Definitions.cs | 6 ++---- .../PixelFormats/Rgba32.PixelOperations.cs | 3 +-- src/ImageSharp/PixelFormats/Rgba32.cs | 4 +--- tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs | 2 ++ tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs | 2 ++ tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs | 2 ++ tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs | 2 ++ .../General/PixelConversion_ConvertFromRgba32.cs | 3 +++ .../General/PixelConversion_ConvertToRgba32.cs | 3 +++ tests/ImageSharp.Benchmarks/Image/CopyPixels.cs | 2 ++ tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs | 2 ++ .../ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs | 2 ++ tests/ImageSharp.Benchmarks/Image/DecodeGif.cs | 2 ++ tests/ImageSharp.Benchmarks/Image/DecodePng.cs | 2 ++ tests/ImageSharp.Benchmarks/Image/EncodeBmp.cs | 2 ++ tests/ImageSharp.Benchmarks/Image/EncodeGif.cs | 2 ++ .../ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs | 2 ++ tests/ImageSharp.Benchmarks/Image/EncodePng.cs | 2 ++ tests/ImageSharp.Benchmarks/Image/Jpeg/DecodeJpeg.cs | 2 ++ .../Image/Jpeg/DecodeJpegMultiple.cs | 2 ++ tests/ImageSharp.Benchmarks/Image/Jpeg/EncodeJpeg.cs | 2 ++ .../Image/MultiImageBenchmarkBase.cs | 1 + tests/ImageSharp.Benchmarks/Samplers/Crop.cs | 2 ++ tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs | 2 ++ .../BaseImageOperationsExtensionTest.cs | 2 ++ tests/ImageSharp.Tests/Drawing/BeziersTests.cs | 2 ++ tests/ImageSharp.Tests/Drawing/DrawPathTests.cs | 1 + .../Drawing/FillRegionProcessorTests.cs | 1 + .../Drawing/LineComplexPolygonTests.cs | 1 + tests/ImageSharp.Tests/Drawing/LineTests.cs | 1 + tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs | 1 + tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs | 1 + .../ImageSharp.Tests/Drawing/Paths/FillRectangle.cs | 1 + tests/ImageSharp.Tests/Drawing/PolygonTests.cs | 2 ++ tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs | 1 + .../Drawing/SolidComplexPolygonTests.cs | 1 + tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs | 1 + .../Formats/Jpg/JpegProfilingBenchmarks.cs | 3 +++ .../Formats/Jpg/Utils/LibJpegTools.ComponentData.cs | 2 ++ .../Formats/Jpg/Utils/LibJpegTools.SpectralData.cs | 2 ++ tests/ImageSharp.Tests/Image/ImageLoadTests.cs | 1 + .../Image/ImageProcessingContextTests.cs | 2 ++ tests/ImageSharp.Tests/Image/ImageRotationTests.cs | 1 + tests/ImageSharp.Tests/ImageOperationTests.cs | 2 ++ .../Memory/ArrayPoolMemoryManagerTests.cs | 3 +++ .../PixelFormats/PixelOperationsTests.cs | 12 ++++++------ .../Processing/Effects/BackgroundColorTest.cs | 2 ++ .../Processing/Filters/BlackWhiteTest.cs | 1 + .../Processing/Filters/ColorBlindnessTest.cs | 1 + .../Processing/Filters/ContrastTest.cs | 1 + .../Processing/Filters/FilterTest.cs | 1 + .../Processing/Filters/GrayscaleTest.cs | 1 + .../Processing/Filters/OpacityTest.cs | 1 + .../Processing/Filters/SaturateTest.cs | 1 + .../ImageSharp.Tests/Processing/Overlays/GlowTest.cs | 2 ++ .../Processing/Overlays/VignetteTest.cs | 1 + .../Transforms/ResizeProfilingBenchmarks.cs | 2 ++ .../Processing/Transforms/AutoOrientTests.cs | 2 ++ .../Processing/Transforms/CropTest.cs | 1 + .../Processing/Transforms/EntropyCropTest.cs | 1 + .../Processing/Transforms/PadTest.cs | 1 + .../Processing/Transforms/ResizeTests.cs | 1 + .../Processing/Transforms/RotateFlipTests.cs | 1 + .../Processing/Transforms/RotateTests.cs | 5 +++-- .../Processing/Transforms/SkewTest.cs | 1 + .../TestUtilities/ImageComparison/PixelDifference.cs | 4 +++- 72 files changed, 126 insertions(+), 25 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Hsv.cs b/src/ImageSharp/ColorSpaces/Hsv.cs index 45ffd7f121..fdfbfe5dd1 100644 --- a/src/ImageSharp/ColorSpaces/Hsv.cs +++ b/src/ImageSharp/ColorSpaces/Hsv.cs @@ -6,6 +6,8 @@ using System.ComponentModel; using System.Numerics; using System.Runtime.CompilerServices; +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.ColorSpaces { /// diff --git a/src/ImageSharp/ColorSpaces/Rgb.cs b/src/ImageSharp/ColorSpaces/Rgb.cs index 53fa6086df..ac86cfbf06 100644 --- a/src/ImageSharp/ColorSpaces/Rgb.cs +++ b/src/ImageSharp/ColorSpaces/Rgb.cs @@ -6,6 +6,8 @@ using System.ComponentModel; using System.Numerics; using System.Runtime.CompilerServices; +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.ColorSpaces { /// diff --git a/src/ImageSharp/Common/Extensions/Vector4Extensions.cs b/src/ImageSharp/Common/Extensions/Vector4Extensions.cs index 8133ebb38e..88712a736f 100644 --- a/src/ImageSharp/Common/Extensions/Vector4Extensions.cs +++ b/src/ImageSharp/Common/Extensions/Vector4Extensions.cs @@ -5,6 +5,8 @@ using System; using System.Numerics; using System.Runtime.CompilerServices; +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp { /// diff --git a/src/ImageSharp/Memory/ArrayPoolMemoryManager.CommonFactoryMethods.cs b/src/ImageSharp/Memory/ArrayPoolMemoryManager.CommonFactoryMethods.cs index d1424870da..53d7fc0216 100644 --- a/src/ImageSharp/Memory/ArrayPoolMemoryManager.CommonFactoryMethods.cs +++ b/src/ImageSharp/Memory/ArrayPoolMemoryManager.CommonFactoryMethods.cs @@ -1,4 +1,6 @@ -namespace SixLabors.ImageSharp.Memory +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Memory { /// /// Contains common factory methods and configuration constants. diff --git a/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.cs index edf6a88e1f..c5ee6661f7 100644 --- a/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.cs @@ -2,19 +2,18 @@ // Licensed under the Apache License, Version 2.0. // -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.PixelFormats { using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; - using SixLabors.ImageSharp.PixelFormats; /// /// Provides optimized overrides for bulk operations. /// public partial struct Rgba32 { - internal partial class PixelOperations : PixelOperations + internal partial class PixelOperations { /// diff --git a/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.tt index d83e49f770..9dfec2cf90 100644 --- a/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.tt +++ b/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.tt @@ -57,19 +57,18 @@ // Licensed under the Apache License, Version 2.0. // -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.PixelFormats { using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; - using SixLabors.ImageSharp.PixelFormats; /// /// Provides optimized overrides for bulk operations. /// public partial struct Rgba32 { - internal partial class PixelOperations : PixelOperations + internal partial class PixelOperations { <# GeneratePackFromMethod("Rgb24", "Unsafe.As(ref dp) = sp; dp.A = 255;"); diff --git a/src/ImageSharp/PixelFormats/Rgba32.Definitions.cs b/src/ImageSharp/PixelFormats/Rgba32.Definitions.cs index b5fed5a357..032d0b5464 100644 --- a/src/ImageSharp/PixelFormats/Rgba32.Definitions.cs +++ b/src/ImageSharp/PixelFormats/Rgba32.Definitions.cs @@ -1,12 +1,10 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.PixelFormats { /// - /// Provides standardized deifinitions for named colors. + /// Provides standardized definitions for named colors. /// public partial struct Rgba32 { diff --git a/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs b/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs index 89a4aba264..d87820f847 100644 --- a/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs +++ b/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs @@ -6,9 +6,8 @@ using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.PixelFormats { /// /// Provides optimized overrides for bulk operations. diff --git a/src/ImageSharp/PixelFormats/Rgba32.cs b/src/ImageSharp/PixelFormats/Rgba32.cs index 83a35f1895..701de7770b 100644 --- a/src/ImageSharp/PixelFormats/Rgba32.cs +++ b/src/ImageSharp/PixelFormats/Rgba32.cs @@ -1,13 +1,11 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.PixelFormats { /// /// Packed pixel type containing four 8-bit unsigned normalized values ranging from 0 to 255. diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs index 9b7b8f4e62..97db3fc49d 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs @@ -8,6 +8,8 @@ using System.Drawing.Drawing2D; using System.IO; using System.Numerics; using BenchmarkDotNet.Attributes; + +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Overlays; diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs index 3f2a030504..c020fabf2b 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs @@ -8,6 +8,8 @@ using System.Drawing.Drawing2D; using BenchmarkDotNet.Attributes; using System.IO; using System.Numerics; + +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Overlays; diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs index a6f8b2c080..2ae104cd10 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs @@ -9,6 +9,8 @@ using System.IO; using System.Numerics; using SixLabors.Shapes; using BenchmarkDotNet.Attributes; + +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Overlays; diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs b/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs index b60a068f19..b0bee373b2 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs @@ -7,6 +7,8 @@ using System.Drawing; using System.Drawing.Drawing2D; using System.Numerics; using BenchmarkDotNet.Attributes; + +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Overlays; using CoreRectangle = SixLabors.Primitives.Rectangle; diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion_ConvertFromRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion_ConvertFromRgba32.cs index a1db525a69..f5bd135e12 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion_ConvertFromRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion_ConvertFromRgba32.cs @@ -1,4 +1,7 @@ // ReSharper disable InconsistentNaming + +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks.General { using System.Runtime.CompilerServices; diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion_ConvertToRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion_ConvertToRgba32.cs index 782c792393..5656904fe0 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion_ConvertToRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion_ConvertToRgba32.cs @@ -1,4 +1,7 @@ // ReSharper disable InconsistentNaming + +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks.General { using System.Runtime.CompilerServices; diff --git a/tests/ImageSharp.Benchmarks/Image/CopyPixels.cs b/tests/ImageSharp.Benchmarks/Image/CopyPixels.cs index 674aef84c1..7f16be8521 100644 --- a/tests/ImageSharp.Benchmarks/Image/CopyPixels.cs +++ b/tests/ImageSharp.Benchmarks/Image/CopyPixels.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks.Image { using System; diff --git a/tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs b/tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs index 142675fa7a..ea13efb55e 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks.Image { using System.Drawing; diff --git a/tests/ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs b/tests/ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs index e295aee732..b08adf4df6 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks.Image { using System.IO; diff --git a/tests/ImageSharp.Benchmarks/Image/DecodeGif.cs b/tests/ImageSharp.Benchmarks/Image/DecodeGif.cs index a65c9f9298..cc3401b580 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeGif.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks.Image { using System.Drawing; diff --git a/tests/ImageSharp.Benchmarks/Image/DecodePng.cs b/tests/ImageSharp.Benchmarks/Image/DecodePng.cs index eb13cf9290..f07e80a756 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodePng.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodePng.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks.Image { using System.Drawing; diff --git a/tests/ImageSharp.Benchmarks/Image/EncodeBmp.cs b/tests/ImageSharp.Benchmarks/Image/EncodeBmp.cs index 86994f2d35..68c84ab85f 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodeBmp.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodeBmp.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks.Image { using System.Drawing; diff --git a/tests/ImageSharp.Benchmarks/Image/EncodeGif.cs b/tests/ImageSharp.Benchmarks/Image/EncodeGif.cs index 7a6ddd79d7..e42881945a 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodeGif.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks.Image { using System.Drawing; diff --git a/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs b/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs index a8368e99b8..a4cc06e25f 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks.Image { using System.IO; diff --git a/tests/ImageSharp.Benchmarks/Image/EncodePng.cs b/tests/ImageSharp.Benchmarks/Image/EncodePng.cs index f81cc4d854..ffd810f289 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodePng.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodePng.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks.Image { using System.Drawing; diff --git a/tests/ImageSharp.Benchmarks/Image/Jpeg/DecodeJpeg.cs b/tests/ImageSharp.Benchmarks/Image/Jpeg/DecodeJpeg.cs index 6cb5f8a219..f090e828d4 100644 --- a/tests/ImageSharp.Benchmarks/Image/Jpeg/DecodeJpeg.cs +++ b/tests/ImageSharp.Benchmarks/Image/Jpeg/DecodeJpeg.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks.Image.Jpeg { using System.Drawing; diff --git a/tests/ImageSharp.Benchmarks/Image/Jpeg/DecodeJpegMultiple.cs b/tests/ImageSharp.Benchmarks/Image/Jpeg/DecodeJpegMultiple.cs index bc60c56696..cf0f0a54cf 100644 --- a/tests/ImageSharp.Benchmarks/Image/Jpeg/DecodeJpegMultiple.cs +++ b/tests/ImageSharp.Benchmarks/Image/Jpeg/DecodeJpegMultiple.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks.Image.Jpeg { using System.Collections.Generic; diff --git a/tests/ImageSharp.Benchmarks/Image/Jpeg/EncodeJpeg.cs b/tests/ImageSharp.Benchmarks/Image/Jpeg/EncodeJpeg.cs index 15861bd617..8a43c39329 100644 --- a/tests/ImageSharp.Benchmarks/Image/Jpeg/EncodeJpeg.cs +++ b/tests/ImageSharp.Benchmarks/Image/Jpeg/EncodeJpeg.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks.Image.Jpeg { using System.Drawing; diff --git a/tests/ImageSharp.Benchmarks/Image/MultiImageBenchmarkBase.cs b/tests/ImageSharp.Benchmarks/Image/MultiImageBenchmarkBase.cs index 2ed2d42c0d..9bf6d73b6d 100644 --- a/tests/ImageSharp.Benchmarks/Image/MultiImageBenchmarkBase.cs +++ b/tests/ImageSharp.Benchmarks/Image/MultiImageBenchmarkBase.cs @@ -3,6 +3,7 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Benchmarks.Image { diff --git a/tests/ImageSharp.Benchmarks/Samplers/Crop.cs b/tests/ImageSharp.Benchmarks/Samplers/Crop.cs index 166cf77fe2..d5ac6a6f10 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Crop.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Crop.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks { using System.Drawing; diff --git a/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs b/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs index 9a208e6159..569b5bc441 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Benchmarks { using System.IO; diff --git a/tests/ImageSharp.Tests/BaseImageOperationsExtensionTest.cs b/tests/ImageSharp.Tests/BaseImageOperationsExtensionTest.cs index ec46e66107..121d93dac8 100644 --- a/tests/ImageSharp.Tests/BaseImageOperationsExtensionTest.cs +++ b/tests/ImageSharp.Tests/BaseImageOperationsExtensionTest.cs @@ -4,6 +4,8 @@ using System; using System.Collections.Generic; using System.Text; + +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs index 9ab772208b..f9483e18bc 100644 --- a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs +++ b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs @@ -2,6 +2,8 @@ // Licensed under the Apache License, Version 2.0. using System.Numerics; + +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Overlays; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs index 58aebb2dfb..40b023e8d9 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs @@ -3,6 +3,7 @@ using System.Numerics; using SixLabors.ImageSharp.Drawing.Pens; +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Shapes; diff --git a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs index 48e3c62044..049ed7e1ff 100644 --- a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs @@ -7,6 +7,7 @@ using SixLabors.ImageSharp.Drawing.Processors; using Moq; using Xunit; using SixLabors.ImageSharp.Drawing.Brushes; +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Overlays; diff --git a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs index 6cfd89b7bf..76e109c623 100644 --- a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs @@ -4,6 +4,7 @@ using System.Numerics; using SixLabors.ImageSharp.Drawing.Pens; +using SixLabors.ImageSharp.PixelFormats; using SixLabors.Shapes; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/LineTests.cs b/tests/ImageSharp.Tests/Drawing/LineTests.cs index 3659a4b283..2048b6fe90 100644 --- a/tests/ImageSharp.Tests/Drawing/LineTests.cs +++ b/tests/ImageSharp.Tests/Drawing/LineTests.cs @@ -4,6 +4,7 @@ using System.Numerics; using SixLabors.ImageSharp.Drawing.Pens; +using SixLabors.ImageSharp.PixelFormats; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs index 28820ceb45..cf818765d3 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs @@ -4,6 +4,7 @@ using System.Numerics; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Processors; +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Shapes; diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs index 2cd63217ff..9eacdff294 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs @@ -5,6 +5,7 @@ using System.Numerics; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Processors; +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Shapes; diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs index 61c7b2b423..429da58264 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Processors; +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing.Overlays; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs index 4265aa4d60..318ce4fce1 100644 --- a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs @@ -2,6 +2,8 @@ // Licensed under the Apache License, Version 2.0. using System.Numerics; + +using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Overlays; diff --git a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs index 6207a8b0d1..8fe26fff59 100644 --- a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Drawing.Brushes; +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Primitives; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs index a35bcb4f56..759947eb0c 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs @@ -3,6 +3,7 @@ using System.Numerics; +using SixLabors.ImageSharp.PixelFormats; using SixLabors.Shapes; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs index 1de6e59d67..941c358b4a 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs @@ -4,6 +4,7 @@ using System; using System.Numerics; using SixLabors.ImageSharp.Drawing.Brushes; +using SixLabors.ImageSharp.PixelFormats; using SixLabors.Shapes; using Xunit; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs index 6652db577c..4eca62cab0 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs @@ -2,6 +2,9 @@ // Licensed under the Apache License, Version 2.0. // ReSharper disable InconsistentNaming + +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Tests.Formats.Jpg { using System; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs index 9e287eb2d7..30f0088861 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs @@ -1,3 +1,5 @@ +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils { using System; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs index 5a4db87b9b..a353b288ab 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs @@ -1,3 +1,5 @@ +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils { using System; diff --git a/tests/ImageSharp.Tests/Image/ImageLoadTests.cs b/tests/ImageSharp.Tests/Image/ImageLoadTests.cs index 97274e98b3..35d6b57226 100644 --- a/tests/ImageSharp.Tests/Image/ImageLoadTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageLoadTests.cs @@ -8,6 +8,7 @@ using SixLabors.ImageSharp.IO; using Moq; using Xunit; using SixLabors.ImageSharp.Advanced; +using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Tests { diff --git a/tests/ImageSharp.Tests/Image/ImageProcessingContextTests.cs b/tests/ImageSharp.Tests/Image/ImageProcessingContextTests.cs index b60fc5ff20..4e149da503 100644 --- a/tests/ImageSharp.Tests/Image/ImageProcessingContextTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageProcessingContextTests.cs @@ -2,6 +2,8 @@ // Licensed under the Apache License, Version 2.0. //using SixLabors.ImageSharp.Processing; + +using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; using Xunit; diff --git a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs index 29c1cb871c..8310d67e83 100644 --- a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; using Xunit; diff --git a/tests/ImageSharp.Tests/ImageOperationTests.cs b/tests/ImageSharp.Tests/ImageOperationTests.cs index 5bc846c3b6..61705fe4e6 100644 --- a/tests/ImageSharp.Tests/ImageOperationTests.cs +++ b/tests/ImageSharp.Tests/ImageOperationTests.cs @@ -8,6 +8,8 @@ using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors; using Moq; +using SixLabors.ImageSharp.PixelFormats; + using Xunit; namespace SixLabors.ImageSharp.Tests diff --git a/tests/ImageSharp.Tests/Memory/ArrayPoolMemoryManagerTests.cs b/tests/ImageSharp.Tests/Memory/ArrayPoolMemoryManagerTests.cs index c73ce96313..11cb861578 100644 --- a/tests/ImageSharp.Tests/Memory/ArrayPoolMemoryManagerTests.cs +++ b/tests/ImageSharp.Tests/Memory/ArrayPoolMemoryManagerTests.cs @@ -2,6 +2,9 @@ // Licensed under the Apache License, Version 2.0. // ReSharper disable InconsistentNaming + +using SixLabors.ImageSharp.PixelFormats; + namespace SixLabors.ImageSharp.Tests.Memory { using System; diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs index c0039bb37c..7a942246e3 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats { public partial class PixelOperationsTests { - public class Rgba32 : PixelOperationsTests + public class Rgba32 : PixelOperationsTests { public Rgba32(ITestOutputHelper output) : base(output) @@ -25,19 +25,19 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats [Fact] public void IsSpecialImplementation() { - Assert.IsType(PixelOperations.Instance); + Assert.IsType(PixelOperations.Instance); } [Fact] public void ToVector4SimdAligned() { - ImageSharp.Rgba32[] source = CreatePixelTestData(64); + ImageSharp.PixelFormats.Rgba32[] source = CreatePixelTestData(64); Vector4[] expected = CreateExpectedVector4Data(source); TestOperation( source, expected, - (s, d) => ImageSharp.Rgba32.PixelOperations.ToVector4SimdAligned(s, d.Span, 64) + (s, d) => ImageSharp.PixelFormats.Rgba32.PixelOperations.ToVector4SimdAligned(s, d.Span, 64) ); } @@ -50,14 +50,14 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats int times = 200000; int count = 1024; - using (IBuffer source = Configuration.Default.MemoryManager.Allocate(count)) + using (IBuffer source = Configuration.Default.MemoryManager.Allocate(count)) using (IBuffer dest = Configuration.Default.MemoryManager.Allocate(count)) { this.Measure( times, () => { - PixelOperations.Instance.ToVector4(source.Span, dest.Span, count); + PixelOperations.Instance.ToVector4(source.Span, dest.Span, count); }); } } diff --git a/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs b/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs index ddb9a6d1df..d7204d0cf4 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs @@ -1,6 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; + using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects diff --git a/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs b/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs index 2a3d6e0cfe..db10c16b11 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; using Xunit; diff --git a/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs b/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs index cfe716c737..29d18897fb 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities; using Xunit; diff --git a/tests/ImageSharp.Tests/Processing/Filters/ContrastTest.cs b/tests/ImageSharp.Tests/Processing/Filters/ContrastTest.cs index dab4ec5854..2f9a8331de 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/ContrastTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/ContrastTest.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; using Xunit; diff --git a/tests/ImageSharp.Tests/Processing/Filters/FilterTest.cs b/tests/ImageSharp.Tests/Processing/Filters/FilterTest.cs index 6fa22030a8..77325b24cc 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/FilterTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/FilterTest.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors; using Xunit; diff --git a/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs b/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs index ee649eaa60..ad12d07a85 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities; using Xunit; diff --git a/tests/ImageSharp.Tests/Processing/Filters/OpacityTest.cs b/tests/ImageSharp.Tests/Processing/Filters/OpacityTest.cs index 6d217fa152..f40f927188 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/OpacityTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/OpacityTest.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; using Xunit; diff --git a/tests/ImageSharp.Tests/Processing/Filters/SaturateTest.cs b/tests/ImageSharp.Tests/Processing/Filters/SaturateTest.cs index 7d115f1ad2..72ab0fe70f 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/SaturateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/SaturateTest.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; using Xunit; diff --git a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs index 0d4695c29f..4165ea24ef 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs @@ -2,6 +2,8 @@ // Licensed under the Apache License, Version 2.0. using System; + +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.ImageSharp.Processing.Overlays.Processors; diff --git a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs index 665b6cf1ca..bd42cf14e0 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.ImageSharp.Processing.Overlays.Processors; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs index ab0efbd708..bbb0b1db96 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs @@ -4,6 +4,8 @@ using System; using System.IO; using System.Text; + +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; diff --git a/tests/ImageSharp.Tests/Processing/Transforms/AutoOrientTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/AutoOrientTests.cs index 92d4f030ba..d01e84220e 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/AutoOrientTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/AutoOrientTests.cs @@ -1,6 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; + using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Transforms diff --git a/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs index 2cc0484de9..78b6852e47 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms; using SixLabors.ImageSharp.Processing.Transforms.Processors; using SixLabors.Primitives; diff --git a/tests/ImageSharp.Tests/Processing/Transforms/EntropyCropTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/EntropyCropTest.cs index 8ddb760791..9c2176b25b 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/EntropyCropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/EntropyCropTest.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms; using SixLabors.ImageSharp.Processing.Transforms.Processors; using Xunit; diff --git a/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs index 46fc027126..6d7816f59d 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms.Resamplers; using Xunit; diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs index f9e09657cd..853f4b3e65 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms; using SixLabors.ImageSharp.Processing.Transforms.Processors; using SixLabors.ImageSharp.Processing.Transforms.Resamplers; diff --git a/tests/ImageSharp.Tests/Processing/Transforms/RotateFlipTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/RotateFlipTests.cs index d1f7783104..3d443b70c3 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/RotateFlipTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/RotateFlipTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Transforms; using SixLabors.ImageSharp.Processing.Transforms.Processors; using Xunit; diff --git a/tests/ImageSharp.Tests/Processing/Transforms/RotateTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/RotateTests.cs index 0fbc9379a1..742f633c08 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/RotateTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/RotateTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors; using Xunit; @@ -28,12 +29,12 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms [InlineData(RotateType.Rotate90, 90)] [InlineData(RotateType.Rotate180, 180)] [InlineData(RotateType.Rotate270, 270)] - public void RotateRotateTypeRotateProcessorWithAnglesConvertedFromEnum(RotateType angle, float expectedangle) + public void RotateRotateTypeRotateProcessorWithAnglesConvertedFromEnum(RotateType angle, float expectedAngle) { this.operations.Rotate(angle); // is this api needed ??? RotateProcessor processor = this.Verify>(); - Assert.Equal(expectedangle, processor.Degrees); + Assert.Equal(expectedAngle, processor.Degrees); } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Processing/Transforms/SkewTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/SkewTest.cs index a4da0cf2f6..bd0dfacd98 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/SkewTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/SkewTest.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; using Xunit; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/PixelDifference.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/PixelDifference.cs index fcfb31d682..97886fdec3 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/PixelDifference.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/PixelDifference.cs @@ -1,4 +1,6 @@ -namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison { using SixLabors.Primitives; From a63bb0b63e7aa72144c3d34b36d6331b46482608 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 11 Mar 2018 22:41:34 +1100 Subject: [PATCH 13/18] Add LaplacianKernelFactory tests --- .../Processors/LaplacianKernelFactoryTests.cs | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs diff --git a/tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs b/tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs new file mode 100644 index 0000000000..439632210f --- /dev/null +++ b/tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs @@ -0,0 +1,68 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using System; +using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Convolution.Processors; +using Xunit; + +namespace SixLabors.ImageSharp.Tests.Processing.Convolution.Processors +{ + public class LaplacianKernelFactoryTests + { + private static readonly ApproximateFloatComparer ApproximateComparer = new ApproximateFloatComparer(0.0001F); + + private static readonly DenseMatrix Expected3x3Matrix = new DenseMatrix( + new float[,] + { + { -1, -1, -1 }, + { -1, 8, -1 }, + { -1, -1, -1 } + }); + + private static readonly DenseMatrix Expected5x5Matrix = new DenseMatrix( + new float[,] + { + { -1, -1, -1,-1, -1 }, + { -1, -1, -1,-1, -1 }, + { -1, -1, 24,-1, -1 }, + { -1, -1, -1,-1, -1 }, + { -1, -1, -1,-1, -1 } + }); + + [Fact] + public void LaplacianKernelFactoryOutOfRangeThrows() + { + Assert.Throws(() => + { + LaplacianKernelFactory.CreateKernel(2); + }); + } + + [Fact] + public void LaplacianKernelFactoryCreatesCorrect3x3Matrix() + { + DenseMatrix actual = LaplacianKernelFactory.CreateKernel(3); + for (int y = 0; y < actual.Rows; y++) + { + for (int x = 0; x < actual.Columns; x++) + { + Assert.Equal(Expected3x3Matrix[y, x], actual[y, x], ApproximateComparer); + } + } + } + + [Fact] + public void LaplacianKernelFactoryCreatesCorrect5x5Matrix() + { + DenseMatrix actual = LaplacianKernelFactory.CreateKernel(5); + for (int y = 0; y < actual.Rows; y++) + { + for (int x = 0; x < actual.Columns; x++) + { + Assert.Equal(Expected5x5Matrix[y, x], actual[y, x], ApproximateComparer); + } + } + } + } +} \ No newline at end of file From 3d8f9c23e92f9b9b9983298b9714ed206444f177 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 12 Mar 2018 00:39:34 +1100 Subject: [PATCH 14/18] Move Bounds/Size to IImageInfo extension methods --- src/ImageSharp/IImage.cs | 12 --------- src/ImageSharp/ImageInfoExtensions.cs | 27 +++++++++++++++++++ src/ImageSharp/Image{TPixel}.cs | 9 +------ src/ImageSharp/MetaData/ImageMetaData.cs | 2 -- tests/ImageSharp.Tests/ImageInfoTests.cs | 34 ++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 22 deletions(-) create mode 100644 src/ImageSharp/ImageInfoExtensions.cs create mode 100644 tests/ImageSharp.Tests/ImageInfoTests.cs diff --git a/src/ImageSharp/IImage.cs b/src/ImageSharp/IImage.cs index 4612daa2d4..b9e2cee616 100644 --- a/src/ImageSharp/IImage.cs +++ b/src/ImageSharp/IImage.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. using System; -using SixLabors.Primitives; namespace SixLabors.ImageSharp { @@ -11,16 +10,5 @@ namespace SixLabors.ImageSharp /// public interface IImage : IImageInfo, IDisposable { - /// - /// Gets the size of the image. - /// - /// The - Size Size(); - - /// - /// Gets the bounds of the image. - /// - /// The - Rectangle Bounds(); } } \ No newline at end of file diff --git a/src/ImageSharp/ImageInfoExtensions.cs b/src/ImageSharp/ImageInfoExtensions.cs new file mode 100644 index 0000000000..0f2b2ba975 --- /dev/null +++ b/src/ImageSharp/ImageInfoExtensions.cs @@ -0,0 +1,27 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.Primitives; + +namespace SixLabors.ImageSharp +{ + /// + /// Extension methods that allow the addition of geometry calculating methods to the type + /// + public static class ImageInfoExtensions + { + /// + /// Gets the bounds of the image. + /// + /// The image info + /// The + public static Size Size(this IImageInfo info) => new Size(info.Width, info.Height); + + /// + /// Gets the bounds of the image. + /// + /// The image info + /// The + public static Rectangle Bounds(this IImageInfo info) => new Rectangle(0, 0, info.Width, info.Height); + } +} diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs index 66ae13db89..78a091e414 100644 --- a/src/ImageSharp/Image{TPixel}.cs +++ b/src/ImageSharp/Image{TPixel}.cs @@ -10,7 +10,6 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.MetaData; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.Primitives; namespace SixLabors.ImageSharp { @@ -18,7 +17,7 @@ namespace SixLabors.ImageSharp /// Encapsulates an image, which consists of the pixel data for a graphics image and its attributes. /// /// The pixel format. - public sealed partial class Image : IImage, IConfigurable + public sealed class Image : IImage, IConfigurable where TPixel : struct, IPixel { private readonly Configuration configuration; @@ -123,12 +122,6 @@ namespace SixLabors.ImageSharp set => this.PixelSource.PixelBuffer[x, y] = value; } - /// - public Size Size() => new Size(this.Width, this.Height); - - /// - public Rectangle Bounds() => new Rectangle(0, 0, this.Width, this.Height); - /// /// Saves the image to the given stream using the given image encoder. /// diff --git a/src/ImageSharp/MetaData/ImageMetaData.cs b/src/ImageSharp/MetaData/ImageMetaData.cs index e36f2a69f2..9613e9b465 100644 --- a/src/ImageSharp/MetaData/ImageMetaData.cs +++ b/src/ImageSharp/MetaData/ImageMetaData.cs @@ -2,8 +2,6 @@ // Licensed under the Apache License, Version 2.0. using System.Collections.Generic; -using SixLabors.ImageSharp.Formats; -using SixLabors.ImageSharp.Formats.Gif; using SixLabors.ImageSharp.MetaData.Profiles.Exif; using SixLabors.ImageSharp.MetaData.Profiles.Icc; diff --git a/tests/ImageSharp.Tests/ImageInfoTests.cs b/tests/ImageSharp.Tests/ImageInfoTests.cs new file mode 100644 index 0000000000..91f6804c0f --- /dev/null +++ b/tests/ImageSharp.Tests/ImageInfoTests.cs @@ -0,0 +1,34 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Formats; +using SixLabors.ImageSharp.MetaData; +using SixLabors.Primitives; + +using Xunit; + +namespace SixLabors.ImageSharp.Tests +{ + public class ImageInfoTests + { + [Fact] + public void ImageInfoInitializesCorrectly() + { + const int Width = 50; + const int Height = 60; + var size = new Size(Width, Height); + var rectangle = new Rectangle(0, 0, Width, Height); + var pixelType = new PixelTypeInfo(8); + var meta = new ImageMetaData(); + + var info = new ImageInfo(pixelType, Width, Height, meta); + + Assert.Equal(pixelType, info.PixelType); + Assert.Equal(Width, info.Width); + Assert.Equal(Height, info.Height); + Assert.Equal(size, info.Size()); + Assert.Equal(rectangle, info.Bounds()); + Assert.Equal(meta, info.MetaData); + } + } +} From 70ed0ee1ec5d28bbc99630c105c092a9b776e517 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 13 Mar 2018 00:34:52 +1100 Subject: [PATCH 15/18] New logo --- build/icons/imagesharp-logo-128.png | 4 ++-- build/icons/imagesharp-logo-256.png | 4 ++-- build/icons/imagesharp-logo-32.png | 4 ++-- build/icons/imagesharp-logo-512.png | 4 ++-- build/icons/imagesharp-logo-64.png | 4 ++-- build/icons/imagesharp-logo-heading.png | 3 --- build/icons/imagesharp-logo.png | 4 ++-- build/icons/imagesharp-logo.svg | 2 +- 8 files changed, 13 insertions(+), 16 deletions(-) delete mode 100644 build/icons/imagesharp-logo-heading.png diff --git a/build/icons/imagesharp-logo-128.png b/build/icons/imagesharp-logo-128.png index f825a4034e..5c2079144f 100644 --- a/build/icons/imagesharp-logo-128.png +++ b/build/icons/imagesharp-logo-128.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e0f7d4c9396d4c7fe8173057c44cc2c0ecc24e52b52ce67c97dd11a7ac6e79ed -size 8113 +oid sha256:148a268c589b628f5d0b5af0e86911a0b393c35b8b25233c71553657c88e0b96 +size 7568 diff --git a/build/icons/imagesharp-logo-256.png b/build/icons/imagesharp-logo-256.png index 3ee8e026f2..e38807ae1e 100644 --- a/build/icons/imagesharp-logo-256.png +++ b/build/icons/imagesharp-logo-256.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7583dab9f399b7b9a7f69fc87086caa439249a705b058d6bfbd88238cfd95d4e -size 16613 +oid sha256:7e4b2ff72aef1979500cd130c28490a00be116bb833bc96ca30c85dc0596099c +size 15413 diff --git a/build/icons/imagesharp-logo-32.png b/build/icons/imagesharp-logo-32.png index fd7cbfa9c3..273b171eb2 100644 --- a/build/icons/imagesharp-logo-32.png +++ b/build/icons/imagesharp-logo-32.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c2b4b7ede0bf2fb4a9d028c9c4e930ab092b8c45689dd288ed1e419b5207048b -size 1904 +oid sha256:021c12313afbdc65f58bfea8c7b436d5c2102513bb63d9e64ee2b61a1344c56a +size 1799 diff --git a/build/icons/imagesharp-logo-512.png b/build/icons/imagesharp-logo-512.png index f1de1fb956..707dc9a35b 100644 --- a/build/icons/imagesharp-logo-512.png +++ b/build/icons/imagesharp-logo-512.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cd9c567ef861075fcaef709577e87017b5834556df5fc6ff51c4ded8972568a8 -size 35069 +oid sha256:3ae54ae0035df1f8f1459081e2f1d5cceda6f88cca6ec015d8c0209bf0d34edf +size 32534 diff --git a/build/icons/imagesharp-logo-64.png b/build/icons/imagesharp-logo-64.png index e326b9c3a8..17577772eb 100644 --- a/build/icons/imagesharp-logo-64.png +++ b/build/icons/imagesharp-logo-64.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:28a0995e02d0535a13d08997d36cc7b4df95760f9499396b209ad2c7d73ccef6 -size 3962 +oid sha256:92896854265693f28f9a503b9093cb2c9a4a9b329f310732efdd9c6f6c3761bc +size 3736 diff --git a/build/icons/imagesharp-logo-heading.png b/build/icons/imagesharp-logo-heading.png deleted file mode 100644 index 0fe1322052..0000000000 --- a/build/icons/imagesharp-logo-heading.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9480cb9ac66963e717b7e89666375e8bb23183e456067fd7d445ffb3c182b425 -size 11390 diff --git a/build/icons/imagesharp-logo.png b/build/icons/imagesharp-logo.png index f1de1fb956..707dc9a35b 100644 --- a/build/icons/imagesharp-logo.png +++ b/build/icons/imagesharp-logo.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cd9c567ef861075fcaef709577e87017b5834556df5fc6ff51c4ded8972568a8 -size 35069 +oid sha256:3ae54ae0035df1f8f1459081e2f1d5cceda6f88cca6ec015d8c0209bf0d34edf +size 32534 diff --git a/build/icons/imagesharp-logo.svg b/build/icons/imagesharp-logo.svg index cd4dfa117d..620287457a 100644 --- a/build/icons/imagesharp-logo.svg +++ b/build/icons/imagesharp-logo.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file From acb7d1e988b4e78c97323ade023c76353265819d Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 13 Mar 2018 12:30:27 +1100 Subject: [PATCH 16/18] Update readme, remove old docs folder, and features [skip ci] Features are too much work to keep track of. API docs should suffice. --- README.md | 49 ++++++++-------- features.md | 149 ------------------------------------------------- input/about.md | 3 - 3 files changed, 27 insertions(+), 174 deletions(-) delete mode 100644 features.md delete mode 100644 input/about.md diff --git a/README.md b/README.md index d9d2628bb7..de95bdac45 100644 --- a/README.md +++ b/README.md @@ -4,31 +4,32 @@ ImageSharp

- GitHub license - Gitter - Twitter - OpenCollective - OpenCollective + GitHub license + Gitter + Twitter + OpenCollective + OpenCollective ### **ImageSharp** is a new, fully featured, fully managed, cross-platform, 2D graphics API. -Without the use of `System.Drawing` we have been able to develop something much more flexible, easier to code against, and much, much less prone to memory leaks. Gone are system-wide process-locks; ImageSharp images are thread-safe and fully supported in web environments. +Designed to democratize image processing, ImageSharp brings you an incredibly powerful yet beautifully simple API. -Built against .Net Standard 1.1 ImageSharp can be used in device, cloud, and embedded/IoT scenarios. - -### Questions? +Compared to `System.Drawing` we have been able to develop something much more flexible, easier to code against, and much, much less prone to memory leaks. Gone are system-wide process-locks; ImageSharp images are thread-safe and fully supported in web environments. -Do you have questions? We are happy to help! Please [join our gitter channel](https://gitter.im/ImageSharp/General), or ask them on [stackoverflow](https://stackoverflow.com) using the `ImageSharp` tag. +Built against .Net Standard 1.1 ImageSharp can be used in device, cloud, and embedded/IoT scenarios. ### Installation +Install stable releases via Nuget;evelopment releases are available via MyGet. + | Package Name | Release (NuGet) | Nightly (MyGet) | |--------------------------------|-----------------|-----------------| | `SixLabors.ImageSharp` | [![NuGet](https://img.shields.io/nuget/v/SixLabors.ImageSharp.svg)](https://www.nuget.org/packages/SixLabors.ImageSharp/) | [![MyGet](https://img.shields.io/myget/sixlabors/v/SixLabors.ImageSharp.svg)](https://www.myget.org/feed/sixlabors/package/nuget/SixLabors.ImageSharp) | | `SixLabors.ImageSharp.Drawing` | [![NuGet](https://img.shields.io/nuget/v/SixLabors.ImageSharp.Drawing.svg)](https://www.nuget.org/packages/SixLabors.ImageSharp.Drawing/) | [![MyGet](https://img.shields.io/myget/sixlabors/v/SixLabors.ImageSharp.Drawing.svg)](https://www.myget.org/feed/sixlabors/package/nuget/SixLabors.ImageSharp.Drawing) | ### Packages + The **ImageSharp** library is made up of multiple packages: - **SixLabors.ImageSharp** - Contains the generic `Image` class, PixelFormats, Primitives, Configuration, and other core functionality. @@ -48,31 +49,37 @@ The **ImageSharp** library is made up of multiple packages: |**Linux/Mac**|[![Build Status](https://travis-ci.org/SixLabors/ImageSharp.svg)](https://travis-ci.org/SixLabors/ImageSharp)|[![Code coverage](https://codecov.io/gh/SixLabors/ImageSharp/branch/master/graph/badge.svg)](https://codecov.io/gh/SixLabors/ImageSharp)| |**Windows** |[![Build Status](https://ci.appveyor.com/api/projects/status/m9pn907xdah3ca39/branch/master?svg=true)](https://ci.appveyor.com/project/six-labors/imagesharp/branch/master)|[![Code coverage](https://codecov.io/gh/SixLabors/ImageSharp/branch/master/graph/badge.svg)](https://codecov.io/gh/SixLabors/ImageSharp)| -### Features +### Questions? -There's plenty there and more coming. Check out the [current features](features.md)! +Do you have questions? We are happy to help! Please [join our gitter channel](https://gitter.im/ImageSharp/General), or ask them on [stackoverflow](https://stackoverflow.com) using the `ImageSharp` tag. ### API -Here's an example of the code required to resize an image using the default Bicubic resampler then turn the colors into their grayscale equivalent using the BT709 standard matrix. +API documentation is available at [https://sixlabors.github.io/docs/](https://sixlabors.github.io/docs/) + +Our API is designed to be simple to consume. Here's an example of the code required to resize an image using the default Bicubic resampler then turn the colors into their grayscale equivalent using the BT709 standard matrix. On platforms supporting netstandard 1.3+ + ```csharp -// Image.Load(string path) is a shortcut for our default type. Other pixel formats use Image.Load(string path)) +// Image.Load(string path) is a shortcut for our default type. +// Other pixel formats use Image.Load(string path)) using (Image image = Image.Load("foo.jpg")) { image.Mutate(x => x .Resize(image.Width / 2, image.Height / 2) .Grayscale()); - image.Save("bar.jpg"); // automatic encoder selected based on extension. + image.Save("bar.jpg"); // Automatic encoder selected based on extension. } ``` -on netstandard 1.1 - 1.2 +On netstandard 1.1 - 1.2 + ```csharp -// Image.Load(Stream stream) is a shortcut for our default type. Other pixel formats use Image.Load(Stream stream)) +// Image.Load(Stream stream) is a shortcut for our default type. +// Other pixel formats use Image.Load(Stream stream)) using (FileStream stream = File.OpenRead("foo.jpg")) using (FileStream output = File.OpenWrite("bar.jpg")) -using (Image image = Image.Load(stream)) +using (Image image = Image.Load(stream)) { image.Mutate(x => x .Resize(image.Width / 2, image.Height / 2) @@ -81,7 +88,7 @@ using (Image image = Image.Load(stream)) } ``` -Setting individual pixel values can be perfomed as follows: +Setting individual pixel values can be performed as follows: ```csharp // Individual pixels @@ -93,9 +100,7 @@ using (Image image = new Image(400, 400)) `Rgba32` is our default PixelFormat, equivalent to `System.Drawing Color`. For advanced pixel format usage there are multiple [PixelFormat implementations](https://github.com/SixLabors/ImageSharp/tree/master/src/ImageSharp/PixelFormats) available allowing developers to implement their own color models in the same manner as Microsoft XNA Game Studio and MonoGame. -All in all this should allow image processing to be much more accessible to developers which has always been my goal from the start. - -**Check out [this blog post](https://sixlabors.com/blog/announcing-imagesharp-beta-1/) or our [Samples Repository](https://github.com/SixLabors/Samples/tree/master/ImageSharp) for more examples!** +**Check out this [blog post](https://sixlabors.com/blog/announcing-imagesharp-beta-1/) or our [Samples Repository](https://github.com/SixLabors/Samples/tree/master/ImageSharp) for more examples!** ### Manual build diff --git a/features.md b/features.md deleted file mode 100644 index 1e35b88e0d..0000000000 --- a/features.md +++ /dev/null @@ -1,149 +0,0 @@ - -# Features - -### What works so far/ What is planned? - -We've achieved a lot so far and hope to do a lot more in the future. We're always looking for help so please pitch in! - -- **Encoding/decoding of image formats (plugable).** - - [x] Jpeg (Includes Subsampling. Progressive writing required) - - [x] Bmp (Read: 32bit, 24bit, 16 bit. Write: 32bit, 24bit just now) - - [x] Png (Read: Rgb, Rgba, Grayscale, Grayscale + alpha, Palette. Write: Rgb, Rgba, Grayscale, Grayscale + alpha, Palette) Supports interlaced decoding - - [x] Gif (Includes animated) - - [ ] Tiff (Help needed) -- **Metadata** - - [x] EXIF Read/Write (Jpeg just now) - - [ ] ICC (In Progress) -- **Quantizers (IQuantizer with alpha channel support, dithering, and thresholding)** - - [x] Octree - - [x] Xiaolin Wu - - [x] Palette -- **DIthering (Error diffusion and Ordered)** - - [x] Atkinson - - [x] Burks - - [x] FloydSteinburg - - [x] JarvisJudiceNinke - - [x] Sieera2 - - [x] Sierra3 - - [x] SerraLite - - [x] Bayer - - [x] Ordered -- **Basic color structs with implicit operators.** - - [x] Bgra32 - - [x] CIE Lab - - [x] CIE XYZ - - [x] CMYK - - [x] HSV - - [x] HSL - - [x] YCbCr -- **IPackedPixel representations of color models. Compatible with Microsoft XNA Game Studio and MonoGame IPackedVector\.** - - [x] Alpha8 - - [x] Argb32 - - [x] Bgr565 - - [x] Bgra444 - - [x] Bgra565 - - [x] Byte4 - - [x] HalfSingle - - [x] HalfVector2 - - [x] HalfVector4 - - [x] NormalizedByte2 - - [x] NormalizedByte4 - - [x] NormalizedShort2 - - [x] NormalizedShort4 - - [x] Rg32 - - [x] Rgba1010102 - - [x] Rgba32 - 32bit color in RGBA order - Our default pixel format. - - [x] Rgba64 - - [x] RgbaVector - - [x] Short2 - - [x] Short4 -- **Basic shape primitives.** - - [x] Rectangle - - [x] Size - - [x] Point - - [x] Ellipse -- **Resampling algorithms. (Optional gamma correction, resize modes, Performance improvements?)** - - [x] Box - - [x] Bicubic - - [x] Lanczos2 - - [x] Lanczos3 - - [x] Lanczos5 - - [x] Lanczos8 - - [x] MitchelNetravali - - [x] Nearest Neighbour - - [x] Robidoux - - [x] Robidoux Sharp - - [x] Spline - - [x] Triangle - - [x] Welch -- **Padding** - - [x] Pad - - [x] ResizeMode.Pad - - [x] ResizeMode.BoxPad -- **Cropping** - - [x] Rectangular Crop - - [ ] Elliptical Crop - - [x] Entropy Crop - - [x] ResizeMode.Crop -- **Rotation/Skew** - - [x] Flip (90, 270, FlipType etc) - - [x] Rotate by angle and center point (Expandable canvas). - - [x] Skew by x/y angles and center point (Expandable canvas). -- **ColorMatrix operations (Uses Matrix4x4)** - - [x] BlackWhite - - [x] Grayscale BT709 - - [x] Grayscale BT601 - - [x] Hue - - [x] Saturation - - [x] Lomograph - - [x] Polaroid - - [x] Kodachrome - - [x] Sepia - - [x] Achromatomaly - - [x] Achromatopsia - - [x] Deuteranomaly - - [x] Deuteranopia - - [x] Protanomaly - - [x] Protanopia - - [x] Tritanomaly - - [x] Tritanopia -- **Edge Detection** - - [x] Kayyali - - [x] Kirsch - - [x] Laplacian3X3 - - [x] Laplacian5X5 - - [x] LaplacianOfGaussian - - [x] Prewitt - - [x] RobertsCross - - [x] Robinson - - [x] Scharr - - [x] Sobel -- **Blurring/Sharpening** - - [x] Gaussian blur - - [x] Gaussian sharpening - - [x] Box Blur -- **Filters** - - [x] Alpha - - [x] Contrast - - [x] Invert - - [x] BackgroundColor - - [x] Brightness - - [x] Pixelate - - [ ] Mask - - [x] Oil Painting - - [x] Vignette - - [x] Glow - - [x] Threshold -- **Drawing** - - [x] Image brush - - [x] Pattern brush - - [x] Solid brush - - [X] Hatch brush (Partial copy of System.Drawing brushes) - - [x] Pen (Solid, Dash, Custom) - - [x] Line drawing - - [x] Complex Polygons (Fill, draw) - - [x] DrawImage - - [ ] Gradient brush (Need help) -- **DrawingText** - - [ ] DrawString (In-progress. Single variant support just now, no italic,bold) -- Other stuff I haven't thought of. \ No newline at end of file diff --git a/input/about.md b/input/about.md deleted file mode 100644 index 42739928ae..0000000000 --- a/input/about.md +++ /dev/null @@ -1,3 +0,0 @@ -Title: About This Project ---- -This project is awesome! \ No newline at end of file From bc7d5b0161bac82d98cbbb8acc98c20c68c42f83 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 13 Mar 2018 12:33:52 +1100 Subject: [PATCH 17/18] Update license link [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index de95bdac45..7e47e6b06f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ImageSharp

- GitHub license + GitHub license Gitter Twitter OpenCollective From 6ec2a269824132ba839c2eeec94445ecf4d3ff91 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 14 Mar 2018 16:40:28 +1100 Subject: [PATCH 18/18] Overlays => Drawing --- .../Primitives/ShapePath.cs | 3 +- .../Drawing/Brushes}/BrushApplicator.cs | 2 +- .../Drawing/Brushes/Brushes.cs | 2 +- .../Drawing/Brushes/IBrush.cs | 3 +- .../Drawing/Brushes/ImageBrush{TPixel}.cs | 3 +- .../Drawing/Brushes/PatternBrush{TPixel}.cs | 3 +- .../Drawing/Brushes/RecolorBrush{TPixel}.cs | 3 +- .../Drawing/Brushes/SolidBrush{TPixel}.cs | 3 +- .../DrawBezierExtensions.cs | 6 +- .../DrawImageExtensions.cs | 4 +- .../DrawLineExtensions.cs | 6 +- .../DrawPathCollectionExtensions.cs | 6 +- .../DrawPathExtensions.cs | 6 +- .../DrawPolygonExtensions.cs | 6 +- .../DrawRectangleExtensions.cs | 6 +- .../FillPathBuilderExtensions.cs | 5 +- .../FillPathCollectionExtensions.cs | 4 +- .../FillPathExtensions.cs | 4 +- .../FillPolygonExtensions.cs | 4 +- .../FillRectangleExtensions.cs | 4 +- .../FillRegionExtensions.cs | 6 +- .../{ => Processing}/Drawing/Pens/IPen.cs | 4 +- .../{ => Processing}/Drawing/Pens/Pens.cs | 4 +- .../Drawing/Pens/Pen{TPixel}.cs | 4 +- .../Processors/DrawImageProcessor.cs | 2 +- .../Processors/FillProcessor.cs | 5 +- .../Processors/FillRegionProcessor.cs | 5 +- .../Text/DrawTextExtensions.Path.cs | 6 +- .../Processing/Text/DrawTextExtensions.cs | 6 +- .../Drawing/DrawBeziers.cs | 2 +- .../Drawing/DrawLines.cs | 14 ++-- .../Drawing/DrawPolygon.cs | 1 + .../Drawing/FillPolygon.cs | 1 + .../Drawing/FillRectangle.cs | 1 + .../Drawing/FillWithPattern.cs | 24 +++---- .../ImageSharp.Tests/Drawing/BeziersTests.cs | 1 + .../ImageSharp.Tests/Drawing/BlendedShapes.cs | 2 +- .../ImageSharp.Tests/Drawing/DrawImageTest.cs | 2 +- .../ImageSharp.Tests/Drawing/DrawPathTests.cs | 25 +++---- .../Drawing/FillPatternTests.cs | 17 ++--- .../Drawing/FillRegionProcessorTests.cs | 9 +-- .../Drawing/FillSolidBrushTests.cs | 22 +++---- .../Drawing/LineComplexPolygonTests.cs | 38 +++++------ tests/ImageSharp.Tests/Drawing/LineTests.cs | 4 +- .../Drawing/Paths/FillPath.cs | 8 +-- .../Drawing/Paths/FillPathCollection.cs | 21 +++--- .../Drawing/Paths/FillPolygon.cs | 7 +- .../Drawing/Paths/FillRectangle.cs | 66 +++++++++---------- .../Drawing/Paths/ShapePathTests.cs | 17 +---- .../Drawing/Paths/ShapeRegionTests.cs | 16 ++--- .../ImageSharp.Tests/Drawing/PolygonTests.cs | 1 + .../Drawing/RecolorImageTest.cs | 8 +-- .../Drawing/SolidBezierTests.cs | 1 + .../Drawing/SolidComplexPolygonTests.cs | 1 + .../Drawing/SolidPolygonTests.cs | 43 ++++++------ .../Drawing/Text/DrawText.Path.cs | 41 ++++++------ .../ImageSharp.Tests/Drawing/Text/DrawText.cs | 9 +-- .../Drawing/Text/OutputText.cs | 17 ++--- .../Drawing/Text/TextGraphicsOptionsTests.cs | 13 +--- tests/ImageSharp.Tests/Issues/Issue412.cs | 2 +- .../ImageProviders/SolidProvider.cs | 1 + 61 files changed, 258 insertions(+), 302 deletions(-) rename src/ImageSharp.Drawing/{Drawing/Brushes/Processors => Processing/Drawing/Brushes}/BrushApplicator.cs (98%) rename src/ImageSharp.Drawing/{ => Processing}/Drawing/Brushes/Brushes.cs (99%) rename src/ImageSharp.Drawing/{ => Processing}/Drawing/Brushes/IBrush.cs (93%) rename src/ImageSharp.Drawing/{ => Processing}/Drawing/Brushes/ImageBrush{TPixel}.cs (98%) rename src/ImageSharp.Drawing/{ => Processing}/Drawing/Brushes/PatternBrush{TPixel}.cs (98%) rename src/ImageSharp.Drawing/{ => Processing}/Drawing/Brushes/RecolorBrush{TPixel}.cs (98%) rename src/ImageSharp.Drawing/{ => Processing}/Drawing/Brushes/SolidBrush{TPixel}.cs (97%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/DrawBezierExtensions.cs (97%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/DrawImageExtensions.cs (98%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/DrawLineExtensions.cs (97%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/DrawPathCollectionExtensions.cs (97%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/DrawPathExtensions.cs (97%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/DrawPolygonExtensions.cs (97%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/DrawRectangleExtensions.cs (97%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/FillPathBuilderExtensions.cs (97%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/FillPathCollectionExtensions.cs (97%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/FillPathExtensions.cs (97%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/FillPolygonExtensions.cs (97%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/FillRectangleExtensions.cs (97%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/FillRegionExtensions.cs (97%) rename src/ImageSharp.Drawing/{ => Processing}/Drawing/Pens/IPen.cs (89%) rename src/ImageSharp.Drawing/{ => Processing}/Drawing/Pens/Pens.cs (98%) rename src/ImageSharp.Drawing/{ => Processing}/Drawing/Pens/Pen{TPixel}.cs (96%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/Processors/DrawImageProcessor.cs (99%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/Processors/FillProcessor.cs (94%) rename src/ImageSharp.Drawing/Processing/{Overlays => Drawing}/Processors/FillRegionProcessor.cs (98%) diff --git a/src/ImageSharp.Drawing/Primitives/ShapePath.cs b/src/ImageSharp.Drawing/Primitives/ShapePath.cs index 6b4ccd917d..2a569f0616 100644 --- a/src/ImageSharp.Drawing/Primitives/ShapePath.cs +++ b/src/ImageSharp.Drawing/Primitives/ShapePath.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.Processing.Drawing.Pens; using SixLabors.Shapes; namespace SixLabors.ImageSharp.Primitives @@ -16,7 +17,7 @@ namespace SixLabors.ImageSharp.Primitives /// The shape. /// The pen to apply to the shape. // TODO: SixLabors.shape will be moving to a Span/ReadOnlySpan based API shortly use ToArray for now. - public ShapePath(IPath shape, Drawing.Pens.IPen pen) + public ShapePath(IPath shape, IPen pen) : base(shape.GenerateOutline(pen.StrokeWidth, pen.StrokePattern.ToArray())) { } diff --git a/src/ImageSharp.Drawing/Drawing/Brushes/Processors/BrushApplicator.cs b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/BrushApplicator.cs similarity index 98% rename from src/ImageSharp.Drawing/Drawing/Brushes/Processors/BrushApplicator.cs rename to src/ImageSharp.Drawing/Processing/Drawing/Brushes/BrushApplicator.cs index 78b394bf22..f665e8408c 100644 --- a/src/ImageSharp.Drawing/Drawing/Brushes/Processors/BrushApplicator.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/BrushApplicator.cs @@ -6,7 +6,7 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Drawing.Brushes.Processors +namespace SixLabors.ImageSharp.Processing.Drawing.Brushes { /// /// primitive that converts a point in to a color for discovering the fill color based on an implementation diff --git a/src/ImageSharp.Drawing/Drawing/Brushes/Brushes.cs b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/Brushes.cs similarity index 99% rename from src/ImageSharp.Drawing/Drawing/Brushes/Brushes.cs rename to src/ImageSharp.Drawing/Processing/Drawing/Brushes/Brushes.cs index 47e207e8c4..141ca403b3 100644 --- a/src/ImageSharp.Drawing/Drawing/Brushes/Brushes.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/Brushes.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Drawing.Brushes +namespace SixLabors.ImageSharp.Processing.Drawing.Brushes { /// /// A collection of methods for creating generic brushes. diff --git a/src/ImageSharp.Drawing/Drawing/Brushes/IBrush.cs b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/IBrush.cs similarity index 93% rename from src/ImageSharp.Drawing/Drawing/Brushes/IBrush.cs rename to src/ImageSharp.Drawing/Processing/Drawing/Brushes/IBrush.cs index 41d9081ebe..93ecb7788c 100644 --- a/src/ImageSharp.Drawing/Drawing/Brushes/IBrush.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/IBrush.cs @@ -1,11 +1,10 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Brushes.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Drawing.Brushes +namespace SixLabors.ImageSharp.Processing.Drawing.Brushes { /// /// Brush represents a logical configuration of a brush which can be used to source pixel colors diff --git a/src/ImageSharp.Drawing/Drawing/Brushes/ImageBrush{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/ImageBrush{TPixel}.cs similarity index 98% rename from src/ImageSharp.Drawing/Drawing/Brushes/ImageBrush{TPixel}.cs rename to src/ImageSharp.Drawing/Processing/Drawing/Brushes/ImageBrush{TPixel}.cs index 91965e62ea..c2e3a16eff 100644 --- a/src/ImageSharp.Drawing/Drawing/Brushes/ImageBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/ImageBrush{TPixel}.cs @@ -3,12 +3,11 @@ using System; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Drawing.Brushes.Processors; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Drawing.Brushes +namespace SixLabors.ImageSharp.Processing.Drawing.Brushes { /// /// Provides an implementation of an image brush for painting images within areas. diff --git a/src/ImageSharp.Drawing/Drawing/Brushes/PatternBrush{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/PatternBrush{TPixel}.cs similarity index 98% rename from src/ImageSharp.Drawing/Drawing/Brushes/PatternBrush{TPixel}.cs rename to src/ImageSharp.Drawing/Processing/Drawing/Brushes/PatternBrush{TPixel}.cs index ba6d912081..765f2a1326 100644 --- a/src/ImageSharp.Drawing/Drawing/Brushes/PatternBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/PatternBrush{TPixel}.cs @@ -4,13 +4,12 @@ using System; using System.Numerics; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Drawing.Brushes.Processors; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Drawing.Brushes +namespace SixLabors.ImageSharp.Processing.Drawing.Brushes { /// /// Provides an implementation of a pattern brush for painting patterns. diff --git a/src/ImageSharp.Drawing/Drawing/Brushes/RecolorBrush{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/RecolorBrush{TPixel}.cs similarity index 98% rename from src/ImageSharp.Drawing/Drawing/Brushes/RecolorBrush{TPixel}.cs rename to src/ImageSharp.Drawing/Processing/Drawing/Brushes/RecolorBrush{TPixel}.cs index 4cef8cc83a..324c54e186 100644 --- a/src/ImageSharp.Drawing/Drawing/Brushes/RecolorBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/RecolorBrush{TPixel}.cs @@ -4,12 +4,11 @@ using System; using System.Numerics; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Drawing.Brushes.Processors; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Drawing.Brushes +namespace SixLabors.ImageSharp.Processing.Drawing.Brushes { /// /// Provides an implementation of a brush that can recolor an image diff --git a/src/ImageSharp.Drawing/Drawing/Brushes/SolidBrush{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/SolidBrush{TPixel}.cs similarity index 97% rename from src/ImageSharp.Drawing/Drawing/Brushes/SolidBrush{TPixel}.cs rename to src/ImageSharp.Drawing/Processing/Drawing/Brushes/SolidBrush{TPixel}.cs index 1511ce86c6..826f5f60a7 100644 --- a/src/ImageSharp.Drawing/Drawing/Brushes/SolidBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/SolidBrush{TPixel}.cs @@ -3,12 +3,11 @@ using System; using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Drawing.Brushes.Processors; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Drawing.Brushes +namespace SixLabors.ImageSharp.Processing.Drawing.Brushes { /// /// Provides an implementation of a solid brush for painting solid color areas. diff --git a/src/ImageSharp.Drawing/Processing/Overlays/DrawBezierExtensions.cs b/src/ImageSharp.Drawing/Processing/Drawing/DrawBezierExtensions.cs similarity index 97% rename from src/ImageSharp.Drawing/Processing/Overlays/DrawBezierExtensions.cs rename to src/ImageSharp.Drawing/Processing/Drawing/DrawBezierExtensions.cs index 974c7a6500..8f075d5c2c 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/DrawBezierExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/DrawBezierExtensions.cs @@ -1,13 +1,13 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Pens; using SixLabors.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp.Processing.Overlays +namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the drawing of Bezier paths to the type. diff --git a/src/ImageSharp.Drawing/Processing/Overlays/DrawImageExtensions.cs b/src/ImageSharp.Drawing/Processing/Drawing/DrawImageExtensions.cs similarity index 98% rename from src/ImageSharp.Drawing/Processing/Overlays/DrawImageExtensions.cs rename to src/ImageSharp.Drawing/Processing/Drawing/DrawImageExtensions.cs index 1fa16da492..6187682067 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/DrawImageExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/DrawImageExtensions.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Overlays.Processors; +using SixLabors.ImageSharp.Processing.Drawing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Overlays +namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the drawing of images to the type. diff --git a/src/ImageSharp.Drawing/Processing/Overlays/DrawLineExtensions.cs b/src/ImageSharp.Drawing/Processing/Drawing/DrawLineExtensions.cs similarity index 97% rename from src/ImageSharp.Drawing/Processing/Overlays/DrawLineExtensions.cs rename to src/ImageSharp.Drawing/Processing/Drawing/DrawLineExtensions.cs index 8bf42a07f9..9d2ea0c1d8 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/DrawLineExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/DrawLineExtensions.cs @@ -1,13 +1,13 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Pens; using SixLabors.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp.Processing.Overlays +namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the drawing of lines to the type. diff --git a/src/ImageSharp.Drawing/Processing/Overlays/DrawPathCollectionExtensions.cs b/src/ImageSharp.Drawing/Processing/Drawing/DrawPathCollectionExtensions.cs similarity index 97% rename from src/ImageSharp.Drawing/Processing/Overlays/DrawPathCollectionExtensions.cs rename to src/ImageSharp.Drawing/Processing/Drawing/DrawPathCollectionExtensions.cs index 191a73a36b..d148638ae1 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/DrawPathCollectionExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/DrawPathCollectionExtensions.cs @@ -1,12 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Pens; using SixLabors.Shapes; -namespace SixLabors.ImageSharp.Processing.Overlays +namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the drawing of collections of polygon outlines to the type. diff --git a/src/ImageSharp.Drawing/Processing/Overlays/DrawPathExtensions.cs b/src/ImageSharp.Drawing/Processing/Drawing/DrawPathExtensions.cs similarity index 97% rename from src/ImageSharp.Drawing/Processing/Overlays/DrawPathExtensions.cs rename to src/ImageSharp.Drawing/Processing/Drawing/DrawPathExtensions.cs index 7f86ddee65..a795ee295b 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/DrawPathExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/DrawPathExtensions.cs @@ -1,13 +1,13 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Pens; using SixLabors.Shapes; -namespace SixLabors.ImageSharp.Processing.Overlays +namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the drawing of polygon outlines to the type. diff --git a/src/ImageSharp.Drawing/Processing/Overlays/DrawPolygonExtensions.cs b/src/ImageSharp.Drawing/Processing/Drawing/DrawPolygonExtensions.cs similarity index 97% rename from src/ImageSharp.Drawing/Processing/Overlays/DrawPolygonExtensions.cs rename to src/ImageSharp.Drawing/Processing/Drawing/DrawPolygonExtensions.cs index f56ab19d83..833b616f89 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/DrawPolygonExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/DrawPolygonExtensions.cs @@ -1,13 +1,13 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Pens; using SixLabors.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp.Processing.Overlays +namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the drawing of closed linear polygons to the type. diff --git a/src/ImageSharp.Drawing/Processing/Overlays/DrawRectangleExtensions.cs b/src/ImageSharp.Drawing/Processing/Drawing/DrawRectangleExtensions.cs similarity index 97% rename from src/ImageSharp.Drawing/Processing/Overlays/DrawRectangleExtensions.cs rename to src/ImageSharp.Drawing/Processing/Drawing/DrawRectangleExtensions.cs index df0c1bf153..3d6702be97 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/DrawRectangleExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/DrawRectangleExtensions.cs @@ -1,13 +1,13 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Pens; using SixLabors.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp.Processing.Overlays +namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the drawing of rectangles to the type. diff --git a/src/ImageSharp.Drawing/Processing/Overlays/FillPathBuilderExtensions.cs b/src/ImageSharp.Drawing/Processing/Drawing/FillPathBuilderExtensions.cs similarity index 97% rename from src/ImageSharp.Drawing/Processing/Overlays/FillPathBuilderExtensions.cs rename to src/ImageSharp.Drawing/Processing/Drawing/FillPathBuilderExtensions.cs index e40eaa4139..975b5db4c6 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/FillPathBuilderExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/FillPathBuilderExtensions.cs @@ -2,12 +2,11 @@ // Licensed under the Apache License, Version 2.0. using System; - -using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; using SixLabors.Shapes; -namespace SixLabors.ImageSharp.Processing.Overlays +namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the filling of polygons with various brushes to the type. diff --git a/src/ImageSharp.Drawing/Processing/Overlays/FillPathCollectionExtensions.cs b/src/ImageSharp.Drawing/Processing/Drawing/FillPathCollectionExtensions.cs similarity index 97% rename from src/ImageSharp.Drawing/Processing/Overlays/FillPathCollectionExtensions.cs rename to src/ImageSharp.Drawing/Processing/Drawing/FillPathCollectionExtensions.cs index 7021b5c87d..be472d373b 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/FillPathCollectionExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/FillPathCollectionExtensions.cs @@ -1,11 +1,11 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; using SixLabors.Shapes; -namespace SixLabors.ImageSharp.Processing.Overlays +namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the filling of collections of polygon outlines to the type. diff --git a/src/ImageSharp.Drawing/Processing/Overlays/FillPathExtensions.cs b/src/ImageSharp.Drawing/Processing/Drawing/FillPathExtensions.cs similarity index 97% rename from src/ImageSharp.Drawing/Processing/Overlays/FillPathExtensions.cs rename to src/ImageSharp.Drawing/Processing/Drawing/FillPathExtensions.cs index 779a6e94fa..9b288c8bef 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/FillPathExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/FillPathExtensions.cs @@ -1,12 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; using SixLabors.Shapes; -namespace SixLabors.ImageSharp.Processing.Overlays +namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the filling of polygon outlines to the type. diff --git a/src/ImageSharp.Drawing/Processing/Overlays/FillPolygonExtensions.cs b/src/ImageSharp.Drawing/Processing/Drawing/FillPolygonExtensions.cs similarity index 97% rename from src/ImageSharp.Drawing/Processing/Overlays/FillPolygonExtensions.cs rename to src/ImageSharp.Drawing/Processing/Drawing/FillPolygonExtensions.cs index 700b3e18f6..692f88337e 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/FillPolygonExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/FillPolygonExtensions.cs @@ -1,12 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; using SixLabors.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp.Processing.Overlays +namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the filling of closed linear polygons to the type. diff --git a/src/ImageSharp.Drawing/Processing/Overlays/FillRectangleExtensions.cs b/src/ImageSharp.Drawing/Processing/Drawing/FillRectangleExtensions.cs similarity index 97% rename from src/ImageSharp.Drawing/Processing/Overlays/FillRectangleExtensions.cs rename to src/ImageSharp.Drawing/Processing/Drawing/FillRectangleExtensions.cs index a7ba82d49f..eff333a4f2 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/FillRectangleExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/FillRectangleExtensions.cs @@ -1,12 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; using SixLabors.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp.Processing.Overlays +namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the filling of rectangles to the type. diff --git a/src/ImageSharp.Drawing/Processing/Overlays/FillRegionExtensions.cs b/src/ImageSharp.Drawing/Processing/Drawing/FillRegionExtensions.cs similarity index 97% rename from src/ImageSharp.Drawing/Processing/Overlays/FillRegionExtensions.cs rename to src/ImageSharp.Drawing/Processing/Drawing/FillRegionExtensions.cs index 0f1176e9d3..d3e2232227 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/FillRegionExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/FillRegionExtensions.cs @@ -1,12 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Processors; -namespace SixLabors.ImageSharp.Processing.Overlays +namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the filling of regions with various brushes to the type. diff --git a/src/ImageSharp.Drawing/Drawing/Pens/IPen.cs b/src/ImageSharp.Drawing/Processing/Drawing/Pens/IPen.cs similarity index 89% rename from src/ImageSharp.Drawing/Drawing/Pens/IPen.cs rename to src/ImageSharp.Drawing/Processing/Drawing/Pens/IPen.cs index ed7de14610..387165e20c 100644 --- a/src/ImageSharp.Drawing/Drawing/Pens/IPen.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Pens/IPen.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. using System; -using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; -namespace SixLabors.ImageSharp.Drawing.Pens +namespace SixLabors.ImageSharp.Processing.Drawing.Pens { /// /// Interface representing a Pen diff --git a/src/ImageSharp.Drawing/Drawing/Pens/Pens.cs b/src/ImageSharp.Drawing/Processing/Drawing/Pens/Pens.cs similarity index 98% rename from src/ImageSharp.Drawing/Drawing/Pens/Pens.cs rename to src/ImageSharp.Drawing/Processing/Drawing/Pens/Pens.cs index 4eb2d5d204..b1883e3220 100644 --- a/src/ImageSharp.Drawing/Drawing/Pens/Pens.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Pens/Pens.cs @@ -1,10 +1,10 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; -namespace SixLabors.ImageSharp.Drawing.Pens +namespace SixLabors.ImageSharp.Processing.Drawing.Pens { /// /// Contains a collection of common Pen styles diff --git a/src/ImageSharp.Drawing/Drawing/Pens/Pen{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Drawing/Pens/Pen{TPixel}.cs similarity index 96% rename from src/ImageSharp.Drawing/Drawing/Pens/Pen{TPixel}.cs rename to src/ImageSharp.Drawing/Processing/Drawing/Pens/Pen{TPixel}.cs index 3956dde0c9..1dd6b6616d 100644 --- a/src/ImageSharp.Drawing/Drawing/Pens/Pen{TPixel}.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Pens/Pen{TPixel}.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. using System; -using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; -namespace SixLabors.ImageSharp.Drawing.Pens +namespace SixLabors.ImageSharp.Processing.Drawing.Pens { /// /// Provides a pen that can apply a pattern to a line with a set brush and thickness diff --git a/src/ImageSharp.Drawing/Processing/Overlays/Processors/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processing/Drawing/Processors/DrawImageProcessor.cs similarity index 99% rename from src/ImageSharp.Drawing/Processing/Overlays/Processors/DrawImageProcessor.cs rename to src/ImageSharp.Drawing/Processing/Drawing/Processors/DrawImageProcessor.cs index a41496d2a9..7b6e36d9d1 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/Processors/DrawImageProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Processors/DrawImageProcessor.cs @@ -9,7 +9,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Processing.Overlays.Processors +namespace SixLabors.ImageSharp.Processing.Drawing.Processors { /// /// Combines two images together by blending the pixels. diff --git a/src/ImageSharp.Drawing/Processing/Overlays/Processors/FillProcessor.cs b/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillProcessor.cs similarity index 94% rename from src/ImageSharp.Drawing/Processing/Overlays/Processors/FillProcessor.cs rename to src/ImageSharp.Drawing/Processing/Drawing/Processors/FillProcessor.cs index 70ac2507a3..e4ef44564e 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/Processors/FillProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillProcessor.cs @@ -3,14 +3,13 @@ using System; using System.Threading.Tasks; -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Brushes.Processors; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Drawing.Processors +namespace SixLabors.ImageSharp.Processing.Drawing.Processors { /// /// Using the brush as a source of pixels colors blends the brush color with source. diff --git a/src/ImageSharp.Drawing/Processing/Overlays/Processors/FillRegionProcessor.cs b/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillRegionProcessor.cs similarity index 98% rename from src/ImageSharp.Drawing/Processing/Overlays/Processors/FillRegionProcessor.cs rename to src/ImageSharp.Drawing/Processing/Drawing/Processors/FillRegionProcessor.cs index dfd66d7fc5..aa0b2e9b23 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/Processors/FillRegionProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillRegionProcessor.cs @@ -3,15 +3,14 @@ using System; using System.Runtime.CompilerServices; -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Brushes.Processors; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Drawing.Processors +namespace SixLabors.ImageSharp.Processing.Drawing.Processors { /// /// Using a brush and a shape fills shape with contents of brush the diff --git a/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.Path.cs b/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.Path.cs index 6c009169f4..84bf26c517 100644 --- a/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.Path.cs +++ b/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.Path.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.Fonts; -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Drawing; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Pens; using SixLabors.Shapes; namespace SixLabors.ImageSharp.Processing.Text diff --git a/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.cs b/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.cs index 7e43fb17c1..5731804aca 100644 --- a/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.Fonts; -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Drawing; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Pens; using SixLabors.Primitives; using SixLabors.Shapes; diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs index 97db3fc49d..d2f54f140f 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs @@ -11,7 +11,7 @@ using BenchmarkDotNet.Attributes; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Drawing; namespace SixLabors.ImageSharp.Benchmarks { diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs index d12b064cbd..a027108a19 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs @@ -3,7 +3,7 @@ // Licensed under the Apache License, Version 2.0. // -using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Drawing; namespace SixLabors.ImageSharp.Benchmarks { @@ -22,13 +22,13 @@ namespace SixLabors.ImageSharp.Benchmarks [Benchmark(Baseline = true, Description = "System.Drawing Draw Lines")] public void DrawPathSystemDrawing() { - using (Bitmap destination = new Bitmap(800, 800)) + using (var destination = new Bitmap(800, 800)) { - using (Graphics graphics = Graphics.FromImage(destination)) + using (var graphics = Graphics.FromImage(destination)) { graphics.InterpolationMode = InterpolationMode.Default; graphics.SmoothingMode = SmoothingMode.AntiAlias; - Pen pen = new Pen(System.Drawing.Color.HotPink, 10); + var pen = new Pen(System.Drawing.Color.HotPink, 10); graphics.DrawLines(pen, new[] { new PointF(10, 10), new PointF(550, 50), @@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Benchmarks }); } - using (MemoryStream ms = new MemoryStream()) + using (var ms = new MemoryStream()) { destination.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); } @@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Draw Lines")] public void DrawLinesCore() { - using (Image image = new Image(800, 800)) + using (var image = new Image(800, 800)) { image.Mutate(x => x.DrawLines( Rgba32.HotPink, @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Benchmarks new Vector2(200, 400) })); - using (MemoryStream ms = new MemoryStream()) + using (var ms = new MemoryStream()) { image.SaveAsBmp(ms); } diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs index c020fabf2b..ab690f645e 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs @@ -11,6 +11,7 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Drawing; using SixLabors.ImageSharp.Processing.Overlays; namespace SixLabors.ImageSharp.Benchmarks diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs index 2ae104cd10..c53a97515c 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs @@ -12,6 +12,7 @@ using BenchmarkDotNet.Attributes; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Drawing; using SixLabors.ImageSharp.Processing.Overlays; namespace SixLabors.ImageSharp.Benchmarks diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs b/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs index b0bee373b2..7bd55e9057 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs @@ -10,6 +10,7 @@ using BenchmarkDotNet.Attributes; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Drawing; using SixLabors.ImageSharp.Processing.Overlays; using CoreRectangle = SixLabors.Primitives.Rectangle; using CoreSize = SixLabors.Primitives.Size; diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs b/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs index 3d840de46c..059398c6c2 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs @@ -3,20 +3,22 @@ // Licensed under the Apache License, Version 2.0. // -using SixLabors.ImageSharp.Processing.Overlays; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.IO; + +using BenchmarkDotNet.Attributes; + +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Drawing; + +using CoreBrushes = SixLabors.ImageSharp.Processing.Drawing.Brushes.Brushes; + namespace SixLabors.ImageSharp.Benchmarks { - using System.Drawing; - using System.Drawing.Drawing2D; - using System.IO; - - using BenchmarkDotNet.Attributes; - using SixLabors.ImageSharp.Drawing.Brushes; - using CoreBrushes = ImageSharp.Drawing.Brushes.Brushes; - using SixLabors.ImageSharp.PixelFormats; - using SixLabors.ImageSharp.Processing; public class FillWithPattern { @@ -29,7 +31,7 @@ namespace SixLabors.ImageSharp.Benchmarks { graphics.SmoothingMode = SmoothingMode.AntiAlias; HatchBrush brush = new HatchBrush(HatchStyle.BackwardDiagonal, System.Drawing.Color.HotPink); - graphics.FillRectangle(brush, new Rectangle(0,0, 800,800)); // can't find a way to flood fill with a brush + graphics.FillRectangle(brush, new Rectangle(0, 0, 800, 800)); // can't find a way to flood fill with a brush } using (MemoryStream ms = new MemoryStream()) { diff --git a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs index f9483e18bc..a0f62c4e79 100644 --- a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs +++ b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs @@ -5,6 +5,7 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Drawing; using SixLabors.ImageSharp.Processing.Overlays; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs b/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs index 3138b8c707..993adb1699 100644 --- a/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs +++ b/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Drawing; using SixLabors.Primitives; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs index eb8e48b7ea..cf65833ea6 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs @@ -5,7 +5,7 @@ using System; using System.Numerics; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Drawing; using SixLabors.Primitives; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs index 40b023e8d9..dbf0e6ce93 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs @@ -2,9 +2,10 @@ // Licensed under the Apache License, Version 2.0. using System.Numerics; -using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Drawing; +using SixLabors.ImageSharp.Processing.Drawing.Pens; using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Shapes; using Xunit; @@ -17,18 +18,18 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByPath() { string path = TestEnvironment.CreateOutputDirectory("Drawing", "Path"); - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { - LinearLineSegment linerSegemnt = new LinearLineSegment( + var linerSegemnt = new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300)); - CubicBezierLineSegment bazierSegment = new CubicBezierLineSegment(new Vector2(50, 300), + var bazierSegment = new CubicBezierLineSegment(new Vector2(50, 300), new Vector2(500, 500), new Vector2(60, 10), new Vector2(10, 400)); - Path p = new Path(linerSegemnt, bazierSegment); + var p = new Path(linerSegemnt, bazierSegment); image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -52,23 +53,23 @@ namespace SixLabors.ImageSharp.Tests.Drawing { string path = TestEnvironment.CreateOutputDirectory("Drawing", "Path"); - Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); + var color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); - LinearLineSegment linerSegemnt = new LinearLineSegment( + var linerSegemnt = new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) ); - CubicBezierLineSegment bazierSegment = new CubicBezierLineSegment(new Vector2(50, 300), + var bazierSegment = new CubicBezierLineSegment(new Vector2(50, 300), new Vector2(500, 500), new Vector2(60, 10), new Vector2(10, 400)); - Path p = new Path(linerSegemnt, bazierSegment); + var p = new Path(linerSegemnt, bazierSegment); - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -76,7 +77,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing image.Save($"{path}/Opacity.png"); //shift background color towards forground color by the opacity amount - Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f)); + var mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f)); using (PixelAccessor sourcePixels = image.Lock()) { @@ -98,7 +99,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing using (var image = new Image(256, 256)) { image.Mutate(x => x.Fill(Rgba32.Black)); - var pen = Pens.Solid(Rgba32.White, 5f); + Pen pen = Pens.Solid(Rgba32.White, 5f); for (int i = 0; i < 300; i += 20) { diff --git a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs index 79bf918036..7db88e9597 100644 --- a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs @@ -2,12 +2,9 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.IO; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Drawing; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; using Xunit; @@ -22,7 +19,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing private void Test(string name, Rgba32 background, IBrush brush, Rgba32[,] expectedPattern) { string path = TestEnvironment.CreateOutputDirectory("Fill", "PatternBrush"); - using (Image image = new Image(20, 20)) + using (var image = new Image(20, 20)) { image.Mutate(x => x .Fill(background) @@ -33,15 +30,15 @@ namespace SixLabors.ImageSharp.Tests.Drawing using (PixelAccessor sourcePixels = image.Lock()) { // lets pick random spots to start checking - Random r = new Random(); - DenseMatrix expectedPatternFast = new DenseMatrix(expectedPattern); + var r = new Random(); + var 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++) + for (var x = 0; x < xStride; x++) { - for (int y = 0; y < yStride; y++) + for (var y = 0; y < yStride; y++) { int actualX = x + offsetX; int actualY = y + offsetY; diff --git a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs index 049ed7e1ff..c995dd31b4 100644 --- a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs @@ -2,15 +2,16 @@ // Licensed under the Apache License, Version 2.0. using System.Numerics; -using SixLabors.ImageSharp.Drawing.Pens; -using SixLabors.ImageSharp.Drawing.Processors; + using Moq; using Xunit; -using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Drawing; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Pens; +using SixLabors.ImageSharp.Processing.Drawing.Processors; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Tests.Drawing diff --git a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs index 88b6a8b258..aa360c8933 100644 --- a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs @@ -1,13 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; using System.Numerics; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Tests.Drawing; +using SixLabors.ImageSharp.Processing.Drawing; using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing @@ -21,12 +17,10 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void ImageShouldBeFloodFilledWithColorOnDefaultBackground() { string path = TestEnvironment.CreateOutputDirectory("Fill", "SolidBrush"); - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { - image.Mutate(x => x - .Fill(Rgba32.HotPink)); - image - .Save($"{path}/DefaultBack.png"); + image.Mutate(x => x.Fill(Rgba32.HotPink)); + image.Save($"{path}/DefaultBack.png"); using (PixelAccessor sourcePixels = image.Lock()) { @@ -41,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void ImageShouldBeFloodFilledWithColor() { string path = TestEnvironment.CreateOutputDirectory("Fill", "SolidBrush"); - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -61,9 +55,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void ImageShouldBeFloodFilledWithColorOpacity() { string path = TestEnvironment.CreateOutputDirectory("Fill", "SolidBrush"); - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { - Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); + var color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -71,7 +65,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing image.Save($"{path}/Opacity.png"); //shift background color towards forground color by the opacity amount - Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f)); + var mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f)); using (PixelAccessor sourcePixels = image.Lock()) diff --git a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs index 76e109c623..0e0df6844a 100644 --- a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. using System.Numerics; - -using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing; +using SixLabors.ImageSharp.Processing.Drawing.Pens; using SixLabors.Shapes; using Xunit; @@ -20,17 +20,17 @@ namespace SixLabors.ImageSharp.Tests.Drawing { string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon"); - Polygon simplePath = new Polygon(new LinearLineSegment( + var simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300))); - Polygon hole1 = new Polygon(new LinearLineSegment( + var hole1 = new Polygon(new LinearLineSegment( new Vector2(37, 85), new Vector2(93, 85), new Vector2(65, 137))); - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -67,17 +67,17 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByPolygonOutlineNoOverlapping() { string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon"); - Polygon simplePath = new Polygon(new LinearLineSegment( + var simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300))); - Polygon hole1 = new Polygon(new LinearLineSegment( + var hole1 = new Polygon(new LinearLineSegment( new Vector2(207, 25), new Vector2(263, 25), new Vector2(235, 57))); - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -115,17 +115,17 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByPolygonOutlineOverlapping() { string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon"); - Polygon simplePath = new Polygon(new LinearLineSegment( + var simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300))); - Polygon hole1 = new Polygon(new LinearLineSegment( + var hole1 = new Polygon(new LinearLineSegment( new Vector2(37, 85), new Vector2(130, 40), new Vector2(65, 137))); - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -158,17 +158,17 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByPolygonOutlineDashed() { string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon"); - Polygon simplePath = new Polygon(new LinearLineSegment( + var simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300))); - Polygon hole1 = new Polygon(new LinearLineSegment( + var hole1 = new Polygon(new LinearLineSegment( new Vector2(37, 85), new Vector2(93, 85), new Vector2(65, 137))); - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -182,18 +182,18 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedPolygonOutlineWithOpacity() { string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon"); - Polygon simplePath = new Polygon(new LinearLineSegment( + var simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300))); - Polygon hole1 = new Polygon(new LinearLineSegment( + var hole1 = new Polygon(new LinearLineSegment( new Vector2(37, 85), new Vector2(93, 85), new Vector2(65, 137))); - Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); + var color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -201,7 +201,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing image.Save($"{path}/Opacity.png"); //shift background color towards forground color by the opacity amount - Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f)); + var mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f)); using (PixelAccessor sourcePixels = image.Lock()) { diff --git a/tests/ImageSharp.Tests/Drawing/LineTests.cs b/tests/ImageSharp.Tests/Drawing/LineTests.cs index 2048b6fe90..d7eb0b6579 100644 --- a/tests/ImageSharp.Tests/Drawing/LineTests.cs +++ b/tests/ImageSharp.Tests/Drawing/LineTests.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. using System.Numerics; - -using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing; +using SixLabors.ImageSharp.Processing.Drawing.Pens; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs index cf818765d3..4713e63c25 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs @@ -2,11 +2,11 @@ // Licensed under the Apache License, Version 2.0. using System.Numerics; -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; -using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Drawing; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Processors; using SixLabors.Shapes; using Xunit; @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; SolidBrush brush = Brushes.Solid(Rgba32.HotPink); - IPath path = new SixLabors.Shapes.Path(new LinearLineSegment(new SixLabors.Primitives.PointF[] { + IPath path = new Path(new LinearLineSegment(new SixLabors.Primitives.PointF[] { new Vector2(10,10), new Vector2(20,10), new Vector2(20,10), diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs index 0b4a5e0bf2..526cf1b924 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs @@ -1,15 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using System.Numerics; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; -using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Drawing; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Processors; using SixLabors.Shapes; using Xunit; @@ -20,13 +17,13 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; SolidBrush brush = Brushes.Solid(Rgba32.HotPink); - IPath path1 = new SixLabors.Shapes.Path(new LinearLineSegment(new SixLabors.Primitives.PointF[] { + IPath path1 = new Path(new LinearLineSegment(new SixLabors.Primitives.PointF[] { new Vector2(10,10), new Vector2(20,10), new Vector2(20,10), new Vector2(30,10), })); - IPath path2 = new SixLabors.Shapes.Path(new LinearLineSegment(new SixLabors.Primitives.PointF[] { + IPath path2 = new Path(new LinearLineSegment(new SixLabors.Primitives.PointF[] { new Vector2(10,10), new Vector2(20,10), new Vector2(20,10), @@ -45,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths { this.operations.Fill(this.brush, this.pathCollection); - for (var i = 0; i < 2; i++) + for (int i = 0; i < 2; i++) { FillRegionProcessor processor = this.Verify>(i); @@ -66,7 +63,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths { this.operations.Fill(this.brush, this.pathCollection, this.noneDefault); - for (var i = 0; i < 2; i++) + for (int i = 0; i < 2; i++) { FillRegionProcessor processor = this.Verify>(i); @@ -85,7 +82,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths { this.operations.Fill(this.color, this.pathCollection); - for (var i = 0; i < 2; i++) + for (int i = 0; i < 2; i++) { FillRegionProcessor processor = this.Verify>(i); @@ -105,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths { this.operations.Fill(this.color, this.pathCollection, this.noneDefault); - for (var i = 0; i < 2; i++) + for (int i = 0; i < 2; i++) { FillRegionProcessor processor = this.Verify>(i); diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs index 9eacdff294..a1f083cf43 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs @@ -2,12 +2,11 @@ // Licensed under the Apache License, Version 2.0. using System.Numerics; - -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; -using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Drawing; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Processors; using SixLabors.Shapes; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs index 429da58264..263eb9a9ca 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs @@ -1,11 +1,11 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; -using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Drawing; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Processors; using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing.Paths @@ -20,75 +20,75 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths [Fact] public void CorrectlySetsBrushAndRectangle() { - this.operations.Fill(brush, rectangle); + this.operations.Fill(this.brush, this.rectangle); FillRegionProcessor processor = this.Verify>(); Assert.Equal(GraphicsOptions.Default, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); - SixLabors.Shapes.RectangularePolygon rect = Assert.IsType(region.Shape); - Assert.Equal(rect.Location.X, rectangle.X); - Assert.Equal(rect.Location.Y, rectangle.Y); - Assert.Equal(rect.Size.Width, rectangle.Width); - Assert.Equal(rect.Size.Height, rectangle.Height); + Shapes.RectangularePolygon rect = Assert.IsType(region.Shape); + Assert.Equal(rect.Location.X, this.rectangle.X); + Assert.Equal(rect.Location.Y, this.rectangle.Y); + Assert.Equal(rect.Size.Width, this.rectangle.Width); + Assert.Equal(rect.Size.Height, this.rectangle.Height); - Assert.Equal(brush, processor.Brush); + Assert.Equal(this.brush, processor.Brush); } [Fact] public void CorrectlySetsBrushRectangleAndOptions() { - this.operations.Fill(brush, rectangle, noneDefault); + this.operations.Fill(this.brush, this.rectangle, this.noneDefault); FillRegionProcessor processor = this.Verify>(); - Assert.Equal(noneDefault, processor.Options); + Assert.Equal(this.noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); - SixLabors.Shapes.RectangularePolygon rect = Assert.IsType(region.Shape); - Assert.Equal(rect.Location.X, rectangle.X); - Assert.Equal(rect.Location.Y, rectangle.Y); - Assert.Equal(rect.Size.Width, rectangle.Width); - Assert.Equal(rect.Size.Height, rectangle.Height); + Shapes.RectangularePolygon rect = Assert.IsType(region.Shape); + Assert.Equal(rect.Location.X, this.rectangle.X); + Assert.Equal(rect.Location.Y, this.rectangle.Y); + Assert.Equal(rect.Size.Width, this.rectangle.Width); + Assert.Equal(rect.Size.Height, this.rectangle.Height); - Assert.Equal(brush, processor.Brush); + Assert.Equal(this.brush, processor.Brush); } [Fact] public void CorrectlySetsColorAndRectangle() { - this.operations.Fill(color, rectangle); + this.operations.Fill(this.color, this.rectangle); FillRegionProcessor processor = this.Verify>(); Assert.Equal(GraphicsOptions.Default, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); - SixLabors.Shapes.RectangularePolygon rect = Assert.IsType(region.Shape); - Assert.Equal(rect.Location.X, rectangle.X); - Assert.Equal(rect.Location.Y, rectangle.Y); - Assert.Equal(rect.Size.Width, rectangle.Width); - Assert.Equal(rect.Size.Height, rectangle.Height); + Shapes.RectangularePolygon rect = Assert.IsType(region.Shape); + Assert.Equal(rect.Location.X, this.rectangle.X); + Assert.Equal(rect.Location.Y, this.rectangle.Y); + Assert.Equal(rect.Size.Width, this.rectangle.Width); + Assert.Equal(rect.Size.Height, this.rectangle.Height); SolidBrush brush = Assert.IsType>(processor.Brush); - Assert.Equal(color, brush.Color); + Assert.Equal(this.color, brush.Color); } [Fact] public void CorrectlySetsColorRectangleAndOptions() { - this.operations.Fill(color, rectangle, noneDefault); + this.operations.Fill(this.color, this.rectangle, this.noneDefault); FillRegionProcessor processor = this.Verify>(); - Assert.Equal(noneDefault, processor.Options); + Assert.Equal(this.noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); - SixLabors.Shapes.RectangularePolygon rect = Assert.IsType(region.Shape); - Assert.Equal(rect.Location.X, rectangle.X); - Assert.Equal(rect.Location.Y, rectangle.Y); - Assert.Equal(rect.Size.Width, rectangle.Width); - Assert.Equal(rect.Size.Height, rectangle.Height); + Shapes.RectangularePolygon rect = Assert.IsType(region.Shape); + Assert.Equal(rect.Location.X, this.rectangle.X); + Assert.Equal(rect.Location.Y, this.rectangle.Y); + Assert.Equal(rect.Size.Width, this.rectangle.Width); + Assert.Equal(rect.Size.Height, this.rectangle.Height); SolidBrush brush = Assert.IsType>(processor.Brush); - Assert.Equal(color, brush.Color); + Assert.Equal(this.color, brush.Color); } } } diff --git a/tests/ImageSharp.Tests/Drawing/Paths/ShapePathTests.cs b/tests/ImageSharp.Tests/Drawing/Paths/ShapePathTests.cs index 5d2e93e877..b474f6e47c 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/ShapePathTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/ShapePathTests.cs @@ -1,25 +1,10 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.IO; -using System.Numerics; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Pens; -using SixLabors.ImageSharp.Drawing.Processors; -using SixLabors.ImageSharp.Processing; -using Moq; -using SixLabors.Shapes; -using Xunit; - namespace SixLabors.ImageSharp.Tests.Drawing.Paths { public class ShapePathTests { - // TODO readd these back in + // TODO read these back in } } diff --git a/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs b/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs index d0912acee9..2a9ab3412e 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs @@ -8,8 +8,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths using System; using Moq; - - using SixLabors.ImageSharp.Drawing; using SixLabors.Primitives; using SixLabors.Shapes; @@ -42,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths [Fact] public void ShapeRegionWithPathRetainsShape() { - ShapeRegion region = new ShapeRegion(this.pathMock.Object); + var region = new ShapeRegion(this.pathMock.Object); Assert.Equal(this.pathMock.Object, region.Shape); } @@ -50,7 +48,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths [Fact] public void ShapeRegionFromPathConvertsBoundsProxyToShape() { - ShapeRegion region = new ShapeRegion(this.pathMock.Object); + var region = new ShapeRegion(this.pathMock.Object); Assert.Equal(Math.Floor(this.bounds.Left), region.Bounds.Left); Assert.Equal(Math.Ceiling(this.bounds.Right), region.Bounds.Right); @@ -61,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths [Fact] public void ShapeRegionFromPathMaxIntersectionsProxyToShape() { - ShapeRegion region = new ShapeRegion(this.pathMock.Object); + var region = new ShapeRegion(this.pathMock.Object); int i = region.MaxIntersections; this.pathMock.Verify(x => x.MaxIntersections); @@ -71,7 +69,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths public void ShapeRegionFromPathScanYProxyToShape() { int yToScan = 10; - ShapeRegion region = new ShapeRegion(this.pathMock.Object); + var region = new ShapeRegion(this.pathMock.Object); this.pathMock .Setup( @@ -99,7 +97,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths public void ShapeRegionFromShapeScanYProxyToShape() { int yToScan = 10; - ShapeRegion region = new ShapeRegion(this.pathMock.Object); + var region = new ShapeRegion(this.pathMock.Object); this.pathMock .Setup( @@ -126,7 +124,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths [Fact] public void ShapeRegionFromShapeConvertsBoundsProxyToShape() { - ShapeRegion region = new ShapeRegion(this.pathMock.Object); + var region = new ShapeRegion(this.pathMock.Object); Assert.Equal(Math.Floor(this.bounds.Left), region.Bounds.Left); Assert.Equal(Math.Ceiling(this.bounds.Right), region.Bounds.Right); @@ -137,7 +135,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths [Fact] public void ShapeRegionFromShapeMaxIntersectionsProxyToShape() { - ShapeRegion region = new ShapeRegion(this.pathMock.Object); + var region = new ShapeRegion(this.pathMock.Object); int i = region.MaxIntersections; this.pathMock.Verify(x => x.MaxIntersections); diff --git a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs index 318ce4fce1..f6d9bf2131 100644 --- a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs @@ -6,6 +6,7 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Drawing; using SixLabors.ImageSharp.Processing.Overlays; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs index 8fe26fff59..4a87ad189d 100644 --- a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs @@ -1,9 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Drawing; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; using SixLabors.Primitives; using Xunit; @@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests { string path = TestEnvironment.CreateOutputDirectory("Drawing", "RecolorImage"); - RecolorBrush brush = new RecolorBrush(Rgba32.Yellow, Rgba32.HotPink, 0.2f); + var brush = new RecolorBrush(Rgba32.Yellow, Rgba32.HotPink, 0.2f); foreach (TestFile file in Files) { @@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests { string path = TestEnvironment.CreateOutputDirectory("Drawing", "RecolorImage"); - RecolorBrush brush = new RecolorBrush(Rgba32.Yellow, Rgba32.HotPink, 0.2f); + var brush = new RecolorBrush(Rgba32.Yellow, Rgba32.HotPink, 0.2f); foreach (TestFile file in Files) { diff --git a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs index 70b896cf8a..7c75c2c443 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs @@ -3,6 +3,7 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing; using SixLabors.Shapes; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs index 759947eb0c..39a7bac53d 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs @@ -4,6 +4,7 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing; using SixLabors.Shapes; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs index 941c358b4a..6eeed144c9 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs @@ -3,14 +3,15 @@ using System; using System.Numerics; -using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing; using SixLabors.Shapes; using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing { using SixLabors.ImageSharp.Processing; + using SixLabors.ImageSharp.Processing.Drawing.Brushes; using SixLabors.ImageSharp.Processing.Overlays; public class SolidPolygonTests : FileTestBase @@ -25,7 +26,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Vector2(50, 300) }; - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { image.Mutate(x => x .FillPolygon(Rgba32.HotPink, simplePath, new GraphicsOptions(true))); @@ -42,13 +43,13 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByFilledPolygonWithPattern() { string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); - SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { + var simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) }; - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { image.Mutate(x => x .FillPolygon(Brushes.Horizontal(Rgba32.HotPink), simplePath, new GraphicsOptions(true))); @@ -65,13 +66,13 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByFilledPolygonNoAntialias() { string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); - SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { + var simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) }; - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -95,16 +96,16 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByFilledPolygonImage() { string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); - SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { + var simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) }; using (Image brushImage = TestFile.Create(TestImages.Bmp.Car).CreateImage()) - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { - ImageBrush brush = new ImageBrush(brushImage); + var brush = new ImageBrush(brushImage); image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -117,14 +118,14 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByFilledPolygonOpacity() { string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); - SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { + var simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) }; - Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); + var color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -132,7 +133,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing image.Save($"{path}/Opacity.png"); //shift background color towards forground color by the opacity amount - Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f)); + var mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f)); using (PixelAccessor sourcePixels = image.Lock()) { @@ -146,7 +147,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); - using (Image image = new Image(500, 500)) + using (var image = new Image(500, 500)) { image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -173,7 +174,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); - using (Image image = new Image(100, 100)) + using (var image = new Image(100, 100)) { image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -194,9 +195,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing { string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); - Configuration config = Configuration.CreateDefaultInstance(); + var config = Configuration.CreateDefaultInstance(); config.ParallelOptions.MaxDegreeOfParallelism = 1; - using (Image image = new Image(config, 100, 100)) + using (var image = new Image(config, 100, 100)) { image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -210,9 +211,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing { string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); - Configuration config = Configuration.CreateDefaultInstance(); + var config = Configuration.CreateDefaultInstance(); config.ParallelOptions.MaxDegreeOfParallelism = 1; - using (Image image = new Image(config, 100, 100)) + using (var image = new Image(config, 100, 100)) { image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -227,9 +228,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing { string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); - Configuration config = Configuration.CreateDefaultInstance(); + var config = Configuration.CreateDefaultInstance(); config.ParallelOptions.MaxDegreeOfParallelism = 1; - using (Image image = new Image(config, 200, 200)) + using (var image = new Image(config, 200, 200)) { image.Mutate(x => x .Fill(Rgba32.Blue) diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs index 939a5bd65c..85503a5524 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs @@ -1,18 +1,15 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using System.Numerics; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Pens; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Tests.Drawing.Paths; using SixLabors.Fonts; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Processors; using SixLabors.ImageSharp.Processing.Text; using SixLabors.Shapes; using Xunit; +using SixLabors.ImageSharp.Processing.Drawing.Pens; namespace SixLabors.ImageSharp.Tests.Drawing.Text { @@ -44,7 +41,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text this.Font, Brushes.Solid(Rgba32.Red), null, - path, + this.path, new TextGraphicsOptions(true)); this.Verify>(0); @@ -55,7 +52,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text [Fact] public void FillsForEachACharachterWhenBrushSetAndNotPenDefaultOptions() { - this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), null, path); + this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), null, this.path); this.Verify>(0); this.Verify>(1); @@ -65,7 +62,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text [Fact] public void FillsForEachACharachterWhenBrushSet() { - this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), path, new TextGraphicsOptions(true)); + this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), this.path, new TextGraphicsOptions(true)); this.Verify>(0); this.Verify>(1); @@ -75,7 +72,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text [Fact] public void FillsForEachACharachterWhenBrushSetDefaultOptions() { - this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), path); + this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), this.path); this.Verify>(0); this.Verify>(1); @@ -85,7 +82,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text [Fact] public void FillsForEachACharachterWhenColorSet() { - this.operations.DrawText("123", this.Font, Rgba32.Red, path, new TextGraphicsOptions(true)); + this.operations.DrawText("123", this.Font, Rgba32.Red, this.path, new TextGraphicsOptions(true)); var processor = this.Verify>(0); this.Verify>(1); @@ -98,9 +95,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text [Fact] public void FillsForEachACharachterWhenColorSetDefaultOptions() { - this.operations.DrawText("123", this.Font, Rgba32.Red, path); + this.operations.DrawText("123", this.Font, Rgba32.Red, this.path); - var processor = this.Verify>(0); + FillRegionProcessor processor = this.Verify>(0); this.Verify>(1); this.Verify>(2); @@ -116,7 +113,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text this.Font, null, Pens.Dash(Rgba32.Red, 1), - path, + this.path, new TextGraphicsOptions(true)); var processor = this.Verify>(0); @@ -127,7 +124,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text [Fact] public void DrawForEachACharachterWhenPenSetAndNotBrushDefaultOptions() { - this.operations.DrawText("123", this.Font, null, Pens.Dash(Rgba32.Red, 1), path); + this.operations.DrawText("123", this.Font, null, Pens.Dash(Rgba32.Red, 1), this.path); var processor = this.Verify>(0); this.Verify>(1); @@ -137,7 +134,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text [Fact] public void DrawForEachACharachterWhenPenSet() { - this.operations.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), path, new TextGraphicsOptions(true)); + this.operations.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), this.path, new TextGraphicsOptions(true)); var processor = this.Verify>(0); this.Verify>(1); @@ -147,9 +144,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text [Fact] public void DrawForEachACharachterWhenPenSetDefaultOptions() { - this.operations.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), path); + this.operations.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), this.path); - var processor = this.Verify>(0); + FillRegionProcessor processor = this.Verify>(0); this.Verify>(1); this.Verify>(2); } @@ -162,7 +159,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), - path, + this.path, new TextGraphicsOptions(true)); var processor = this.Verify>(0); @@ -176,7 +173,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text [Fact] public void DrawForEachACharachterWhenPenSetAndFillFroEachWhenBrushSetDefaultOptions() { - this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), path); + this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), this.path); var processor = this.Verify>(0); this.Verify>(1); @@ -194,7 +191,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), - path, + this.path, new TextGraphicsOptions(true)); var processor = this.Verify>(0); @@ -204,7 +201,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text [Fact] public void BrushAppliesBeforPenDefaultOptions() { - this.operations.DrawText("1", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), path); + this.operations.DrawText("1", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), this.path); var processor = this.Verify>(0); this.Verify>(1); diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs index 85234d0b54..058ce6f95e 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs @@ -1,15 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using System.Numerics; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Pens; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Tests.Drawing.Paths; using SixLabors.Fonts; +using SixLabors.ImageSharp.Processing.Drawing.Brushes; +using SixLabors.ImageSharp.Processing.Drawing.Pens; +using SixLabors.ImageSharp.Processing.Drawing.Processors; using SixLabors.ImageSharp.Processing.Text; using SixLabors.Shapes; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs index 908120d423..ec05b64ab1 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs @@ -1,21 +1,14 @@ // 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.Numerics; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Pens; -using SixLabors.ImageSharp.Drawing.Processors; + using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.Fonts; -using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Drawing; using SixLabors.ImageSharp.Processing.Text; -using SixLabors.Shapes; + using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing.Text @@ -28,14 +21,14 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text public OutputText() { this.FontCollection = new FontCollection(); - this.Font = FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff")).CreateFont(12); + this.Font = this.FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff")).CreateFont(12); } [Fact] public void DrawAB() { //draws 2 overlapping triangle glyphs twice 1 set on each line - using (Image img = new Image(100, 200)) + using (var img = new Image(100, 200)) { img.Mutate(x => x.Fill(Rgba32.DarkBlue) .DrawText("AB\nAB", new Font(this.Font, 50), Rgba32.Red, new Vector2(0, 0))); diff --git a/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs b/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs index dbbfa186ea..d710229ff1 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs @@ -1,13 +1,6 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; -using System.Threading.Tasks; -using SixLabors.ImageSharp.Drawing; -using SixLabors.Fonts; using SixLabors.ImageSharp.Processing.Text; using Xunit; @@ -19,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text [Fact] public void ExplicitCastOfGraphicsOptions() { - GraphicsOptions opt = new GraphicsOptions(false) + var opt = new GraphicsOptions(false) { AntialiasSubpixelDepth = 99 }; @@ -33,12 +26,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text [Fact] public void ImplicitCastToGraphicsOptions() { - TextGraphicsOptions textOptions = new TextGraphicsOptions(false) + var textOptions = new TextGraphicsOptions(false) { AntialiasSubpixelDepth = 99 }; - GraphicsOptions opt = (GraphicsOptions)textOptions; + var opt = (GraphicsOptions)textOptions; Assert.False(opt.Antialias); Assert.Equal(99, opt.AntialiasSubpixelDepth); diff --git a/tests/ImageSharp.Tests/Issues/Issue412.cs b/tests/ImageSharp.Tests/Issues/Issue412.cs index 8d4e360a5f..f48696cd9a 100644 --- a/tests/ImageSharp.Tests/Issues/Issue412.cs +++ b/tests/ImageSharp.Tests/Issues/Issue412.cs @@ -2,7 +2,7 @@ using Xunit; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Drawing; namespace SixLabors.ImageSharp.Tests.Issues { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs index c069020718..30902b4b0e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs @@ -4,6 +4,7 @@ using System; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Drawing; using SixLabors.ImageSharp.Processing.Overlays; using Xunit.Abstractions;