diff --git a/src/ImageProcessorCore/Bootstrapper.cs b/src/ImageProcessorCore/Bootstrapper.cs index 9e5ec39fd..2ddb64dcd 100644 --- a/src/ImageProcessorCore/Bootstrapper.cs +++ b/src/ImageProcessorCore/Bootstrapper.cs @@ -8,7 +8,6 @@ namespace ImageProcessorCore using System; using System.Collections.Generic; using System.Collections.ObjectModel; - using System.Reflection; using System.Threading.Tasks; using Formats; @@ -51,8 +50,8 @@ namespace ImageProcessorCore /// /// Gets the collection of supported /// - public IReadOnlyCollection ImageFormats => - new ReadOnlyCollection(this.imageFormats); + public IReadOnlyCollection ImageFormats => new ReadOnlyCollection(this.imageFormats); + /// /// Gets or sets the global parallel options for processing tasks in parallel. diff --git a/src/ImageProcessorCore/Colors/Colorspaces/IAlmostEquatable.cs b/src/ImageProcessorCore/Colors/Colorspaces/IAlmostEquatable.cs index 97f57c21a..134b19014 100644 --- a/src/ImageProcessorCore/Colors/Colorspaces/IAlmostEquatable.cs +++ b/src/ImageProcessorCore/Colors/Colorspaces/IAlmostEquatable.cs @@ -12,8 +12,9 @@ namespace ImageProcessorCore /// a type-specific method for determining approximate equality of instances. /// /// The type of objects to compare. - /// The object specifying the type to specify precision with. - public interface IAlmostEquatable where TPacked : struct, IComparable + /// The object specifying the type to specify precision with. + public interface IAlmostEquatable + where TPrecision : struct, IComparable { /// /// Indicates whether the current object is equal to another object of the same type @@ -24,6 +25,6 @@ namespace ImageProcessorCore /// /// true if the current object is equal to the other parameter; otherwise, false. /// - bool AlmostEquals(TColor other, TPacked precision); + bool AlmostEquals(TColor other, TPrecision precision); } } diff --git a/src/ImageProcessorCore/Common/Extensions/ByteExtensions.cs b/src/ImageProcessorCore/Common/Extensions/ByteExtensions.cs index bee549c0f..f5da2252b 100644 --- a/src/ImageProcessorCore/Common/Extensions/ByteExtensions.cs +++ b/src/ImageProcessorCore/Common/Extensions/ByteExtensions.cs @@ -20,7 +20,7 @@ namespace ImageProcessorCore /// The number of bits per value. /// The resulting array. Is never null. /// is null. - /// is less than or equals than zero. + /// is less than or equals than zero. public static byte[] ToArrayByBitsLength(this byte[] bytes, int bits) { Guard.NotNull(bytes, "bytes"); diff --git a/src/ImageProcessorCore/Common/Helpers/Guard.cs b/src/ImageProcessorCore/Common/Helpers/Guard.cs index 6940a460e..4e8c764f7 100644 --- a/src/ImageProcessorCore/Common/Helpers/Guard.cs +++ b/src/ImageProcessorCore/Common/Helpers/Guard.cs @@ -1,16 +1,8 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. // -// -// Provides methods to protect against invalid parameters. -// -// -------------------------------------------------------------------------------------------------------------------- -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("ImageProcessorCore.Tests")] namespace ImageProcessorCore { using System; @@ -26,18 +18,10 @@ namespace ImageProcessorCore /// Verifies, that the method parameter with specified object value is not null /// and throws an exception if it is found to be so. /// - /// - /// The target object, which cannot be null. - /// - /// - /// The name of the parameter that is to be checked. - /// - /// - /// The error message, if any to add to the exception. - /// - /// - /// is null - /// + /// The target object, which cannot be null. + /// The name of the parameter that is to be checked. + /// The error message, if any to add to the exception. + /// is null public static void NotNull(object target, string parameterName, string message = "") { if (target == null) @@ -58,13 +42,8 @@ namespace ImageProcessorCore /// /// The target string, which should be checked against being null or empty. /// Name of the parameter. - /// - /// is null. - /// - /// - /// is - /// empty or contains only blanks. - /// + /// is null. + /// is empty or contains only blanks. public static void NotNullOrEmpty(string target, string parameterName) { if (target == null) @@ -94,9 +73,7 @@ namespace ImageProcessorCore { if (value.CompareTo(max) >= 0) { - throw new ArgumentOutOfRangeException( - parameterName, - $"Value must be less than {max}."); + throw new ArgumentOutOfRangeException(parameterName, $"Value must be less than {max}."); } } @@ -116,9 +93,7 @@ namespace ImageProcessorCore { if (value.CompareTo(max) > 0) { - throw new ArgumentOutOfRangeException( - parameterName, - $"Value must be less than or equal to {max}."); + throw new ArgumentOutOfRangeException(parameterName, $"Value must be less than or equal to {max}."); } } @@ -134,7 +109,7 @@ namespace ImageProcessorCore /// is less than the minimum value. /// public static void MustBeGreaterThan(TValue value, TValue min, string parameterName) - where TValue : IComparable + where TValue : IComparable { if (value.CompareTo(min) <= 0) { @@ -156,13 +131,11 @@ namespace ImageProcessorCore /// is less than the minimum value. /// public static void MustBeGreaterThanOrEqualTo(TValue value, TValue min, string parameterName) - where TValue : IComparable + where TValue : IComparable { if (value.CompareTo(min) < 0) { - throw new ArgumentOutOfRangeException( - parameterName, - $"Value must be greater than or equal to {min}."); + throw new ArgumentOutOfRangeException(parameterName, $"Value must be greater than or equal to {min}."); } } @@ -175,17 +148,15 @@ namespace ImageProcessorCore /// The maximum value. /// The name of the parameter that is to be checked. /// The type of the value. - /// + /// /// is less than the minimum value of greater than the maximum value. /// public static void MustBeBetweenOrEqualTo(TValue value, TValue min, TValue max, string parameterName) - where TValue : IComparable + where TValue : IComparable { if (value.CompareTo(min) < 0 || value.CompareTo(max) > 0) { - throw new ArgumentOutOfRangeException( - parameterName, - $"Value must be greater than or equal to {min} and less than or equal to {max}."); + throw new ArgumentOutOfRangeException(parameterName, $"Value must be greater than or equal to {min} and less than or equal to {max}."); } } @@ -202,7 +173,7 @@ namespace ImageProcessorCore /// /// The error message, if any to add to the exception. /// - /// + /// /// is null /// public static void IsTrue(bool target, string parameterName, string message = "") @@ -222,15 +193,9 @@ namespace ImageProcessorCore /// Verifies, that the method parameter with specified target value is false /// and throws an exception if it is found to be so. /// - /// - /// The target value, which cannot be true. - /// - /// - /// The name of the parameter that is to be checked. - /// - /// - /// The error message, if any to add to the exception. - /// + /// The target value, which cannot be true. + /// The name of the parameter that is to be checked. + /// The error message, if any to add to the exception. /// /// is null /// diff --git a/src/ImageProcessorCore/Filters/Blend.cs b/src/ImageProcessorCore/Filters/Blend.cs index 77b65cf20..215bd23eb 100644 --- a/src/ImageProcessorCore/Filters/Blend.cs +++ b/src/ImageProcessorCore/Filters/Blend.cs @@ -1,7 +1,7 @@ // // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. -// ------------------------------------------------------------------------------------------------------------------- +// namespace ImageProcessorCore { @@ -15,10 +15,10 @@ namespace ImageProcessorCore /// /// Combines 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 packed format. uint, long, float. + /// The image this method extends. + /// The image to blend with the currently processing image. /// The opacity of the image image to blend. Must be between 0 and 100. /// A delegate which is called as progress is made processing the image. /// The . diff --git a/src/ImageProcessorCore/Filters/BoxBlur.cs b/src/ImageProcessorCore/Filters/BoxBlur.cs index acbd0d895..f4a0ce238 100644 --- a/src/ImageProcessorCore/Filters/BoxBlur.cs +++ b/src/ImageProcessorCore/Filters/BoxBlur.cs @@ -15,8 +15,8 @@ namespace ImageProcessorCore /// /// Applies a box blur to the image. /// - /// The pixel format. - /// The packed format. uint, long, float. + /// The pixel format. + /// The packed format. long, float. /// The image this method extends. /// The 'radius' value representing the size of the area to sample. /// A delegate which is called as progress is made processing the image. @@ -31,8 +31,8 @@ namespace ImageProcessorCore /// /// Applies a box blur to the image. /// - /// The pixel format. - /// The packed format. uint, long, float. + /// The pixel format. + /// The packed format. long, float. /// The image this method extends. /// The 'radius' value representing the size of the area to sample. /// diff --git a/src/ImageProcessorCore/Filters/DetectEdges.cs b/src/ImageProcessorCore/Filters/DetectEdges.cs index 9e906fcf7..60006ea72 100644 --- a/src/ImageProcessorCore/Filters/DetectEdges.cs +++ b/src/ImageProcessorCore/Filters/DetectEdges.cs @@ -29,7 +29,7 @@ namespace ImageProcessorCore } /// - /// Detects any edges within the image. Uses the filter + /// Detects any edges within the image. Uses the filter /// operating in Grayscale mode. /// /// The pixel format. @@ -118,7 +118,7 @@ namespace ImageProcessorCore break; default: - processor = new ScharrProcessor { Grayscale = grayscale }; + processor = new SobelProcessor { Grayscale = grayscale }; break; } diff --git a/src/ImageProcessorCore/Filters/Invert.cs b/src/ImageProcessorCore/Filters/Invert.cs index e1f59d8d3..ed7124662 100644 --- a/src/ImageProcessorCore/Filters/Invert.cs +++ b/src/ImageProcessorCore/Filters/Invert.cs @@ -1,20 +1,22 @@ // // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. -// ------------------------------------------------------------------------------------------------------------------- +// namespace ImageProcessorCore { using Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Inverts the colors of the image. /// + /// The pixel format. + /// The packed format. uint, long, float. /// The image this method extends. /// A delegate which is called as progress is made processing the image. /// The . @@ -28,6 +30,8 @@ namespace ImageProcessorCore /// /// Inverts the colors of the image. /// + /// The pixel format. + /// The packed format. uint, long, float. /// The image this method extends. /// /// The structure that specifies the portion of the image object to alter. diff --git a/src/ImageProcessorCore/Filters/Kodachrome.cs b/src/ImageProcessorCore/Filters/Kodachrome.cs index 9a27f2010..7310703b0 100644 --- a/src/ImageProcessorCore/Filters/Kodachrome.cs +++ b/src/ImageProcessorCore/Filters/Kodachrome.cs @@ -10,6 +10,8 @@ namespace ImageProcessorCore /// /// Extension methods for the type. /// + /// The pixel format. + /// The packed format. uint, long, float. public static partial class ImageExtensions { /// diff --git a/src/ImageProcessorCore/Filters/Pixelate.cs b/src/ImageProcessorCore/Filters/Pixelate.cs index 32b443881..a9b7f63af 100644 --- a/src/ImageProcessorCore/Filters/Pixelate.cs +++ b/src/ImageProcessorCore/Filters/Pixelate.cs @@ -11,13 +11,13 @@ namespace ImageProcessorCore /// /// Extension methods for the type. /// - /// The pixel format. - /// The packed format. uint, long, float. public static partial class ImageExtensions { /// /// Pixelates and image with the given pixel size. /// + /// The pixel format. + /// The packed format. uint, long, float. /// The image this method extends. /// The size of the pixels. /// A delegate which is called as progress is made processing the image. @@ -32,6 +32,8 @@ namespace ImageProcessorCore /// /// Pixelates and image with the given pixel size. /// + /// The pixel format. + /// The packed format. uint, long, float. /// The image this method extends. /// The size of the pixels. /// diff --git a/src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs b/src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs index 2b04b6a33..9572cf63b 100644 --- a/src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs @@ -22,7 +22,7 @@ namespace ImageProcessorCore.Processors /// Initializes a new instance of the class. /// /// The percentage to adjust the opacity of the image. Must be between 0 and 100. - /// + /// /// is less than 0 or is greater than 100. /// public AlphaProcessor(int percent) diff --git a/src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs b/src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs index b5a22e796..cb3173385 100644 --- a/src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs @@ -24,7 +24,7 @@ namespace ImageProcessorCore.Processors /// /// Initializes a new instance of the class. /// - /// The to set the background color to. + /// The to set the background color to. public BackgroundColorProcessor(TColor color) { this.Value = color; diff --git a/src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs b/src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs index bb6845878..4b4f67b50 100644 --- a/src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs @@ -22,7 +22,7 @@ namespace ImageProcessorCore.Processors /// Initializes a new instance of the class. /// /// The threshold to split the image. Must be between 0 and 1. - /// + /// /// is less than 0 or is greater than 1. /// public BinaryThresholdProcessor(float threshold) @@ -111,4 +111,4 @@ namespace ImageProcessorCore.Processors } } } -} \ No newline at end of file +} diff --git a/src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs b/src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs index 1cf51c1d1..1b333b6f0 100644 --- a/src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs @@ -24,7 +24,7 @@ namespace ImageProcessorCore.Processors private readonly ImageBase blend; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The image to blend with the currently processing image. diff --git a/src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs b/src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs index f1259dac5..f87e514e9 100644 --- a/src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs @@ -22,7 +22,7 @@ namespace ImageProcessorCore.Processors /// Initializes a new instance of the class. /// /// The new brightness of the image. Must be between -100 and 100. - /// + /// /// is less than -100 or is greater than 100. /// public BrightnessProcessor(int brightness) diff --git a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/HueProcessor.cs b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/HueProcessor.cs index a497f5bd4..afe6dbca9 100644 --- a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/HueProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/HueProcessor.cs @@ -9,7 +9,7 @@ namespace ImageProcessorCore.Processors using System.Numerics; /// - /// An to change the hue of an . + /// An to change the hue of an . /// /// The pixel format. /// The packed format. uint, long, float. @@ -18,12 +18,7 @@ namespace ImageProcessorCore.Processors where TPacked : struct { /// - /// The used to alter the image. - /// - private Matrix4x4 matrix; - - /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The new brightness of the image. Must be between -100 and 100. public HueProcessor(float angle) @@ -67,7 +62,7 @@ namespace ImageProcessorCore.Processors M33 = (float)(lumB + (cosradians * oneMinusLumB) + (sinradians * lumB)) }; - this.matrix = matrix4X4; + this.Matrix = matrix4X4; } /// @@ -76,7 +71,7 @@ namespace ImageProcessorCore.Processors public float Angle { get; } /// - public override Matrix4x4 Matrix => this.matrix; + public override Matrix4x4 Matrix { get; } /// public override bool Compand => false; diff --git a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/IColorMatrixFilter.cs b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/IColorMatrixFilter.cs index cb4c3c36a..f1f6377ef 100644 --- a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/IColorMatrixFilter.cs +++ b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/IColorMatrixFilter.cs @@ -11,6 +11,8 @@ namespace ImageProcessorCore.Processors /// Encapsulates properties and methods for creating processors that utilize a matrix to /// alter the image pixels. /// + /// The pixel format. + /// The packed format. uint, long, float. public interface IColorMatrixFilter : IImageProcessor where TColor : IPackedVector where TPacked : struct diff --git a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/PolaroidProcessor.cs b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/PolaroidProcessor.cs index 956896c64..c737a7bb6 100644 --- a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/PolaroidProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/PolaroidProcessor.cs @@ -45,4 +45,4 @@ namespace ImageProcessorCore.Processors new GlowProcessor { GlowColor = packedG, Radius = target.Width / 4F }.Apply(target, target, sourceRectangle); } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/SaturationProcessor.cs b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/SaturationProcessor.cs index ae031fed9..37612357a 100644 --- a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/SaturationProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/SaturationProcessor.cs @@ -8,7 +8,7 @@ namespace ImageProcessorCore.Processors using System.Numerics; /// - /// An to change the saturation of an . + /// An to change the saturation of an . /// /// The pixel format. /// The packed format. uint, long, float. @@ -17,28 +17,16 @@ namespace ImageProcessorCore.Processors where TPacked : struct { /// - /// The saturation to be applied to the image. - /// - private readonly int saturation; - - /// - /// The used to alter the image. - /// - private Matrix4x4 matrix; - - /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The new saturation of the image. Must be between -100 and 100. - /// + /// /// is less than -100 or is greater than 100. /// public SaturationProcessor(int saturation) { Guard.MustBeBetweenOrEqualTo(saturation, -100, 100, nameof(saturation)); - this.saturation = saturation; - - float saturationFactor = this.saturation / 100f; + float saturationFactor = saturation / 100f; // Stop at -1 to prevent inversion. saturationFactor++; @@ -65,10 +53,10 @@ namespace ImageProcessorCore.Processors M33 = saturationComplementB + saturationFactor, }; - this.matrix = matrix4X4; + this.Matrix = matrix4X4; } /// - public override Matrix4x4 Matrix => this.matrix; + public override Matrix4x4 Matrix { get; } } } diff --git a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/SepiaProcessor.cs b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/SepiaProcessor.cs index 6a4b2c880..040d48884 100644 --- a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/SepiaProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/SepiaProcessor.cs @@ -34,4 +34,4 @@ namespace ImageProcessorCore.Processors /// public override bool Compand => false; } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs b/src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs index 91a7e4a12..54a9e10cc 100644 --- a/src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs @@ -12,17 +12,17 @@ namespace ImageProcessorCore.Processors /// /// An to change the contrast of an . /// - /// The pixel format. - /// The packed format. uint, long, float. + /// The pixel format. + /// The packed format. long, float. public class ContrastProcessor : ImageProcessor where TColor : IPackedVector where TPacked : struct { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The new contrast of the image. Must be between -100 and 100. - /// + /// /// is less than -100 or is greater than 100. /// public ContrastProcessor(int contrast) diff --git a/src/ImageProcessorCore/Filters/Processors/Convolution/BoxBlurProcessor.cs b/src/ImageProcessorCore/Filters/Processors/Convolution/BoxBlurProcessor.cs index f8c2d9109..1b8430f5f 100644 --- a/src/ImageProcessorCore/Filters/Processors/Convolution/BoxBlurProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/Convolution/BoxBlurProcessor.cs @@ -30,7 +30,7 @@ namespace ImageProcessorCore.Processors private float[,] kernelX; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The 'radius' value representing the size of the area to sample. diff --git a/src/ImageProcessorCore/Filters/Processors/Convolution/ConvolutionFilter.cs b/src/ImageProcessorCore/Filters/Processors/Convolution/ConvolutionFilter.cs index dfc026bae..da0c11df5 100644 --- a/src/ImageProcessorCore/Filters/Processors/Convolution/ConvolutionFilter.cs +++ b/src/ImageProcessorCore/Filters/Processors/Convolution/ConvolutionFilter.cs @@ -11,6 +11,8 @@ namespace ImageProcessorCore.Processors /// /// Defines a filter that uses a 2 dimensional matrix to perform convolution against an image. /// + /// The pixel format. + /// The packed format. uint, long, float. public abstract class ConvolutionFilter : ImageProcessor where TColor : IPackedVector where TPacked : struct diff --git a/src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/EdgeDetector2DFilter.cs b/src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/EdgeDetector2DFilter.cs index 6475ad7cb..34a589630 100644 --- a/src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/EdgeDetector2DFilter.cs +++ b/src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/EdgeDetector2DFilter.cs @@ -9,6 +9,8 @@ namespace ImageProcessorCore.Processors /// Defines a filter that detects edges within an image using two /// one-dimensional matrices. /// + /// The pixel format. + /// The packed format. uint, long, float. public abstract class EdgeDetector2DFilter : Convolution2DFilter, IEdgeDetectorFilter where TColor : IPackedVector where TPacked : struct diff --git a/src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/EdgeDetectorFilter.cs b/src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/EdgeDetectorFilter.cs index 2d221664d..04cd2cddd 100644 --- a/src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/EdgeDetectorFilter.cs +++ b/src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/EdgeDetectorFilter.cs @@ -9,6 +9,8 @@ namespace ImageProcessorCore.Processors /// Defines a filter that detects edges within an image using a single /// two dimensional matrix. /// + /// The pixel format. + /// The packed format. uint, long, float. public abstract class EdgeDetectorFilter : ConvolutionFilter, IEdgeDetectorFilter where TColor : IPackedVector where TPacked : struct diff --git a/src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/IEdgeDetectorFilter.cs b/src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/IEdgeDetectorFilter.cs index e101612b6..620db328e 100644 --- a/src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/IEdgeDetectorFilter.cs +++ b/src/ImageProcessorCore/Filters/Processors/Convolution/EdgeDetection/IEdgeDetectorFilter.cs @@ -8,6 +8,8 @@ namespace ImageProcessorCore.Processors /// /// Provides properties and methods allowing the detection of edges within an image. /// + /// The pixel format. + /// The packed format. uint, long, float. public interface IEdgeDetectorFilter : IImageProcessor, IEdgeDetectorFilter where TColor : IPackedVector where TPacked : struct diff --git a/src/ImageProcessorCore/Filters/Processors/Convolution/GuassianBlurProcessor.cs b/src/ImageProcessorCore/Filters/Processors/Convolution/GuassianBlurProcessor.cs index 7ab5fe4fb..7a9b0137f 100644 --- a/src/ImageProcessorCore/Filters/Processors/Convolution/GuassianBlurProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/Convolution/GuassianBlurProcessor.cs @@ -37,7 +37,7 @@ namespace ImageProcessorCore.Processors private float[,] kernelX; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The 'sigma' value representing the weight of the blur. public GuassianBlurProcessor(float sigma = 3f) @@ -47,7 +47,7 @@ namespace ImageProcessorCore.Processors } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The 'radius' value representing the size of the area to sample. @@ -59,7 +59,7 @@ namespace ImageProcessorCore.Processors } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The 'sigma' value representing the weight of the blur. diff --git a/src/ImageProcessorCore/Filters/Processors/Convolution/GuassianSharpenProcessor.cs b/src/ImageProcessorCore/Filters/Processors/Convolution/GuassianSharpenProcessor.cs index 2c290f2df..18704faf1 100644 --- a/src/ImageProcessorCore/Filters/Processors/Convolution/GuassianSharpenProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/Convolution/GuassianSharpenProcessor.cs @@ -37,7 +37,7 @@ namespace ImageProcessorCore.Processors private float[,] kernelX; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The 'sigma' value representing the weight of the sharpening. @@ -49,7 +49,7 @@ namespace ImageProcessorCore.Processors } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The 'radius' value representing the size of the area to sample. @@ -61,7 +61,7 @@ namespace ImageProcessorCore.Processors } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The 'sigma' value representing the weight of the sharpen. diff --git a/src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs b/src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs index ee6b07d17..10a68ffcf 100644 --- a/src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs @@ -15,11 +15,11 @@ namespace ImageProcessorCore.Processors /// The pixel format. /// The packed format. uint, long, float. public class GlowProcessor : ImageProcessor - where TColor : IPackedVector - where TPacked : struct + where TColor : IPackedVector + where TPacked : struct { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public GlowProcessor() { diff --git a/src/ImageProcessorCore/Filters/Processors/PixelateProcessor.cs b/src/ImageProcessorCore/Filters/Processors/PixelateProcessor.cs index 4e5c63ed4..300081050 100644 --- a/src/ImageProcessorCore/Filters/Processors/PixelateProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/PixelateProcessor.cs @@ -19,7 +19,7 @@ namespace ImageProcessorCore.Processors where TPacked : struct { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The size of the pixels. Must be greater than 0. /// @@ -110,4 +110,4 @@ namespace ImageProcessorCore.Processors } } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs b/src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs index c6e8cf35e..142f20e6b 100644 --- a/src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs @@ -96,5 +96,4 @@ namespace ImageProcessorCore.Processors } } } -} - +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Filters/Sepia.cs b/src/ImageProcessorCore/Filters/Sepia.cs index 750d3016f..126c0d92a 100644 --- a/src/ImageProcessorCore/Filters/Sepia.cs +++ b/src/ImageProcessorCore/Filters/Sepia.cs @@ -55,4 +55,4 @@ namespace ImageProcessorCore } } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Formats/Bmp/BmpDecoder.cs b/src/ImageProcessorCore/Formats/Bmp/BmpDecoder.cs index c87de4cc0..2f2484554 100644 --- a/src/ImageProcessorCore/Formats/Bmp/BmpDecoder.cs +++ b/src/ImageProcessorCore/Formats/Bmp/BmpDecoder.cs @@ -71,8 +71,8 @@ namespace ImageProcessorCore.Formats /// public void Decode(Image image, Stream stream) - where TColor : IPackedVector - where TPacked : struct + where TColor : IPackedVector + where TPacked : struct { Guard.NotNull(image, "image"); Guard.NotNull(stream, "stream"); diff --git a/src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs b/src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs index 82d7823f4..9aa612b80 100644 --- a/src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageProcessorCore/Formats/Bmp/BmpDecoderCore.cs @@ -128,8 +128,7 @@ namespace ImageProcessorCore.Formats case BmpCompression.RGB: if (this.infoHeader.HeaderSize != 40) { - throw new ImageFormatException( - $"Header Size value '{this.infoHeader.HeaderSize}' is not valid."); + throw new ImageFormatException($"Header Size value '{this.infoHeader.HeaderSize}' is not valid."); } if (this.infoHeader.BitsPerPixel == 32) @@ -190,7 +189,7 @@ namespace ImageProcessorCore.Formats /// /// The pixel format. /// The packed format. uint, long, float. - /// The image data to assign the palette to. + /// The image data to assign the palette to. /// The containing the colors. /// The width of the bitmap. /// The height of the bitmap. @@ -255,7 +254,7 @@ namespace ImageProcessorCore.Formats /// /// The pixel format. /// The packed format. uint, long, float. - /// The image data to assign the palette to. + /// The image data to assign the palette to. /// The width of the bitmap. /// The height of the bitmap. /// Whether the bitmap is inverted. @@ -306,7 +305,7 @@ namespace ImageProcessorCore.Formats /// /// The pixel format. /// The packed format. uint, long, float. - /// The image data to assign the palette to. + /// The image data to assign the palette to. /// The width of the bitmap. /// The height of the bitmap. /// Whether the bitmap is inverted. @@ -347,7 +346,7 @@ namespace ImageProcessorCore.Formats /// /// The pixel format. /// The packed format. uint, long, float. - /// The image data to assign the palette to. + /// The image data to assign the palette to. /// The width of the bitmap. /// The height of the bitmap. /// Whether the bitmap is inverted. diff --git a/src/ImageProcessorCore/Formats/Bmp/BmpEncoderCore.cs b/src/ImageProcessorCore/Formats/Bmp/BmpEncoderCore.cs index 5b959d844..d296d3241 100644 --- a/src/ImageProcessorCore/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageProcessorCore/Formats/Bmp/BmpEncoderCore.cs @@ -27,8 +27,8 @@ namespace ImageProcessorCore.Formats /// /// Encodes the image to the specified stream from the . /// - /// The pixel format. - /// The packed format. uint, long, float. + /// The pixel format. + /// The packed format. long, float. /// The to encode from. /// The to encode the image data to. /// The @@ -134,11 +134,11 @@ namespace ImageProcessorCore.Formats switch (this.bmpBitsPerPixel) { case BmpBitsPerPixel.Pixel32: - this.Write32Bit(writer, pixels); + this.Write32Bit(writer, pixels); break; case BmpBitsPerPixel.Pixel24: - this.Write24Bit(writer, pixels); + this.Write24Bit(writer, pixels); break; } } @@ -150,7 +150,7 @@ namespace ImageProcessorCore.Formats /// The pixel format. /// The packed format. uint, long, float. /// The containing the stream to write to. - /// The containing pixel data. + /// The containing pixel data. private void Write32Bit(EndianBinaryWriter writer, PixelAccessor pixels) where TColor : IPackedVector where TPacked : struct @@ -176,8 +176,9 @@ namespace ImageProcessorCore.Formats /// Writes the 24bit color palette to the stream. /// /// The pixel format. - /// The packed format. uint, long, float./// The containing the stream to write to. - /// The containing pixel data. + /// The packed format. uint, long, float. + /// The containing the stream to write to. + /// The containing pixel data. private void Write24Bit(EndianBinaryWriter writer, PixelAccessor pixels) where TColor : IPackedVector where TPacked : struct diff --git a/src/ImageProcessorCore/Formats/Gif/GifDecoderCore.cs b/src/ImageProcessorCore/Formats/Gif/GifDecoderCore.cs index d37bca929..766e5bb33 100644 --- a/src/ImageProcessorCore/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageProcessorCore/Formats/Gif/GifDecoderCore.cs @@ -12,7 +12,7 @@ namespace ImageProcessorCore.Formats /// Performs the gif decoding operation. /// /// The pixel format. - /// The packed format. uint, long, float. + /// The packed format. uint, long, float. internal class GifDecoderCore where TColor : IPackedVector where TPacked : struct diff --git a/src/ImageProcessorCore/Formats/Gif/LzwDecoder.cs b/src/ImageProcessorCore/Formats/Gif/LzwDecoder.cs index 1474cc708..7135ca62e 100644 --- a/src/ImageProcessorCore/Formats/Gif/LzwDecoder.cs +++ b/src/ImageProcessorCore/Formats/Gif/LzwDecoder.cs @@ -5,7 +5,6 @@ namespace ImageProcessorCore.Formats { - using System; using System.IO; /// diff --git a/src/ImageProcessorCore/Formats/Gif/LzwEncoder.cs b/src/ImageProcessorCore/Formats/Gif/LzwEncoder.cs index 469cacbce..a9681d2c5 100644 --- a/src/ImageProcessorCore/Formats/Gif/LzwEncoder.cs +++ b/src/ImageProcessorCore/Formats/Gif/LzwEncoder.cs @@ -310,7 +310,7 @@ namespace ImageProcessorCore.Formats } /// - /// Return the nexTColor pixel from the image + /// Return the next pixel from the image /// /// /// The diff --git a/src/ImageProcessorCore/Formats/Gif/Sections/GifGraphicsControlExtension.cs b/src/ImageProcessorCore/Formats/Gif/Sections/GifGraphicsControlExtension.cs index 59dbceb21..071dc62c8 100644 --- a/src/ImageProcessorCore/Formats/Gif/Sections/GifGraphicsControlExtension.cs +++ b/src/ImageProcessorCore/Formats/Gif/Sections/GifGraphicsControlExtension.cs @@ -27,7 +27,7 @@ namespace ImageProcessorCore.Formats /// /// Gets or sets the transparency index. /// The Transparency Index is such that when encountered, the corresponding pixel - /// of the display device is not modified and processing goes on to the nexTColor pixel. + /// of the display device is not modified and processing goes on to the next pixel. /// public int TransparencyIndex { get; set; } diff --git a/src/ImageProcessorCore/Formats/IImageEncoder.cs b/src/ImageProcessorCore/Formats/IImageEncoder.cs index 808371456..445b7f645 100644 --- a/src/ImageProcessorCore/Formats/IImageEncoder.cs +++ b/src/ImageProcessorCore/Formats/IImageEncoder.cs @@ -38,11 +38,11 @@ namespace ImageProcessorCore.Formats bool IsSupportedFileExtension(string extension); /// - /// Encodes the image to the specified stream from the . + /// Encodes the image to the specified stream from the . /// /// The pixel format. /// The packed format. uint, long, float. - /// The to encode from. + /// The to encode from. /// The to encode the image data to. void Encode(Image image, Stream stream) where TColor : IPackedVector diff --git a/src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id b/src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id index bd65b8702..2fb48cb7e 100644 --- a/src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id +++ b/src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id @@ -1 +1 @@ -d6ce5dd6236ac6ef9ba570fb4e57e81c06bbb854 \ No newline at end of file +457ce2b70d772a8f3b259b2d624fcb41c75357e1 \ No newline at end of file diff --git a/src/ImageProcessorCore/Formats/Jpg/JpegEncoderCore.cs b/src/ImageProcessorCore/Formats/Jpg/JpegEncoderCore.cs index 783406a28..ef6df20ab 100644 --- a/src/ImageProcessorCore/Formats/Jpg/JpegEncoderCore.cs +++ b/src/ImageProcessorCore/Formats/Jpg/JpegEncoderCore.cs @@ -504,7 +504,7 @@ namespace ImageProcessorCore.Formats // Write the image data. using (PixelAccessor pixels = image.Lock()) { - this.WriteSOS(pixels); + this.WriteSOS(pixels); } // Write the End Of Image marker. @@ -720,10 +720,10 @@ namespace ImageProcessorCore.Formats switch (this.subsample) { case JpegSubsample.Ratio444: - this.Encode444(pixels); + this.Encode444(pixels); break; case JpegSubsample.Ratio420: - this.Encode420(pixels); + this.Encode420(pixels); break; } @@ -750,7 +750,7 @@ namespace ImageProcessorCore.Formats { for (int x = 0; x < pixels.Width; x += 8) { - this.ToYCbCr(pixels, x, y, b, cb, cr); + this.ToYCbCr(pixels, x, y, b, cb, cr); prevDCY = this.WriteBlock(b, QuantIndex.Luminance, prevDCY); prevDCCb = this.WriteBlock(cb, QuantIndex.Chrominance, prevDCCb); prevDCCr = this.WriteBlock(cr, QuantIndex.Chrominance, prevDCCr); @@ -784,7 +784,7 @@ namespace ImageProcessorCore.Formats int xOff = (i & 1) * 8; int yOff = (i & 2) * 4; - this.ToYCbCr(pixels, x + xOff, y + yOff, b, cb[i], cr[i]); + this.ToYCbCr(pixels, x + xOff, y + yOff, b, cb[i], cr[i]); prevDCY = this.WriteBlock(b, QuantIndex.Luminance, prevDCY); } diff --git a/src/ImageProcessorCore/Formats/Png/Filters/UpFilter.cs b/src/ImageProcessorCore/Formats/Png/Filters/UpFilter.cs index deb4d9d0d..8f87ec1ca 100644 --- a/src/ImageProcessorCore/Formats/Png/Filters/UpFilter.cs +++ b/src/ImageProcessorCore/Formats/Png/Filters/UpFilter.cs @@ -6,7 +6,7 @@ namespace ImageProcessorCore.Formats { /// - /// The Up filter is just like the Sub filter except that the pixel immediately above the currenTColor pixel, + /// The Up filter is just like the Sub filter except that the pixel immediately above the current pixel, /// rather than just to its left, is used as the predictor. /// /// diff --git a/src/ImageProcessorCore/Formats/Png/PngDecoder.cs b/src/ImageProcessorCore/Formats/Png/PngDecoder.cs index 264971e4d..0fad54dd7 100644 --- a/src/ImageProcessorCore/Formats/Png/PngDecoder.cs +++ b/src/ImageProcessorCore/Formats/Png/PngDecoder.cs @@ -77,6 +77,8 @@ namespace ImageProcessorCore.Formats /// /// Decodes the image from the specified stream to the . /// + /// The pixel format. + /// The packed format. uint, long, float. /// The to decode to. /// The containing image data. public void Decode(Image image, Stream stream) diff --git a/src/ImageProcessorCore/Formats/Png/PngDecoderCore.cs b/src/ImageProcessorCore/Formats/Png/PngDecoderCore.cs index 3cf8be40e..ab27ccd17 100644 --- a/src/ImageProcessorCore/Formats/Png/PngDecoderCore.cs +++ b/src/ImageProcessorCore/Formats/Png/PngDecoderCore.cs @@ -81,13 +81,13 @@ namespace ImageProcessorCore.Formats /// Decodes the stream to the image. /// /// The pixel format. - /// The packed format. uint, long, float. + /// The packed format. uint, long, float. /// The image to decode to. /// The stream containing image data. /// /// Thrown if the stream does not contain and end chunk. /// - /// + /// /// Thrown if the image is larger than the maximum allowable size. /// public void Decode(Image image, Stream stream) @@ -150,11 +150,7 @@ namespace ImageProcessorCore.Formats } TColor[] pixels = new TColor[this.header.Width * this.header.Height]; - - this.ReadScanlines(dataStream, pixels); - - image.SetPixels(this.header.Width, this.header.Height, pixels); } } @@ -226,9 +222,10 @@ namespace ImageProcessorCore.Formats /// /// Reads the scanlines within the image. /// + /// The pixel format. + /// The packed format. uint, long, float. /// The containing data. - /// - /// The containing pixel data. + /// The pixel data. private void ReadScanlines(MemoryStream dataStream, TColor[] pixels) where TColor : IPackedVector where TPacked : struct diff --git a/src/ImageProcessorCore/Formats/Png/PngEncoder.cs b/src/ImageProcessorCore/Formats/Png/PngEncoder.cs index 660315c58..75f686857 100644 --- a/src/ImageProcessorCore/Formats/Png/PngEncoder.cs +++ b/src/ImageProcessorCore/Formats/Png/PngEncoder.cs @@ -73,8 +73,8 @@ namespace ImageProcessorCore.Formats /// public void Encode(Image image, Stream stream) - where TColor : IPackedVector - where TPacked : struct + where TColor : IPackedVector + where TPacked : struct { PngEncoderCore encoder = new PngEncoderCore { diff --git a/src/ImageProcessorCore/IO/EndianBitConverter.cs b/src/ImageProcessorCore/IO/EndianBitConverter.cs index 71cba1a51..107148100 100644 --- a/src/ImageProcessorCore/IO/EndianBitConverter.cs +++ b/src/ImageProcessorCore/IO/EndianBitConverter.cs @@ -246,7 +246,7 @@ namespace ImageProcessorCore.IO /// The start index passed in /// The number of bytes required /// value is a null reference - /// + /// /// startIndex is less than zero or greater than the length of value minus bytesRequired. /// [SuppressMessage("ReSharper", "UnusedParameter.Local", Justification = "Keeps code DRY")] diff --git a/src/ImageProcessorCore/Image/IImageBase.cs b/src/ImageProcessorCore/Image/IImageBase.cs index 1afd7daaf..cc2ef9a79 100644 --- a/src/ImageProcessorCore/Image/IImageBase.cs +++ b/src/ImageProcessorCore/Image/IImageBase.cs @@ -5,8 +5,6 @@ namespace ImageProcessorCore { - using System; - /// /// Encapsulates the basic properties and methods required to manipulate images in varying formats. /// @@ -27,10 +25,10 @@ namespace ImageProcessorCore /// The new width of the image. Must be greater than zero. /// The new height of the image. Must be greater than zero. /// The array with pixels. Must be a multiple of the width and height. - /// + /// /// Thrown if either or are less than or equal to 0. /// - /// + /// /// Thrown if the length is not equal to Width * Height. /// void SetPixels(int width, int height, TColor[] pixels); @@ -42,10 +40,10 @@ namespace ImageProcessorCore /// The new width of the image. Must be greater than zero. /// The new height of the image. Must be greater than zero. /// The array with pixels. Must be a multiple of four times the width and height. - /// + /// /// Thrown if either or are less than or equal to 0. /// - /// + /// /// Thrown if the length is not equal to Width * Height. /// void ClonePixels(int width, int height, TColor[] pixels); @@ -56,7 +54,7 @@ namespace ImageProcessorCore /// It is imperative that the accessor is correctly disposed off after use. /// /// - /// The + /// The PixelAccessor Lock(); } diff --git a/src/ImageProcessorCore/Image/IImageProcessor.cs b/src/ImageProcessorCore/Image/IImageProcessor.cs index cf9f2c15d..06f0514d8 100644 --- a/src/ImageProcessorCore/Image/IImageProcessor.cs +++ b/src/ImageProcessorCore/Image/IImageProcessor.cs @@ -44,7 +44,7 @@ namespace ImageProcessorCore.Processors bool Compand { get; set; } /// - /// Applies the process to the specified portion of the specified . + /// Applies the process to the specified portion of the specified . /// /// Target image to apply the process to. /// The source image. Cannot be null. @@ -64,7 +64,7 @@ namespace ImageProcessorCore.Processors void Apply(ImageBase target, ImageBase source, Rectangle sourceRectangle); /// - /// Applies the process to the specified portion of the specified at the specified + /// Applies the process to the specified portion of the specified at the specified /// location and with the specified size. /// /// Target image to apply the process to. diff --git a/src/ImageProcessorCore/Image/ImageBase.cs b/src/ImageProcessorCore/Image/ImageBase.cs index 9f4b36323..4d17d9f01 100644 --- a/src/ImageProcessorCore/Image/ImageBase.cs +++ b/src/ImageProcessorCore/Image/ImageBase.cs @@ -3,8 +3,6 @@ // Licensed under the Apache License, Version 2.0. // -using System.Runtime.CompilerServices; - namespace ImageProcessorCore { using System; @@ -12,20 +10,15 @@ namespace ImageProcessorCore /// /// The base class of all images. Encapsulates the basic properties and methods required to manipulate - /// images in differenTColor pixel formats. + /// images in different pixel formats. /// /// The pixel format. /// The packed format. uint, long, float. [DebuggerDisplay("Image: {Width}x{Height}")] - public abstract unsafe class ImageBase : IImageBase + public abstract class ImageBase : IImageBase where TColor : IPackedVector where TPacked : struct { - /// - /// The image pixels - /// - private TColor[] pixelBuffer; - /// /// Initializes a new instance of the class. /// @@ -38,7 +31,7 @@ namespace ImageProcessorCore /// /// The width of the image in pixels. /// The height of the image in pixels. - /// + /// /// Thrown if either or are less than or equal to 0. /// protected ImageBase(int width, int height) @@ -48,7 +41,7 @@ namespace ImageProcessorCore this.Width = width; this.Height = height; - this.pixelBuffer = new TColor[width * height]; + this.Pixels = new TColor[width * height]; } /// @@ -68,9 +61,9 @@ namespace ImageProcessorCore this.Height = other.Height; this.CopyProperties(other); - // Copy the pixels. - this.pixelBuffer = new TColor[this.Width * this.Height]; - Unsafe.Copy(Unsafe.AsPointer(ref this.pixelBuffer), ref other.pixelBuffer); + // Copy the pixels. Don't use Unsafe.Copy as it is breaking edge detection. + this.Pixels = new TColor[this.Width * this.Height]; + Array.Copy(other.Pixels, this.Pixels, other.Pixels.Length); } /// @@ -80,7 +73,7 @@ namespace ImageProcessorCore public int MaxHeight { get; set; } = int.MaxValue; /// - public TColor[] Pixels => this.pixelBuffer; + public TColor[] Pixels { get; private set; } /// public int Width { get; private set; } @@ -103,15 +96,8 @@ namespace ImageProcessorCore /// public void SetPixels(int width, int height, TColor[] pixels) { - if (width <= 0) - { - throw new ArgumentOutOfRangeException(nameof(width), "Width must be greater than or equals than zero."); - } - - if (height <= 0) - { - throw new ArgumentOutOfRangeException(nameof(height), "Height must be greater than or equal than zero."); - } + Guard.MustBeGreaterThan(width, 0, nameof(width)); + Guard.MustBeGreaterThan(height, 0, nameof(height)); if (pixels.Length != width * height) { @@ -120,21 +106,14 @@ namespace ImageProcessorCore this.Width = width; this.Height = height; - this.pixelBuffer = pixels; + this.Pixels = pixels; } /// public void ClonePixels(int width, int height, TColor[] pixels) { - if (width <= 0) - { - throw new ArgumentOutOfRangeException(nameof(width), "Width must be greater than or equals than zero."); - } - - if (height <= 0) - { - throw new ArgumentOutOfRangeException(nameof(height), "Height must be greater than or equal than zero."); - } + Guard.MustBeGreaterThan(width, 0, nameof(width)); + Guard.MustBeGreaterThan(height, 0, nameof(height)); if (pixels.Length != width * height) { @@ -144,9 +123,9 @@ namespace ImageProcessorCore this.Width = width; this.Height = height; - // Copy the pixels. - this.pixelBuffer = new TColor[pixels.Length]; - Unsafe.Copy(Unsafe.AsPointer(ref this.pixelBuffer), ref pixels); + // Copy the pixels. Don't use Unsafe.Copy as it is breaking edge detection. + this.Pixels = new TColor[pixels.Length]; + Array.Copy(pixels, this.Pixels, pixels.Length); } /// diff --git a/src/ImageProcessorCore/Image/ImageExtensions.cs b/src/ImageProcessorCore/Image/ImageExtensions.cs index 476c2a48e..103f8c3eb 100644 --- a/src/ImageProcessorCore/Image/ImageExtensions.cs +++ b/src/ImageProcessorCore/Image/ImageExtensions.cs @@ -20,7 +20,7 @@ namespace ImageProcessorCore /// Saves the image to the given stream with the bmp format. /// /// The pixel format. - /// The packed format. uint, long, float. + /// The packed format. uint, long, float. /// The image this method extends. /// The stream to save the image to. /// Thrown if the stream is null. @@ -34,7 +34,7 @@ namespace ImageProcessorCore /// Saves the image to the given stream with the png format. /// /// The pixel format. - /// The packed format. uint, long, float. + /// The packed format. uint, long, float. /// The image this method extends. /// The stream to save the image to. /// The quality to save the image to representing the number of colors. @@ -50,7 +50,7 @@ namespace ImageProcessorCore /// Saves the image to the given stream with the jpeg format. /// /// The pixel format. - /// The packed format. uint, long, float. + /// The packed format. uint, long, float. /// The image this method extends. /// The stream to save the image to. /// The quality to save the image to. Between 1 and 100. @@ -64,7 +64,7 @@ namespace ImageProcessorCore /// Saves the image to the given stream with the gif format. /// /// The pixel format. - /// The packed format. uint, long, float. + /// The packed format. uint, long, float. /// The image this method extends. /// The stream to save the image to. /// The quality to save the image to representing the number of colors. Between 1 and 256. @@ -115,8 +115,8 @@ namespace ImageProcessorCore /// This method is not chainable. /// /// - /// The pixel format. - /// The packed format. uint, long, float. + /// The pixel format. + /// The packed format. long, float. /// The source image. Cannot be null. /// The target image width. /// The target image height. @@ -135,8 +135,8 @@ namespace ImageProcessorCore /// This method does will resize the target image if the source and target rectangles are different. /// /// - /// The pixel format. - /// The packed format. uint, long, float. + /// The pixel format. + /// The packed format. long, float. /// The source image. Cannot be null. /// The target image width. /// The target image height. @@ -159,8 +159,8 @@ namespace ImageProcessorCore /// /// Performs the given action on the source image. /// - /// The pixel format. - /// The packed format. uint, long, float. + /// The pixel format. + /// The packed format. long, float. /// The image to perform the action against. /// Whether to clone the image. /// The to perform against the image. diff --git a/src/ImageProcessorCore/Image/PixelAccessor.cs b/src/ImageProcessorCore/Image/PixelAccessor.cs index d7146e4aa..d6f15047e 100644 --- a/src/ImageProcessorCore/Image/PixelAccessor.cs +++ b/src/ImageProcessorCore/Image/PixelAccessor.cs @@ -14,7 +14,7 @@ namespace ImageProcessorCore /// /// The pixel format. /// The packed format. uint, long, float. - public sealed unsafe class PixelAccessor : IDisposable + public unsafe class PixelAccessor : IDisposable where TColor : IPackedVector where TPacked : struct { @@ -106,6 +106,7 @@ namespace ImageProcessorCore { get { return Unsafe.Read(this.pixelsBase + (y * this.Width + x) * Unsafe.SizeOf()); } set { Unsafe.Write(this.pixelsBase + (y * this.Width + x) * Unsafe.SizeOf(), value); } + } /// diff --git a/src/ImageProcessorCore/ImageProcessor.cs b/src/ImageProcessorCore/ImageProcessor.cs index 2ed0e56b2..10014e0f3 100644 --- a/src/ImageProcessorCore/ImageProcessor.cs +++ b/src/ImageProcessorCore/ImageProcessor.cs @@ -12,6 +12,8 @@ namespace ImageProcessorCore.Processors /// /// Allows the application of processors to images. /// + /// The pixel format. + /// The packed format. uint, long, float. public abstract class ImageProcessor : IImageProcessor where TColor : IPackedVector where TPacked : struct @@ -93,8 +95,6 @@ namespace ImageProcessorCore.Processors /// /// This method is called before the process is applied to prepare the processor. /// - /// The pixel format. - /// The packed format. uint, long, float. /// Target image to apply the process to. /// The source image. Cannot be null. /// diff --git a/src/ImageProcessorCore/Profiles/Exif/ExifProfile.cs b/src/ImageProcessorCore/Profiles/Exif/ExifProfile.cs index 638d721a7..2c1509fd0 100644 --- a/src/ImageProcessorCore/Profiles/Exif/ExifProfile.cs +++ b/src/ImageProcessorCore/Profiles/Exif/ExifProfile.cs @@ -2,9 +2,9 @@ // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // + namespace ImageProcessorCore { - using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; diff --git a/src/ImageProcessorCore/Quantizers/IQuantizer.cs b/src/ImageProcessorCore/Quantizers/IQuantizer.cs index af4733b11..e0087a52e 100644 --- a/src/ImageProcessorCore/Quantizers/IQuantizer.cs +++ b/src/ImageProcessorCore/Quantizers/IQuantizer.cs @@ -15,7 +15,7 @@ namespace ImageProcessorCore.Quantizers where TPacked : struct { /// - /// Quantize an image and return the resulting outpuTColor pixels. + /// Quantize an image and return the resulting output pixels. /// /// The image to quantize. /// The maximum number of colors to return. diff --git a/src/ImageProcessorCore/Quantizers/Octree/OctreeQuantizer.cs b/src/ImageProcessorCore/Quantizers/Octree/OctreeQuantizer.cs index 522e07151..7e872bed1 100644 --- a/src/ImageProcessorCore/Quantizers/Octree/OctreeQuantizer.cs +++ b/src/ImageProcessorCore/Quantizers/Octree/OctreeQuantizer.cs @@ -74,9 +74,7 @@ namespace ImageProcessorCore.Quantizers /// /// Override this to process the pixel in the second pass of the algorithm /// - /// - /// The pixel to quantize - /// + /// The pixel to quantize /// /// The quantized value /// @@ -193,7 +191,7 @@ namespace ImageProcessorCore.Quantizers /// Add a given color value to the Octree /// /// - /// The containing color information to add. + /// The containing color information to add. /// public void AddColor(TColor pixel) { @@ -224,11 +222,9 @@ namespace ImageProcessorCore.Quantizers /// /// Convert the nodes in the Octree to a palette with a maximum of colorCount colors /// - /// - /// The maximum number of colors - /// + /// The maximum number of colors /// - /// An with the palletized colors + /// An with the palletized colors /// public List Palletize(int colorCount) { @@ -249,9 +245,7 @@ namespace ImageProcessorCore.Quantizers /// /// Get the palette index for the passed color /// - /// - /// The containing the pixel data. - /// + /// The containing the pixel data. /// /// The index of the given structure. /// @@ -449,12 +443,8 @@ namespace ImageProcessorCore.Quantizers /// /// Traverse the tree, building up the color palette /// - /// - /// The palette - /// - /// - /// The current palette index - /// + /// The palette + /// The current palette index public void ConstructPalette(List palette, ref int index) { if (this.leaf) @@ -487,12 +477,8 @@ namespace ImageProcessorCore.Quantizers /// /// Return the palette index for the passed color /// - /// - /// The representing the pixel. - /// - /// - /// The level. - /// + /// The representing the pixel. + /// The level. /// /// The representing the index of the pixel in the palette. /// diff --git a/src/ImageProcessorCore/Quantizers/Octree/Quantizer.cs b/src/ImageProcessorCore/Quantizers/Octree/Quantizer.cs index 7bda2d4ab..a5d933d4e 100644 --- a/src/ImageProcessorCore/Quantizers/Octree/Quantizer.cs +++ b/src/ImageProcessorCore/Quantizers/Octree/Quantizer.cs @@ -11,6 +11,8 @@ namespace ImageProcessorCore.Quantizers /// /// Encapsulates methods to calculate the color palette of an image. /// + /// The pixel format. + /// The packed format. uint, long, float. public abstract class Quantizer : IQuantizer where TColor : IPackedVector where TPacked : struct @@ -98,10 +100,10 @@ namespace ImageProcessorCore.Quantizers /// Execute a second pass through the bitmap /// /// The source image. - /// The outpuTColor pixel array + /// The output pixel array /// The width in pixels of the image /// The height in pixels of the image - protected virtual void SecondPass(PixelAccessor source, byte[] output, int width, int height) + protected virtual void SecondPass(PixelAccessor source, byte[] output, int width, int height) { Parallel.For( 0, diff --git a/src/ImageProcessorCore/Quantizers/Quantize.cs b/src/ImageProcessorCore/Quantizers/Quantize.cs index ea0102d59..c6b72430c 100644 --- a/src/ImageProcessorCore/Quantizers/Quantize.cs +++ b/src/ImageProcessorCore/Quantizers/Quantize.cs @@ -3,10 +3,10 @@ // Licensed under the Apache License, Version 2.0. // -using ImageProcessorCore.Quantizers; - namespace ImageProcessorCore { + using ImageProcessorCore.Quantizers; + /// /// Extension methods for the type. /// diff --git a/src/ImageProcessorCore/Quantizers/QuantizedImage.cs b/src/ImageProcessorCore/Quantizers/QuantizedImage.cs index f95483f37..84ebcadfe 100644 --- a/src/ImageProcessorCore/Quantizers/QuantizedImage.cs +++ b/src/ImageProcessorCore/Quantizers/QuantizedImage.cs @@ -14,8 +14,8 @@ namespace ImageProcessorCore.Quantizers /// The pixel format. /// The packed format. uint, long, float. public class QuantizedImage - where TColor : IPackedVector - where TPacked : struct + where TColor : IPackedVector + where TPacked : struct { /// /// Initializes a new instance of the class. diff --git a/src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs b/src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs index a1f6b8f3c..5a9aefcb2 100644 --- a/src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs +++ b/src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs @@ -102,7 +102,7 @@ namespace ImageProcessorCore.Quantizers private readonly byte[] tag; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public WuQuantizer() { diff --git a/src/ImageProcessorCore/Samplers/AutoOrient.cs b/src/ImageProcessorCore/Samplers/AutoOrient.cs index 33f7902c2..a0dac5d67 100644 --- a/src/ImageProcessorCore/Samplers/AutoOrient.cs +++ b/src/ImageProcessorCore/Samplers/AutoOrient.cs @@ -17,7 +17,7 @@ namespace ImageProcessorCore /// /// The pixel format. /// The packed format. uint, long, float. - /// The image to crop. + /// The image to auto rotate. /// The public static Image AutoOrient(this Image source, ProgressEventHandler progressHandler = null) where TColor : IPackedVector @@ -27,11 +27,6 @@ namespace ImageProcessorCore switch (orientation) { - case Orientation.Unknown: - case Orientation.TopLeft: - default: - return source; - case Orientation.TopRight: return source.Flip(FlipType.Horizontal, progressHandler); @@ -42,23 +37,33 @@ namespace ImageProcessorCore return source.Flip(FlipType.Vertical, progressHandler); case Orientation.LeftTop: - return source - .Rotate(RotateType.Rotate90, progressHandler) - .Flip(FlipType.Horizontal, progressHandler); + return source.Rotate(RotateType.Rotate90, progressHandler) + .Flip(FlipType.Horizontal, progressHandler); case Orientation.RightTop: return source.Rotate(RotateType.Rotate90, progressHandler); case Orientation.RightBottom: - return source - .Flip(FlipType.Vertical, progressHandler) - .Rotate(RotateType.Rotate270, progressHandler); + return source.Flip(FlipType.Vertical, progressHandler) + .Rotate(RotateType.Rotate270, progressHandler); case Orientation.LeftBottom: return source.Rotate(RotateType.Rotate270, progressHandler); + + case Orientation.Unknown: + case Orientation.TopLeft: + default: + return source; } } + /// + /// Returns the current EXIF orientation + /// + /// The pixel format. + /// The packed format. uint, long, float. + /// The image to auto rotate. + /// The private static Orientation GetExifOrientation(Image source) where TColor : IPackedVector where TPacked : struct @@ -81,4 +86,4 @@ namespace ImageProcessorCore return orientation; } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Samplers/Options/ResizeHelper.cs b/src/ImageProcessorCore/Samplers/Options/ResizeHelper.cs index eab845cff..82a98c3c3 100644 --- a/src/ImageProcessorCore/Samplers/Options/ResizeHelper.cs +++ b/src/ImageProcessorCore/Samplers/Options/ResizeHelper.cs @@ -17,7 +17,8 @@ namespace ImageProcessorCore /// /// Calculates the target location and bounds to perform the resize operation against. /// - /// The type of pixels contained within the image. + /// The pixel format. + /// The packed format. uint, long, float. /// The source image. /// The resize options. /// @@ -49,7 +50,8 @@ namespace ImageProcessorCore /// /// Calculates the target rectangle for crop mode. /// - /// The type of pixels contained within the image. + /// The pixel format. + /// The packed format. uint, long, float. /// The source image. /// The resize options. /// @@ -169,7 +171,8 @@ namespace ImageProcessorCore /// /// Calculates the target rectangle for pad mode. /// - /// The type of pixels contained within the image. + /// The pixel format. + /// The packed format. uint, long, float. /// The source image. /// The resize options. /// @@ -251,7 +254,8 @@ namespace ImageProcessorCore /// /// Calculates the target rectangle for box pad mode. /// - /// The type of pixels contained within the image. + /// The pixel format. + /// The packed format. uint, long, float. /// The source image. /// The resize options. /// @@ -339,7 +343,8 @@ namespace ImageProcessorCore /// /// Calculates the target rectangle for max mode. /// - /// The type of pixels contained within the image. + /// The pixel format. + /// The packed format. uint, long, float. /// The source image. /// The resize options. /// @@ -381,7 +386,8 @@ namespace ImageProcessorCore /// /// Calculates the target rectangle for min mode. /// - /// The type of pixels contained within the image. + /// The pixel format. + /// The packed format. uint, long, float. /// The source image. /// The resize options. /// diff --git a/src/ImageProcessorCore/Samplers/Processors/EntropyCropProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/EntropyCropProcessor.cs index f20b7bce1..1f858631d 100644 --- a/src/ImageProcessorCore/Samplers/Processors/EntropyCropProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/EntropyCropProcessor.cs @@ -27,7 +27,7 @@ namespace ImageProcessorCore.Processors /// Initializes a new instance of the class. /// /// The threshold to split the image. Must be between 0 and 1. - /// + /// /// is less than 0 or is greater than 1. /// public EntropyCropProcessor(float threshold) @@ -55,7 +55,7 @@ namespace ImageProcessorCore.Processors // Search for the first white pixels Rectangle rectangle = ImageMaths.GetFilteredBoundingRectangle(temp, 0); - // Reset the targeTColor pixel to the correct size. + // Reset the target pixel to the correct size. target.SetPixels(rectangle.Width, rectangle.Height, new TColor[rectangle.Width * rectangle.Height]); this.cropRectangle = rectangle; } diff --git a/src/ImageProcessorCore/Samplers/Processors/ImageSampler.cs b/src/ImageProcessorCore/Samplers/Processors/ImageSampler.cs index c1d4d5c70..1256897db 100644 --- a/src/ImageProcessorCore/Samplers/Processors/ImageSampler.cs +++ b/src/ImageProcessorCore/Samplers/Processors/ImageSampler.cs @@ -16,4 +16,4 @@ namespace ImageProcessorCore.Processors where TPacked : struct { } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Samplers/Processors/RotateProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/RotateProcessor.cs index df3eea635..be005f252 100644 --- a/src/ImageProcessorCore/Samplers/Processors/RotateProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/RotateProcessor.cs @@ -2,6 +2,9 @@ // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // + +using System; + namespace ImageProcessorCore.Processors { using System.Numerics; @@ -34,7 +37,9 @@ namespace ImageProcessorCore.Processors /// protected override void OnApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle) { - if (Angle == 0 || Angle == 90 || Angle == 180 || Angle == 270) + const float Epsilon = .0001F; + + if (Math.Abs(Angle) < Epsilon || Math.Abs(Angle - 90) < Epsilon || Math.Abs(Angle - 180) < Epsilon || Math.Abs(Angle - 270) < Epsilon) { return; } @@ -89,25 +94,26 @@ namespace ImageProcessorCore.Processors /// private bool OptimizedApply(ImageBase target, ImageBase source) { - if (Angle == 0) + const float Epsilon = .0001F; + if (Math.Abs(Angle) < Epsilon) { target.ClonePixels(target.Width, target.Height, source.Pixels); return true; } - if (Angle == 90) + if (Math.Abs(Angle - 90) < Epsilon) { this.Rotate90(target, source); return true; } - if (Angle == 180) + if (Math.Abs(Angle - 180) < Epsilon) { this.Rotate180(target, source); return true; } - if (Angle == 270) + if (Math.Abs(Angle - 270) < Epsilon) { this.Rotate270(target, source); return true; diff --git a/src/ImageProcessorCore/Samplers/Resamplers/NearestNeighborResampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/NearestNeighborResampler.cs index bcd9a58b1..58b6a9d58 100644 --- a/src/ImageProcessorCore/Samplers/Resamplers/NearestNeighborResampler.cs +++ b/src/ImageProcessorCore/Samplers/Resamplers/NearestNeighborResampler.cs @@ -7,7 +7,7 @@ namespace ImageProcessorCore { /// /// The function implements the nearest neighbour algorithm. This uses an unscaled filter - /// which will select the closesTColor pixel to the new pixels position. + /// which will select the closest pixel to the new pixels position. /// public class NearestNeighborResampler : IResampler { diff --git a/src/ImageProcessorCore/Samplers/RotateFlip.cs b/src/ImageProcessorCore/Samplers/RotateFlip.cs index 0cd406038..8bba64ca5 100644 --- a/src/ImageProcessorCore/Samplers/RotateFlip.cs +++ b/src/ImageProcessorCore/Samplers/RotateFlip.cs @@ -25,9 +25,7 @@ namespace ImageProcessorCore where TColor : IPackedVector where TPacked : struct { - return source - .Rotate(rotateType, progressHandler) - .Flip(flipType, progressHandler); + return source.Rotate(rotateType, progressHandler).Flip(flipType, progressHandler); } } }