diff --git a/src/ImageProcessorCore/Filters/Alpha.cs b/src/ImageProcessorCore/Filters/Alpha.cs index 1d678370d..4cbb6342f 100644 --- a/src/ImageProcessorCore/Filters/Alpha.cs +++ b/src/ImageProcessorCore/Filters/Alpha.cs @@ -19,13 +19,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image this method extends. /// The new opacity of the image. Must be between 0 and 100. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Alpha(this Image source, int percent, ProgressEventHandler progressHandler = null) + public static Image Alpha(this Image source, int percent) where TColor : IPackedVector where TPacked : struct { - return Alpha(source, percent, source.Bounds, progressHandler); + return Alpha(source, percent, source.Bounds); } /// @@ -38,23 +37,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Alpha(this Image source, int percent, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Alpha(this Image source, int percent, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - AlphaProcessor processor = new AlphaProcessor(percent); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new AlphaProcessor(percent)); } } } diff --git a/src/ImageProcessorCore/Filters/BackgroundColor.cs b/src/ImageProcessorCore/Filters/BackgroundColor.cs index f059700e1..5a1b39d5f 100644 --- a/src/ImageProcessorCore/Filters/BackgroundColor.cs +++ b/src/ImageProcessorCore/Filters/BackgroundColor.cs @@ -19,23 +19,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image this method extends. /// The color to set as the background. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image BackgroundColor(this Image source, TColor color, ProgressEventHandler progressHandler = null) + public static Image BackgroundColor(this Image source, TColor color) where TColor : IPackedVector where TPacked : struct { - BackgroundColorProcessor processor = new BackgroundColorProcessor(color); - processor.OnProgress += progressHandler; - - try - { - return source.Process(source.Bounds, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(source.Bounds, new BackgroundColorProcessor(color)); } } } diff --git a/src/ImageProcessorCore/Filters/BinaryThreshold.cs b/src/ImageProcessorCore/Filters/BinaryThreshold.cs index b57d63c4f..40538fb2a 100644 --- a/src/ImageProcessorCore/Filters/BinaryThreshold.cs +++ b/src/ImageProcessorCore/Filters/BinaryThreshold.cs @@ -19,13 +19,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image this method extends. /// The threshold to apply binerization of the image. Must be between 0 and 1. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image BinaryThreshold(this Image source, float threshold, ProgressEventHandler progressHandler = null) + public static Image BinaryThreshold(this Image source, float threshold) where TColor : IPackedVector where TPacked : struct { - return BinaryThreshold(source, threshold, source.Bounds, progressHandler); + return BinaryThreshold(source, threshold, source.Bounds); } /// @@ -38,23 +37,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image BinaryThreshold(this Image source, float threshold, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image BinaryThreshold(this Image source, float threshold, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - BinaryThresholdProcessor processor = new BinaryThresholdProcessor(threshold); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new BinaryThresholdProcessor(threshold)); } } } diff --git a/src/ImageProcessorCore/Filters/BlackWhite.cs b/src/ImageProcessorCore/Filters/BlackWhite.cs index 209387308..6cd0e86cd 100644 --- a/src/ImageProcessorCore/Filters/BlackWhite.cs +++ b/src/ImageProcessorCore/Filters/BlackWhite.cs @@ -18,13 +18,12 @@ namespace ImageProcessorCore /// 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 . - public static Image BlackWhite(this Image source, ProgressEventHandler progressHandler = null) + public static Image BlackWhite(this Image source) where TColor : IPackedVector where TPacked : struct { - return BlackWhite(source, source.Bounds, progressHandler); + return BlackWhite(source, source.Bounds); } /// @@ -36,23 +35,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image BlackWhite(this Image source, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image BlackWhite(this Image source, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - BlackWhiteProcessor processor = new BlackWhiteProcessor(); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new BlackWhiteProcessor()); } } } diff --git a/src/ImageProcessorCore/Filters/Blend.cs b/src/ImageProcessorCore/Filters/Blend.cs index ea7af5f19..6161bf164 100644 --- a/src/ImageProcessorCore/Filters/Blend.cs +++ b/src/ImageProcessorCore/Filters/Blend.cs @@ -20,13 +20,12 @@ namespace ImageProcessorCore /// 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 . - public static Image Blend(this Image source, ImageBase image, int percent = 50, ProgressEventHandler progressHandler = null) + public static Image Blend(this Image source, ImageBase image, int percent = 50) where TColor : IPackedVector where TPacked : struct { - return Blend(source, image, percent, source.Bounds, progressHandler); + return Blend(source, image, percent, source.Bounds); } /// @@ -40,23 +39,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Blend(this Image source, ImageBase image, int percent, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Blend(this Image source, ImageBase image, int percent, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - BlendProcessor processor = new BlendProcessor(image, percent); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new BlendProcessor(image, percent)); } } } \ No newline at end of file diff --git a/src/ImageProcessorCore/Filters/Brightness.cs b/src/ImageProcessorCore/Filters/Brightness.cs index f7d1a6263..47b59067e 100644 --- a/src/ImageProcessorCore/Filters/Brightness.cs +++ b/src/ImageProcessorCore/Filters/Brightness.cs @@ -19,13 +19,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image this method extends. /// The new brightness of the image. Must be between -100 and 100. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Brightness(this Image source, int amount, ProgressEventHandler progressHandler = null) + public static Image Brightness(this Image source, int amount) where TColor : IPackedVector where TPacked : struct { - return Brightness(source, amount, source.Bounds, progressHandler); + return Brightness(source, amount, source.Bounds); } /// @@ -38,23 +37,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Brightness(this Image source, int amount, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Brightness(this Image source, int amount, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - BrightnessProcessor processor = new BrightnessProcessor(amount); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new BrightnessProcessor(amount)); } } } diff --git a/src/ImageProcessorCore/Filters/ColorBlindness.cs b/src/ImageProcessorCore/Filters/ColorBlindness.cs index 5a29a63de..cb7759b46 100644 --- a/src/ImageProcessorCore/Filters/ColorBlindness.cs +++ b/src/ImageProcessorCore/Filters/ColorBlindness.cs @@ -19,13 +19,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image this method extends. /// The type of color blindness simulator to apply. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image ColorBlindness(this Image source, ColorBlindness colorBlindness, ProgressEventHandler progressHandler = null) + public static Image ColorBlindness(this Image source, ColorBlindness colorBlindness) where TColor : IPackedVector where TPacked : struct { - return ColorBlindness(source, colorBlindness, source.Bounds, progressHandler); + return ColorBlindness(source, colorBlindness, source.Bounds); } /// @@ -38,9 +37,8 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image ColorBlindness(this Image source, ColorBlindness colorBlindness, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image ColorBlindness(this Image source, ColorBlindness colorBlindness, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { @@ -81,16 +79,7 @@ namespace ImageProcessorCore break; } - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, processor); } } } diff --git a/src/ImageProcessorCore/Filters/Contrast.cs b/src/ImageProcessorCore/Filters/Contrast.cs index 364fc34b4..1f4d04746 100644 --- a/src/ImageProcessorCore/Filters/Contrast.cs +++ b/src/ImageProcessorCore/Filters/Contrast.cs @@ -19,13 +19,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image this method extends. /// The new contrast of the image. Must be between -100 and 100. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Contrast(this Image source, int amount, ProgressEventHandler progressHandler = null) + public static Image Contrast(this Image source, int amount) where TColor : IPackedVector where TPacked : struct { - return Contrast(source, amount, source.Bounds, progressHandler); + return Contrast(source, amount, source.Bounds); } /// @@ -38,23 +37,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Contrast(this Image source, int amount, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Contrast(this Image source, int amount, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - ContrastProcessor processor = new ContrastProcessor(amount); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new ContrastProcessor(amount)); } } } diff --git a/src/ImageProcessorCore/Filters/Glow.cs b/src/ImageProcessorCore/Filters/Glow.cs index 0d5b18fb3..1e973bbf9 100644 --- a/src/ImageProcessorCore/Filters/Glow.cs +++ b/src/ImageProcessorCore/Filters/Glow.cs @@ -18,13 +18,12 @@ namespace ImageProcessorCore /// 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 . - public static Image Glow(this Image source, ProgressEventHandler progressHandler = null) + public static Image Glow(this Image source) where TColor : IPackedVector where TPacked : struct { - return Glow(source, default(TColor), source.Bounds.Width * .5F, source.Bounds, progressHandler); + return Glow(source, default(TColor), source.Bounds.Width * .5F, source.Bounds); } /// @@ -34,13 +33,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image this method extends. /// The color to set as the glow. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Glow(this Image source, TColor color, ProgressEventHandler progressHandler = null) + public static Image Glow(this Image source, TColor color) where TColor : IPackedVector where TPacked : struct { - return Glow(source, color, source.Bounds.Width * .5F, source.Bounds, progressHandler); + return Glow(source, color, source.Bounds.Width * .5F, source.Bounds); } /// @@ -50,13 +48,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image this method extends. /// The the radius. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Glow(this Image source, float radius, ProgressEventHandler progressHandler = null) + public static Image Glow(this Image source, float radius) where TColor : IPackedVector where TPacked : struct { - return Glow(source, default(TColor), radius, source.Bounds, progressHandler); + return Glow(source, default(TColor), radius, source.Bounds); } /// @@ -68,13 +65,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Glow(this Image source, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Glow(this Image source, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - return Glow(source, default(TColor), 0, rectangle, progressHandler); + return Glow(source, default(TColor), 0, rectangle); } /// @@ -88,9 +84,8 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Glow(this Image source, TColor color, float radius, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Glow(this Image source, TColor color, float radius, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { @@ -101,16 +96,7 @@ namespace ImageProcessorCore processor.GlowColor = color; } - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, processor); } } } diff --git a/src/ImageProcessorCore/Filters/Grayscale.cs b/src/ImageProcessorCore/Filters/Grayscale.cs index f9fae3671..f496c3da8 100644 --- a/src/ImageProcessorCore/Filters/Grayscale.cs +++ b/src/ImageProcessorCore/Filters/Grayscale.cs @@ -19,13 +19,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image this method extends. /// The formula to apply to perform the operation. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Grayscale(this Image source, GrayscaleMode mode = GrayscaleMode.Bt709, ProgressEventHandler progressHandler = null) + public static Image Grayscale(this Image source, GrayscaleMode mode = GrayscaleMode.Bt709) where TColor : IPackedVector where TPacked : struct { - return Grayscale(source, source.Bounds, mode, progressHandler); + return Grayscale(source, source.Bounds, mode); } /// @@ -38,9 +37,8 @@ namespace ImageProcessorCore /// The structure that specifies the portion of the image object to alter. /// /// The formula to apply to perform the operation. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Grayscale(this Image source, Rectangle rectangle, GrayscaleMode mode = GrayscaleMode.Bt709, ProgressEventHandler progressHandler = null) + public static Image Grayscale(this Image source, Rectangle rectangle, GrayscaleMode mode = GrayscaleMode.Bt709) where TColor : IPackedVector where TPacked : struct { @@ -48,16 +46,7 @@ namespace ImageProcessorCore ? (IImageFilter)new GrayscaleBt709Processor() : new GrayscaleBt601Processor(); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, processor); } } } diff --git a/src/ImageProcessorCore/Filters/Hue.cs b/src/ImageProcessorCore/Filters/Hue.cs index d4c86ac3a..18e3a8a1a 100644 --- a/src/ImageProcessorCore/Filters/Hue.cs +++ b/src/ImageProcessorCore/Filters/Hue.cs @@ -19,13 +19,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image this method extends. /// The angle in degrees to adjust the image. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Hue(this Image source, float degrees, ProgressEventHandler progressHandler = null) + public static Image Hue(this Image source, float degrees) where TColor : IPackedVector where TPacked : struct { - return Hue(source, degrees, source.Bounds, progressHandler); + return Hue(source, degrees, source.Bounds); } /// @@ -38,23 +37,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Hue(this Image source, float degrees, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Hue(this Image source, float degrees, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - HueProcessor processor = new HueProcessor(degrees); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new HueProcessor(degrees)); } } } diff --git a/src/ImageProcessorCore/Filters/Invert.cs b/src/ImageProcessorCore/Filters/Invert.cs index ed7124662..b2132da6f 100644 --- a/src/ImageProcessorCore/Filters/Invert.cs +++ b/src/ImageProcessorCore/Filters/Invert.cs @@ -18,13 +18,12 @@ namespace ImageProcessorCore /// 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 . - public static Image Invert(this Image source, ProgressEventHandler progressHandler = null) + public static Image Invert(this Image source) where TColor : IPackedVector where TPacked : struct { - return Invert(source, source.Bounds, progressHandler); + return Invert(source, source.Bounds); } /// @@ -36,23 +35,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Invert(this Image source, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Invert(this Image source, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - InvertProcessor processor = new InvertProcessor(); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new InvertProcessor()); } } } diff --git a/src/ImageProcessorCore/Filters/Kodachrome.cs b/src/ImageProcessorCore/Filters/Kodachrome.cs index 7310703b0..32eb6dd9d 100644 --- a/src/ImageProcessorCore/Filters/Kodachrome.cs +++ b/src/ImageProcessorCore/Filters/Kodachrome.cs @@ -10,8 +10,6 @@ namespace ImageProcessorCore /// /// Extension methods for the type. /// - /// The pixel format. - /// The packed format. uint, long, float. public static partial class ImageExtensions { /// @@ -20,13 +18,12 @@ namespace ImageProcessorCore /// 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 . - public static Image Kodachrome(this Image source, ProgressEventHandler progressHandler = null) + public static Image Kodachrome(this Image source) where TColor : IPackedVector where TPacked : struct { - return Kodachrome(source, source.Bounds, progressHandler); + return Kodachrome(source, source.Bounds); } /// @@ -38,23 +35,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Kodachrome(this Image source, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Kodachrome(this Image source, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - KodachromeProcessor processor = new KodachromeProcessor(); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new KodachromeProcessor()); } } } diff --git a/src/ImageProcessorCore/Filters/Lomograph.cs b/src/ImageProcessorCore/Filters/Lomograph.cs index fa5f094b4..dc5443bd2 100644 --- a/src/ImageProcessorCore/Filters/Lomograph.cs +++ b/src/ImageProcessorCore/Filters/Lomograph.cs @@ -18,13 +18,12 @@ namespace ImageProcessorCore /// 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 . - public static Image Lomograph(this Image source, ProgressEventHandler progressHandler = null) + public static Image Lomograph(this Image source) where TColor : IPackedVector where TPacked : struct { - return Lomograph(source, source.Bounds, progressHandler); + return Lomograph(source, source.Bounds); } /// @@ -36,23 +35,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Lomograph(this Image source, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Lomograph(this Image source, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - LomographProcessor processor = new LomographProcessor(); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new LomographProcessor()); } } } diff --git a/src/ImageProcessorCore/Filters/Polaroid.cs b/src/ImageProcessorCore/Filters/Polaroid.cs index 99dfb0a78..0801f85b7 100644 --- a/src/ImageProcessorCore/Filters/Polaroid.cs +++ b/src/ImageProcessorCore/Filters/Polaroid.cs @@ -18,13 +18,12 @@ namespace ImageProcessorCore /// 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 . - public static Image Polaroid(this Image source, ProgressEventHandler progressHandler = null) + public static Image Polaroid(this Image source) where TColor : IPackedVector where TPacked : struct { - return Polaroid(source, source.Bounds, progressHandler); + return Polaroid(source, source.Bounds); } /// @@ -36,23 +35,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Polaroid(this Image source, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Polaroid(this Image source, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - PolaroidProcessor processor = new PolaroidProcessor(); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new PolaroidProcessor()); } } } diff --git a/src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs b/src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs index 8810bd0ec..12b731ecd 100644 --- a/src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs @@ -78,8 +78,6 @@ namespace ImageProcessorCore.Processors packed.PackFromVector4(sourcePixels[offsetX, offsetY].ToVector4() * alphaVector); sourcePixels[offsetX, offsetY] = packed; } - - this.OnRowProcessed(); }); } } diff --git a/src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs b/src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs index 6654a961c..5039d6a93 100644 --- a/src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs @@ -12,6 +12,8 @@ namespace ImageProcessorCore.Processors /// /// Sets the background color of the image. /// + /// The pixel format. + /// The packed format. uint, long, float. public class BackgroundColorProcessor : ImageFilter where TColor : IPackedVector where TPacked : struct @@ -89,8 +91,6 @@ namespace ImageProcessorCore.Processors packed.PackFromVector4(color); sourcePixels[offsetX, offsetY] = packed; } - - this.OnRowProcessed(); }); } } diff --git a/src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs b/src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs index 9dd9debd2..7111963ea 100644 --- a/src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs @@ -104,10 +104,8 @@ namespace ImageProcessorCore.Processors // Any channel will do since it's Grayscale. sourcePixels[offsetX, offsetY] = color.ToVector4().X >= threshold ? upper : lower; } - - this.OnRowProcessed(); }); } } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs b/src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs index e645871e2..b29ef4e42 100644 --- a/src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs @@ -99,10 +99,8 @@ namespace ImageProcessorCore.Processors packed.PackFromVector4(color); sourcePixels[offsetX, offsetY] = packed; } - - this.OnRowProcessed(); }); } } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs b/src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs index 0e823e712..04d796fca 100644 --- a/src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs @@ -83,8 +83,6 @@ namespace ImageProcessorCore.Processors sourcePixels[offsetX, offsetY] = packed; } - - this.OnRowProcessed(); }); } } diff --git a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/ColorMatrixFilter.cs b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/ColorMatrixFilter.cs index ad41df7ed..7bbc5c0a8 100644 --- a/src/ImageProcessorCore/Filters/Processors/ColorMatrix/ColorMatrixFilter.cs +++ b/src/ImageProcessorCore/Filters/Processors/ColorMatrix/ColorMatrixFilter.cs @@ -64,8 +64,6 @@ namespace ImageProcessorCore.Processors int offsetX = x - startX; sourcePixels[offsetX, offsetY] = this.ApplyMatrix(sourcePixels[offsetX, offsetY], matrix, compand); } - - this.OnRowProcessed(); }); } } diff --git a/src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs b/src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs index ca2c4a3d0..3e37d2722 100644 --- a/src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs @@ -83,8 +83,6 @@ namespace ImageProcessorCore.Processors packed.PackFromVector4(vector.Compress()); sourcePixels[offsetX, offsetY] = packed; } - - this.OnRowProcessed(); }); } } diff --git a/src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs b/src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs index 5186a8bd0..01eb9cd8e 100644 --- a/src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs @@ -87,8 +87,6 @@ namespace ImageProcessorCore.Processors sourcePixels[offsetX, offsetY] = packed; } } - - this.OnRowProcessed(); }); } } diff --git a/src/ImageProcessorCore/Filters/Processors/ImageFilter.cs b/src/ImageProcessorCore/Filters/Processors/ImageFilter.cs index 6dcbb5a3d..1ac88ff52 100644 --- a/src/ImageProcessorCore/Filters/Processors/ImageFilter.cs +++ b/src/ImageProcessorCore/Filters/Processors/ImageFilter.cs @@ -1,4 +1,9 @@ -namespace ImageProcessorCore.Processors +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageProcessorCore.Processors { using System; @@ -18,9 +23,6 @@ { this.OnApply(source, sourceRectangle); - this.NumRowsProcessed = 0; - this.TotalRows = sourceRectangle.Height; - this.Apply(source, sourceRectangle, sourceRectangle.Y, sourceRectangle.Bottom); this.AfterApply(source, sourceRectangle); diff --git a/src/ImageProcessorCore/Filters/Processors/InvertProcessor.cs b/src/ImageProcessorCore/Filters/Processors/InvertProcessor.cs index 5c77eb5ca..9fe61d03b 100644 --- a/src/ImageProcessorCore/Filters/Processors/InvertProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/InvertProcessor.cs @@ -61,8 +61,6 @@ namespace ImageProcessorCore.Processors packed.PackFromVector4(new Vector4(vector, color.W)); sourcePixels[offsetX, offsetY] = packed; } - - this.OnRowProcessed(); }); } } diff --git a/src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs b/src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs index 56a85111e..f725e75c6 100644 --- a/src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs +++ b/src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs @@ -89,8 +89,6 @@ namespace ImageProcessorCore.Processors packed.PackFromVector4(Vector4.Lerp(vignetteColor.ToVector4(), sourceColor, 1 - (.9F * (distance / maxDistance)))); sourcePixels[offsetX, offsetY] = packed; } - - this.OnRowProcessed(); }); } } diff --git a/src/ImageProcessorCore/Filters/Saturation.cs b/src/ImageProcessorCore/Filters/Saturation.cs index 6e2367d80..6158be7fc 100644 --- a/src/ImageProcessorCore/Filters/Saturation.cs +++ b/src/ImageProcessorCore/Filters/Saturation.cs @@ -19,13 +19,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image this method extends. /// The new saturation of the image. Must be between -100 and 100. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Saturation(this Image source, int amount, ProgressEventHandler progressHandler = null) + public static Image Saturation(this Image source, int amount) where TColor : IPackedVector where TPacked : struct { - return Saturation(source, amount, source.Bounds, progressHandler); + return Saturation(source, amount, source.Bounds); } /// @@ -38,23 +37,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Saturation(this Image source, int amount, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Saturation(this Image source, int amount, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - SaturationProcessor processor = new SaturationProcessor(amount); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new SaturationProcessor(amount)); } } } diff --git a/src/ImageProcessorCore/Filters/Sepia.cs b/src/ImageProcessorCore/Filters/Sepia.cs index 126c0d92a..5102f0772 100644 --- a/src/ImageProcessorCore/Filters/Sepia.cs +++ b/src/ImageProcessorCore/Filters/Sepia.cs @@ -18,13 +18,12 @@ namespace ImageProcessorCore /// 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 . - public static Image Sepia(this Image source, ProgressEventHandler progressHandler = null) + public static Image Sepia(this Image source) where TColor : IPackedVector where TPacked : struct { - return Sepia(source, source.Bounds, progressHandler); + return Sepia(source, source.Bounds); } /// @@ -36,23 +35,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Sepia(this Image source, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Sepia(this Image source, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - SepiaProcessor processor = new SepiaProcessor(); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new SepiaProcessor()); } } } \ No newline at end of file diff --git a/src/ImageProcessorCore/Filters/Vignette.cs b/src/ImageProcessorCore/Filters/Vignette.cs index f884db613..bb0f058e9 100644 --- a/src/ImageProcessorCore/Filters/Vignette.cs +++ b/src/ImageProcessorCore/Filters/Vignette.cs @@ -18,13 +18,12 @@ namespace ImageProcessorCore /// 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 . - public static Image Vignette(this Image source, ProgressEventHandler progressHandler = null) + public static Image Vignette(this Image source) where TColor : IPackedVector where TPacked : struct { - return Vignette(source, default(TColor), source.Bounds.Width * .5F, source.Bounds.Height * .5F, source.Bounds, progressHandler); + return Vignette(source, default(TColor), source.Bounds.Width * .5F, source.Bounds.Height * .5F, source.Bounds); } /// @@ -34,13 +33,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image this method extends. /// The color to set as the vignette. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Vignette(this Image source, TColor color, ProgressEventHandler progressHandler = null) + public static Image Vignette(this Image source, TColor color) where TColor : IPackedVector where TPacked : struct { - return Vignette(source, color, source.Bounds.Width * .5F, source.Bounds.Height * .5F, source.Bounds, progressHandler); + return Vignette(source, color, source.Bounds.Width * .5F, source.Bounds.Height * .5F, source.Bounds); } /// @@ -51,13 +49,12 @@ namespace ImageProcessorCore /// The image this method extends. /// The the x-radius. /// The the y-radius. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Vignette(this Image source, float radiusX, float radiusY, ProgressEventHandler progressHandler = null) + public static Image Vignette(this Image source, float radiusX, float radiusY) where TColor : IPackedVector where TPacked : struct { - return Vignette(source, default(TColor), radiusX, radiusY, source.Bounds, progressHandler); + return Vignette(source, default(TColor), radiusX, radiusY, source.Bounds); } /// @@ -69,13 +66,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Vignette(this Image source, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Vignette(this Image source, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - return Vignette(source, default(TColor), 0, 0, rectangle, progressHandler); + return Vignette(source, default(TColor), 0, 0, rectangle); } /// @@ -90,9 +86,8 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Vignette(this Image source, TColor color, float radiusX, float radiusY, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Vignette(this Image source, TColor color, float radiusX, float radiusY, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { @@ -103,16 +98,7 @@ namespace ImageProcessorCore processor.VignetteColor = color; } - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, processor); } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Image/IImageProcessor.cs b/src/ImageProcessorCore/Image/IImageProcessor.cs index c13f88a9a..060534a1b 100644 --- a/src/ImageProcessorCore/Image/IImageProcessor.cs +++ b/src/ImageProcessorCore/Image/IImageProcessor.cs @@ -7,27 +7,11 @@ namespace ImageProcessorCore.Processors { using System.Threading.Tasks; - /// - /// A delegate which is called as progress is made processing an image. - /// - /// The source of the event. - /// An object that contains the event data. - public delegate void ProgressEventHandler(object sender, ProgressEventArgs e); - /// /// Encapsulates methods to alter the pixels of an image. /// public interface IImageProcessor { - /// - /// Event fires when each row of the source image has been processed. - /// - /// - /// This event may be called from threads other than the client thread, and from multiple threads simultaneously. - /// Individual row notifications may arrived out of order. - /// - event ProgressEventHandler OnProgress; - /// /// Gets or sets the parallel options for processing tasks in parallel. /// diff --git a/src/ImageProcessorCore/ImageProcessor.cs b/src/ImageProcessorCore/ImageProcessor.cs index 15d4208be..5ebec4304 100644 --- a/src/ImageProcessorCore/ImageProcessor.cs +++ b/src/ImageProcessorCore/ImageProcessor.cs @@ -5,8 +5,6 @@ namespace ImageProcessorCore.Processors { - using System.Collections.Generic; - using System.Threading; using System.Threading.Tasks; /// @@ -18,14 +16,6 @@ namespace ImageProcessorCore.Processors where TColor : IPackedVector where TPacked : struct { - /// - /// Gets or sets the number of rows processed by a derived class. - /// - protected int NumRowsProcessed; - - /// - public event ProgressEventHandler OnProgress; - /// public virtual ParallelOptions ParallelOptions { get; set; } = Bootstrapper.Instance.ParallelOptions; @@ -36,25 +26,5 @@ namespace ImageProcessorCore.Processors /// Gets or sets the total number of rows that will be processed by a derived class. /// protected int TotalRows { get; set; } - - /// - /// Must be called by derived classes after processing a single row. - /// - protected void OnRowProcessed() - { - if (this.OnProgress != null) - { - int currThreadNumRows = Interlocked.Add(ref this.NumRowsProcessed, 1); - - // Multi-pass filters process multiple times more rows than totalRows, so update totalRows on the fly - if (currThreadNumRows > this.TotalRows) - { - this.TotalRows = currThreadNumRows; - } - - // Report progress. This may be on the client's thread, or on a Task library thread. - this.OnProgress(this, new ProgressEventArgs { RowsProcessed = currThreadNumRows, TotalRows = this.TotalRows }); - } - } } } \ No newline at end of file diff --git a/src/ImageProcessorCore/Samplers/AutoOrient.cs b/src/ImageProcessorCore/Samplers/AutoOrient.cs index a0dac5d67..26fe192d8 100644 --- a/src/ImageProcessorCore/Samplers/AutoOrient.cs +++ b/src/ImageProcessorCore/Samplers/AutoOrient.cs @@ -5,8 +5,6 @@ namespace ImageProcessorCore { - using Processors; - /// /// Extension methods for the type. /// @@ -19,7 +17,7 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image to auto rotate. /// The - public static Image AutoOrient(this Image source, ProgressEventHandler progressHandler = null) + public static Image AutoOrient(this Image source) where TColor : IPackedVector where TPacked : struct { @@ -28,27 +26,27 @@ namespace ImageProcessorCore switch (orientation) { case Orientation.TopRight: - return source.Flip(FlipType.Horizontal, progressHandler); + return source.Flip(FlipType.Horizontal); case Orientation.BottomRight: - return source.Rotate(RotateType.Rotate180, progressHandler); + return source.Rotate(RotateType.Rotate180); case Orientation.BottomLeft: - return source.Flip(FlipType.Vertical, progressHandler); + return source.Flip(FlipType.Vertical); case Orientation.LeftTop: - return source.Rotate(RotateType.Rotate90, progressHandler) - .Flip(FlipType.Horizontal, progressHandler); + return source.Rotate(RotateType.Rotate90) + .Flip(FlipType.Horizontal); case Orientation.RightTop: - return source.Rotate(RotateType.Rotate90, progressHandler); + return source.Rotate(RotateType.Rotate90); case Orientation.RightBottom: - return source.Flip(FlipType.Vertical, progressHandler) - .Rotate(RotateType.Rotate270, progressHandler); + return source.Flip(FlipType.Vertical) + .Rotate(RotateType.Rotate270); case Orientation.LeftBottom: - return source.Rotate(RotateType.Rotate270, progressHandler); + return source.Rotate(RotateType.Rotate270); case Orientation.Unknown: case Orientation.TopLeft: diff --git a/src/ImageProcessorCore/Samplers/BoxBlur.cs b/src/ImageProcessorCore/Samplers/BoxBlur.cs index f4a0ce238..53442d841 100644 --- a/src/ImageProcessorCore/Samplers/BoxBlur.cs +++ b/src/ImageProcessorCore/Samplers/BoxBlur.cs @@ -19,42 +19,30 @@ namespace ImageProcessorCore /// 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. /// The . - public static Image BoxBlur(this Image source, int radius = 7, ProgressEventHandler progressHandler = null) + public static Image BoxBlur(this Image source, int radius = 7) where TColor : IPackedVector where TPacked : struct { - return BoxBlur(source, radius, source.Bounds, progressHandler); + return BoxBlur(source, radius, source.Bounds); } /// /// Applies a box blur to the image. /// - /// The pixel format. + /// The pixel format. /// The packed format. long, float. /// The image this method extends. /// The 'radius' value representing the size of the area to sample. /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image BoxBlur(this Image source, int radius, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image BoxBlur(this Image source, int radius, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - BoxBlurProcessor processor = new BoxBlurProcessor(radius); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new BoxBlurProcessor(radius)); } } } diff --git a/src/ImageProcessorCore/Samplers/Crop.cs b/src/ImageProcessorCore/Samplers/Crop.cs index 01c7421a1..ccb07ee5c 100644 --- a/src/ImageProcessorCore/Samplers/Crop.cs +++ b/src/ImageProcessorCore/Samplers/Crop.cs @@ -20,13 +20,12 @@ namespace ImageProcessorCore /// The image to resize. /// The target image width. /// The target image height. - /// A delegate which is called as progress is made processing the image. /// The - public static Image Crop(this Image source, int width, int height, ProgressEventHandler progressHandler = null) + public static Image Crop(this Image source, int width, int height) where TColor : IPackedVector where TPacked : struct { - return Crop(source, width, height, source.Bounds, progressHandler); + return Crop(source, width, height, source.Bounds); } /// @@ -44,9 +43,8 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to draw. /// - /// A delegate which is called as progress is made processing the image. /// The - public static Image Crop(this Image source, int width, int height, Rectangle sourceRectangle, ProgressEventHandler progressHandler = null) + public static Image Crop(this Image source, int width, int height, Rectangle sourceRectangle) where TColor : IPackedVector where TPacked : struct { @@ -61,16 +59,7 @@ namespace ImageProcessorCore } CropProcessor processor = new CropProcessor(); - processor.OnProgress += progressHandler; - - try - { - return source.Process(width, height, sourceRectangle, new Rectangle(0, 0, width, height), processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(width, height, sourceRectangle, new Rectangle(0, 0, width, height), processor); } } } diff --git a/src/ImageProcessorCore/Samplers/DetectEdges.cs b/src/ImageProcessorCore/Samplers/DetectEdges.cs index 5281db031..3282b0bb3 100644 --- a/src/ImageProcessorCore/Samplers/DetectEdges.cs +++ b/src/ImageProcessorCore/Samplers/DetectEdges.cs @@ -19,13 +19,12 @@ namespace ImageProcessorCore /// 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 . - public static Image DetectEdges(this Image source, ProgressEventHandler progressHandler = null) + public static Image DetectEdges(this Image source) where TColor : IPackedVector where TPacked : struct { - return DetectEdges(source, source.Bounds, new SobelProcessor { Grayscale = true }, progressHandler); + return DetectEdges(source, source.Bounds, new SobelProcessor { Grayscale = true }); } /// @@ -38,13 +37,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image DetectEdges(this Image source, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image DetectEdges(this Image source, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - return DetectEdges(source, rectangle, new SobelProcessor { Grayscale = true }, progressHandler); + return DetectEdges(source, rectangle, new SobelProcessor { Grayscale = true }); } /// @@ -55,13 +53,12 @@ namespace ImageProcessorCore /// The image this method extends. /// The filter for detecting edges. /// Whether to convert the image to Grayscale first. Defaults to true. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image DetectEdges(this Image source, EdgeDetection filter, bool grayscale = true, ProgressEventHandler progressHandler = null) + public static Image DetectEdges(this Image source, EdgeDetection filter, bool grayscale = true) where TColor : IPackedVector where TPacked : struct { - return DetectEdges(source, filter, source.Bounds, grayscale, progressHandler); + return DetectEdges(source, filter, source.Bounds, grayscale); } /// @@ -75,9 +72,8 @@ namespace ImageProcessorCore /// The structure that specifies the portion of the image object to alter. /// /// Whether to convert the image to Grayscale first. Defaults to true. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image DetectEdges(this Image source, EdgeDetection filter, Rectangle rectangle, bool grayscale = true, ProgressEventHandler progressHandler = null) + public static Image DetectEdges(this Image source, EdgeDetection filter, Rectangle rectangle, bool grayscale = true) where TColor : IPackedVector where TPacked : struct { @@ -126,7 +122,7 @@ namespace ImageProcessorCore break; } - return DetectEdges(source, rectangle, processor, progressHandler); + return DetectEdges(source, rectangle, processor); } /// @@ -136,13 +132,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image this method extends. /// The filter for detecting edges. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image DetectEdges(this Image source, IEdgeDetectorFilter filter, ProgressEventHandler progressHandler = null) + public static Image DetectEdges(this Image source, IEdgeDetectorFilter filter) where TColor : IPackedVector where TPacked : struct { - return DetectEdges(source, source.Bounds, filter, progressHandler); + return DetectEdges(source, source.Bounds, filter); } /// @@ -155,22 +150,12 @@ namespace ImageProcessorCore /// The structure that specifies the portion of the image object to alter. /// /// The filter for detecting edges. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image DetectEdges(this Image source, Rectangle rectangle, IEdgeDetectorFilter filter, ProgressEventHandler progressHandler = null) + public static Image DetectEdges(this Image source, Rectangle rectangle, IEdgeDetectorFilter filter) where TColor : IPackedVector where TPacked : struct { - filter.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, filter); - } - finally - { - filter.OnProgress -= progressHandler; - } + return source.Process(rectangle, filter); } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Samplers/EntropyCrop.cs b/src/ImageProcessorCore/Samplers/EntropyCrop.cs index ba129dab4..04e84cfaf 100644 --- a/src/ImageProcessorCore/Samplers/EntropyCrop.cs +++ b/src/ImageProcessorCore/Samplers/EntropyCrop.cs @@ -19,23 +19,13 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image to crop. /// The threshold for entropic density. - /// A delegate which is called as progress is made processing the image. /// The - public static Image EntropyCrop(this Image source, float threshold = .5f, ProgressEventHandler progressHandler = null) + public static Image EntropyCrop(this Image source, float threshold = .5f) where TColor : IPackedVector where TPacked : struct { EntropyCropProcessor processor = new EntropyCropProcessor(threshold); - processor.OnProgress += progressHandler; - - try - { - return source.Process(source.Width, source.Height, source.Bounds, Rectangle.Empty, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(source.Width, source.Height, source.Bounds, Rectangle.Empty, processor); } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Samplers/Flip.cs b/src/ImageProcessorCore/Samplers/Flip.cs index 68a7e7229..ebf880f2b 100644 --- a/src/ImageProcessorCore/Samplers/Flip.cs +++ b/src/ImageProcessorCore/Samplers/Flip.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -19,23 +19,13 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image to rotate, flip, or both. /// The to perform the flip. - /// A delegate which is called as progress is made processing the image. /// The - public static Image Flip(this Image source, FlipType flipType, ProgressEventHandler progressHandler = null) + public static Image Flip(this Image source, FlipType flipType) where TColor : IPackedVector where TPacked : struct { FlipProcessor processor = new FlipProcessor(flipType); - processor.OnProgress += progressHandler; - - try - { - return source.Process(source.Width, source.Height, source.Bounds, source.Bounds, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(source.Width, source.Height, source.Bounds, source.Bounds, processor); } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Samplers/GuassianBlur.cs b/src/ImageProcessorCore/Samplers/GuassianBlur.cs index b2a0768bc..18ff96e47 100644 --- a/src/ImageProcessorCore/Samplers/GuassianBlur.cs +++ b/src/ImageProcessorCore/Samplers/GuassianBlur.cs @@ -19,13 +19,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image this method extends. /// The 'sigma' value representing the weight of the blur. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image GuassianBlur(this Image source, float sigma = 3f, ProgressEventHandler progressHandler = null) + public static Image GuassianBlur(this Image source, float sigma = 3f) where TColor : IPackedVector where TPacked : struct { - return GuassianBlur(source, sigma, source.Bounds, progressHandler); + return GuassianBlur(source, sigma, source.Bounds); } /// @@ -38,23 +37,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image GuassianBlur(this Image source, float sigma, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image GuassianBlur(this Image source, float sigma, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - GuassianBlurProcessor processor = new GuassianBlurProcessor(sigma); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new GuassianBlurProcessor(sigma)); } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Samplers/GuassianSharpen.cs b/src/ImageProcessorCore/Samplers/GuassianSharpen.cs index f3eed8018..219c19ecc 100644 --- a/src/ImageProcessorCore/Samplers/GuassianSharpen.cs +++ b/src/ImageProcessorCore/Samplers/GuassianSharpen.cs @@ -19,13 +19,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image this method extends. /// The 'sigma' value representing the weight of the blur. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image GuassianSharpen(this Image source, float sigma = 3f, ProgressEventHandler progressHandler = null) + public static Image GuassianSharpen(this Image source, float sigma = 3f) where TColor : IPackedVector where TPacked : struct { - return GuassianSharpen(source, sigma, source.Bounds, progressHandler); + return GuassianSharpen(source, sigma, source.Bounds); } /// @@ -38,23 +37,12 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image GuassianSharpen(this Image source, float sigma, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image GuassianSharpen(this Image source, float sigma, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { - GuassianSharpenProcessor processor = new GuassianSharpenProcessor(sigma); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new GuassianSharpenProcessor(sigma)); } } } diff --git a/src/ImageProcessorCore/Samplers/OilPainting.cs b/src/ImageProcessorCore/Samplers/OilPainting.cs index 9b5975734..07b4144f4 100644 --- a/src/ImageProcessorCore/Samplers/OilPainting.cs +++ b/src/ImageProcessorCore/Samplers/OilPainting.cs @@ -1,13 +1,14 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageProcessorCore { - using Processors; using System; + using Processors; + /// /// Extension methods for the type. /// @@ -21,13 +22,12 @@ namespace ImageProcessorCore /// The image this method extends. /// The number of intensity levels. Higher values result in a broader range of colour intensities forming part of the result image. /// The number of neighbouring pixels used in calculating each individual pixel value. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image OilPaint(this Image source, int levels = 10, int brushSize = 15, ProgressEventHandler progressHandler = null) + public static Image OilPaint(this Image source, int levels = 10, int brushSize = 15) where TColor : IPackedVector where TPacked : struct { - return OilPaint(source, levels, brushSize, source.Bounds, progressHandler); + return OilPaint(source, levels, brushSize, source.Bounds); } /// @@ -41,9 +41,8 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image OilPaint(this Image source, int levels, int brushSize, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image OilPaint(this Image source, int levels, int brushSize, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { @@ -54,17 +53,7 @@ namespace ImageProcessorCore throw new ArgumentOutOfRangeException(nameof(brushSize)); } - OilPaintingProcessor processor = new OilPaintingProcessor(levels, brushSize); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new OilPaintingProcessor(levels, brushSize)); } } } \ No newline at end of file diff --git a/src/ImageProcessorCore/Samplers/Pad.cs b/src/ImageProcessorCore/Samplers/Pad.cs index 6d932a306..3c91a2f89 100644 --- a/src/ImageProcessorCore/Samplers/Pad.cs +++ b/src/ImageProcessorCore/Samplers/Pad.cs @@ -5,8 +5,6 @@ namespace ImageProcessorCore { - using Processors; - /// /// Extension methods for the type. /// @@ -20,9 +18,8 @@ namespace ImageProcessorCore /// The source image to pad. /// The new width. /// The new height. - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Pad(this Image source, int width, int height, ProgressEventHandler progressHandler = null) + public static Image Pad(this Image source, int width, int height) where TColor : IPackedVector where TPacked : struct { @@ -33,7 +30,7 @@ namespace ImageProcessorCore Sampler = new NearestNeighborResampler() }; - return Resize(source, options, progressHandler); + return Resize(source, options); } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Samplers/Pixelate.cs b/src/ImageProcessorCore/Samplers/Pixelate.cs index 4dd17ad13..5d39728b3 100644 --- a/src/ImageProcessorCore/Samplers/Pixelate.cs +++ b/src/ImageProcessorCore/Samplers/Pixelate.cs @@ -5,9 +5,10 @@ namespace ImageProcessorCore { - using Processors; using System; + using Processors; + /// /// Extension methods for the type. /// @@ -20,13 +21,12 @@ namespace ImageProcessorCore /// 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. /// The . - public static Image Pixelate(this Image source, int size = 4, ProgressEventHandler progressHandler = null) + public static Image Pixelate(this Image source, int size = 4) where TColor : IPackedVector where TPacked : struct { - return Pixelate(source, size, source.Bounds, progressHandler); + return Pixelate(source, size, source.Bounds); } /// @@ -39,9 +39,8 @@ namespace ImageProcessorCore /// /// The structure that specifies the portion of the image object to alter. /// - /// A delegate which is called as progress is made processing the image. /// The . - public static Image Pixelate(this Image source, int size, Rectangle rectangle, ProgressEventHandler progressHandler = null) + public static Image Pixelate(this Image source, int size, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { @@ -50,17 +49,7 @@ namespace ImageProcessorCore throw new ArgumentOutOfRangeException(nameof(size)); } - PixelateProcessor processor = new PixelateProcessor(size); - processor.OnProgress += progressHandler; - - try - { - return source.Process(rectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(rectangle, new PixelateProcessor(size)); } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Samplers/Processors/CompandingResizeProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/CompandingResizeProcessor.cs index 50ad894bf..a6c07cffb 100644 --- a/src/ImageProcessorCore/Samplers/Processors/CompandingResizeProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/CompandingResizeProcessor.cs @@ -80,8 +80,6 @@ namespace ImageProcessorCore.Processors // X coordinates of source points targetPixels[x, y] = sourcePixels[(int)((x - startX) * widthFactor), originY]; } - - this.OnRowProcessed(); }); } @@ -154,8 +152,6 @@ namespace ImageProcessorCore.Processors d.PackFromVector4(destination.Compress()); targetPixels[x, y] = d; } - - this.OnRowProcessed(); }); } } diff --git a/src/ImageProcessorCore/Samplers/Processors/Convolution/Convolution2DFilter.cs b/src/ImageProcessorCore/Samplers/Processors/Convolution/Convolution2DFilter.cs index 307da4353..51cbcdf28 100644 --- a/src/ImageProcessorCore/Samplers/Processors/Convolution/Convolution2DFilter.cs +++ b/src/ImageProcessorCore/Samplers/Processors/Convolution/Convolution2DFilter.cs @@ -123,11 +123,9 @@ namespace ImageProcessorCore.Processors packed.PackFromVector4(new Vector4(red, green, blue, targetColor.Z)); targetPixels[x, y] = packed; } - - this.OnRowProcessed(); } }); } } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Samplers/Processors/Convolution/Convolution2PassFilter.cs b/src/ImageProcessorCore/Samplers/Processors/Convolution/Convolution2PassFilter.cs index 5eb4155ff..ab6e13bc5 100644 --- a/src/ImageProcessorCore/Samplers/Processors/Convolution/Convolution2PassFilter.cs +++ b/src/ImageProcessorCore/Samplers/Processors/Convolution/Convolution2PassFilter.cs @@ -100,8 +100,6 @@ namespace ImageProcessorCore.Processors packed.PackFromVector4(destination); targetPixels[x, y] = packed; } - - this.OnRowProcessed(); }); } } diff --git a/src/ImageProcessorCore/Samplers/Processors/Convolution/ConvolutionFilter.cs b/src/ImageProcessorCore/Samplers/Processors/Convolution/ConvolutionFilter.cs index 35229eb4f..4a0b41501 100644 --- a/src/ImageProcessorCore/Samplers/Processors/Convolution/ConvolutionFilter.cs +++ b/src/ImageProcessorCore/Samplers/Processors/Convolution/ConvolutionFilter.cs @@ -97,11 +97,9 @@ namespace ImageProcessorCore.Processors packed.PackFromVector4(new Vector4(red, green, blue, targetColor.Z)); targetPixels[x, y] = packed; } - - this.OnRowProcessed(); } }); } } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Samplers/Processors/CropProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/CropProcessor.cs index 80ec06d01..0aaab8395 100644 --- a/src/ImageProcessorCore/Samplers/Processors/CropProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/CropProcessor.cs @@ -37,10 +37,8 @@ namespace ImageProcessorCore.Processors { targetPixels[x, y] = sourcePixels[x + sourceX, y + sourceY]; } - - this.OnRowProcessed(); }); } } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Samplers/Processors/EntropyCropProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/EntropyCropProcessor.cs index 6d9afb9a5..88a31e9e1 100644 --- a/src/ImageProcessorCore/Samplers/Processors/EntropyCropProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/EntropyCropProcessor.cs @@ -71,8 +71,6 @@ namespace ImageProcessorCore.Processors { targetPixels[x - startX, y - targetY] = sourcePixels[x, y]; } - - this.OnRowProcessed(); }); } } diff --git a/src/ImageProcessorCore/Samplers/Processors/FlipProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/FlipProcessor.cs index e178266a4..4c4df43e6 100644 --- a/src/ImageProcessorCore/Samplers/Processors/FlipProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/FlipProcessor.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -76,8 +76,6 @@ namespace ImageProcessorCore.Processors targetPixels[x, y] = tempPixels[x, newY]; targetPixels[x, newY] = tempPixels[x, y]; } - - this.OnRowProcessed(); }); } } @@ -110,10 +108,8 @@ namespace ImageProcessorCore.Processors targetPixels[x, y] = tempPixels[newX, y]; targetPixels[newX, y] = tempPixels[x, y]; } - - this.OnRowProcessed(); }); } } } -} +} \ No newline at end of file diff --git a/src/ImageProcessorCore/Samplers/Processors/ImageSampler.cs b/src/ImageProcessorCore/Samplers/Processors/ImageSampler.cs index 9b21446c7..110ff28bd 100644 --- a/src/ImageProcessorCore/Samplers/Processors/ImageSampler.cs +++ b/src/ImageProcessorCore/Samplers/Processors/ImageSampler.cs @@ -23,9 +23,6 @@ namespace ImageProcessorCore.Processors { this.OnApply(target, source, target.Bounds, sourceRectangle); - this.NumRowsProcessed = 0; - this.TotalRows = sourceRectangle.Height; - this.Apply(target, source, target.Bounds, sourceRectangle, sourceRectangle.Y, sourceRectangle.Bottom); this.AfterApply(target, source, target.Bounds, sourceRectangle); @@ -57,9 +54,6 @@ namespace ImageProcessorCore.Processors this.OnApply(target, source, targetRectangle, sourceRectangle); - this.NumRowsProcessed = 0; - this.TotalRows = targetRectangle.Height; - this.Apply(target, source, targetRectangle, sourceRectangle, targetRectangle.Y, targetRectangle.Bottom); this.AfterApply(target, source, target.Bounds, sourceRectangle); diff --git a/src/ImageProcessorCore/Samplers/Processors/OilPaintingProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/OilPaintingProcessor.cs index b93468655..2709d13a0 100644 --- a/src/ImageProcessorCore/Samplers/Processors/OilPaintingProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/OilPaintingProcessor.cs @@ -145,8 +145,6 @@ namespace ImageProcessorCore.Processors } } - - this.OnRowProcessed(); }); } } diff --git a/src/ImageProcessorCore/Samplers/Processors/PixelateProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/PixelateProcessor.cs index 5e5d1c09e..fe21e7fd6 100644 --- a/src/ImageProcessorCore/Samplers/Processors/PixelateProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/PixelateProcessor.cs @@ -104,8 +104,6 @@ namespace ImageProcessorCore.Processors } } } - - this.OnRowProcessed(); }); } } diff --git a/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs index eea31cea8..74d61983f 100644 --- a/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs @@ -79,8 +79,6 @@ namespace ImageProcessorCore.Processors // X coordinates of source points targetPixels[x, y] = sourcePixels[(int)((x - startX) * widthFactor), originY]; } - - this.OnRowProcessed(); }); } @@ -153,8 +151,6 @@ namespace ImageProcessorCore.Processors d.PackFromVector4(destination); targetPixels[x, y] = d; } - - this.OnRowProcessed(); }); } } diff --git a/src/ImageProcessorCore/Samplers/Processors/RotateProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/RotateProcessor.cs index ba3ed8448..5b6cee4cc 100644 --- a/src/ImageProcessorCore/Samplers/Processors/RotateProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/RotateProcessor.cs @@ -80,8 +80,6 @@ namespace ImageProcessorCore.Processors targetPixels[x, y] = sourcePixels[transformedPoint.X, transformedPoint.Y]; } } - - this.OnRowProcessed(); }); } } @@ -149,8 +147,6 @@ namespace ImageProcessorCore.Processors int newY = width - x - 1; tempPixels[newX, newY] = sourcePixels[x, y]; } - - this.OnRowProcessed(); }); } @@ -182,8 +178,6 @@ namespace ImageProcessorCore.Processors int newY = height - y - 1; targetPixels[newX, newY] = sourcePixels[x, y]; } - - this.OnRowProcessed(); }); } } @@ -213,8 +207,6 @@ namespace ImageProcessorCore.Processors int newX = height - y - 1; tempPixels[newX, x] = sourcePixels[x, y]; } - - this.OnRowProcessed(); }); } diff --git a/src/ImageProcessorCore/Samplers/Processors/SkewProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/SkewProcessor.cs index 9a9adc4ed..47bbabcf1 100644 --- a/src/ImageProcessorCore/Samplers/Processors/SkewProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/SkewProcessor.cs @@ -72,8 +72,6 @@ namespace ImageProcessorCore.Processors targetPixels[x, y] = sourcePixels[transformedPoint.X, transformedPoint.Y]; } } - - OnRowProcessed(); }); } } diff --git a/src/ImageProcessorCore/Samplers/Resize.cs b/src/ImageProcessorCore/Samplers/Resize.cs index 62d482b91..6fd2a7b09 100644 --- a/src/ImageProcessorCore/Samplers/Resize.cs +++ b/src/ImageProcessorCore/Samplers/Resize.cs @@ -19,10 +19,9 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image to resize. /// The resize options. - /// A delegate which is called as progress is made processing the image. /// The /// Passing zero for one of height or width within the resize options will automatically preserve the aspect ratio of the original image - public static Image Resize(this Image source, ResizeOptions options, ProgressEventHandler progressHandler = null) + public static Image Resize(this Image source, ResizeOptions options) where TColor : IPackedVector where TPacked : struct { @@ -39,7 +38,7 @@ namespace ImageProcessorCore Rectangle targetRectangle = ResizeHelper.CalculateTargetLocationAndBounds(source, options); - return Resize(source, options.Size.Width, options.Size.Height, options.Sampler, source.Bounds, targetRectangle, options.Compand, progressHandler); + return Resize(source, options.Size.Width, options.Size.Height, options.Sampler, source.Bounds, targetRectangle, options.Compand); } /// @@ -50,14 +49,13 @@ namespace ImageProcessorCore /// The image to resize. /// The target image width. /// The target image height. - /// A delegate which is called as progress is made processing the image. /// The /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image - public static Image Resize(this Image source, int width, int height, ProgressEventHandler progressHandler = null) + public static Image Resize(this Image source, int width, int height) where TColor : IPackedVector where TPacked : struct { - return Resize(source, width, height, new BicubicResampler(), false, progressHandler); + return Resize(source, width, height, new BicubicResampler(), false); } /// @@ -69,14 +67,13 @@ namespace ImageProcessorCore /// The target image width. /// The target image height. /// Whether to compress and expand the image color-space to gamma correct the image during processing. - /// A delegate which is called as progress is made processing the image. /// The /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image - public static Image Resize(this Image source, int width, int height, bool compand, ProgressEventHandler progressHandler = null) + public static Image Resize(this Image source, int width, int height, bool compand) where TColor : IPackedVector where TPacked : struct { - return Resize(source, width, height, new BicubicResampler(), compand, progressHandler); + return Resize(source, width, height, new BicubicResampler(), compand); } /// @@ -88,14 +85,13 @@ namespace ImageProcessorCore /// The target image width. /// The target image height. /// The to perform the resampling. - /// A delegate which is called as progress is made processing the image. /// The /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image - public static Image Resize(this Image source, int width, int height, IResampler sampler, ProgressEventHandler progressHandler = null) + public static Image Resize(this Image source, int width, int height, IResampler sampler) where TColor : IPackedVector where TPacked : struct { - return Resize(source, width, height, sampler, false, progressHandler); + return Resize(source, width, height, sampler, false); } /// @@ -108,14 +104,13 @@ namespace ImageProcessorCore /// The target image height. /// The to perform the resampling. /// Whether to compress and expand the image color-space to gamma correct the image during processing. - /// A delegate which is called as progress is made processing the image. /// The /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image - public static Image Resize(this Image source, int width, int height, IResampler sampler, bool compand, ProgressEventHandler progressHandler = null) + public static Image Resize(this Image source, int width, int height, IResampler sampler, bool compand) where TColor : IPackedVector where TPacked : struct { - return Resize(source, width, height, sampler, source.Bounds, new Rectangle(0, 0, width, height), compand, progressHandler); + return Resize(source, width, height, sampler, source.Bounds, new Rectangle(0, 0, width, height), compand); } /// @@ -135,10 +130,9 @@ namespace ImageProcessorCore /// The structure that specifies the portion of the target image object to draw to. /// /// Whether to compress and expand the image color-space to gamma correct the image during processing. - /// A delegate which is called as progress is made processing the image. /// The /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image - public static Image Resize(this Image source, int width, int height, IResampler sampler, Rectangle sourceRectangle, Rectangle targetRectangle, bool compand = false, ProgressEventHandler progressHandler = null) + public static Image Resize(this Image source, int width, int height, IResampler sampler, Rectangle sourceRectangle, Rectangle targetRectangle, bool compand = false) where TColor : IPackedVector where TPacked : struct { @@ -168,16 +162,7 @@ namespace ImageProcessorCore processor = new ResizeProcessor(sampler); } - processor.OnProgress += progressHandler; - - try - { - return source.Process(width, height, sourceRectangle, targetRectangle, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(width, height, sourceRectangle, targetRectangle, processor); } } } diff --git a/src/ImageProcessorCore/Samplers/Rotate.cs b/src/ImageProcessorCore/Samplers/Rotate.cs index 1774abaaf..2b0f4dbce 100644 --- a/src/ImageProcessorCore/Samplers/Rotate.cs +++ b/src/ImageProcessorCore/Samplers/Rotate.cs @@ -19,13 +19,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image to rotate. /// The angle in degrees to perform the rotation. - /// A delegate which is called as progress is made processing the image. /// The - public static Image Rotate(this Image source, float degrees, ProgressEventHandler progressHandler = null) + public static Image Rotate(this Image source, float degrees) where TColor : IPackedVector where TPacked : struct { - return Rotate(source, degrees, true, progressHandler); + return Rotate(source, degrees, true); } /// @@ -35,13 +34,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image to rotate. /// The to perform the rotation. - /// A delegate which is called as progress is made processing the image. /// The - public static Image Rotate(this Image source, RotateType rotateType, ProgressEventHandler progressHandler = null) + public static Image Rotate(this Image source, RotateType rotateType) where TColor : IPackedVector where TPacked : struct { - return Rotate(source, (float)rotateType, false, progressHandler); + return Rotate(source, (float)rotateType, false); } /// @@ -52,23 +50,13 @@ namespace ImageProcessorCore /// The image to rotate. /// The angle in degrees to perform the rotation. /// Whether to expand the image to fit the rotated result. - /// A delegate which is called as progress is made processing the image. /// The - public static Image Rotate(this Image source, float degrees, bool expand, ProgressEventHandler progressHandler = null) + public static Image Rotate(this Image source, float degrees, bool expand) where TColor : IPackedVector where TPacked : struct { RotateProcessor processor = new RotateProcessor { Angle = degrees, Expand = expand }; - processor.OnProgress += progressHandler; - - try - { - return source.Process(source.Width, source.Height, source.Bounds, source.Bounds, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(source.Width, source.Height, source.Bounds, source.Bounds, processor); } } } diff --git a/src/ImageProcessorCore/Samplers/RotateFlip.cs b/src/ImageProcessorCore/Samplers/RotateFlip.cs index 8bba64ca5..34af54a98 100644 --- a/src/ImageProcessorCore/Samplers/RotateFlip.cs +++ b/src/ImageProcessorCore/Samplers/RotateFlip.cs @@ -5,8 +5,6 @@ namespace ImageProcessorCore { - using Processors; - /// /// Extension methods for the type. /// @@ -19,13 +17,12 @@ namespace ImageProcessorCore /// The packed format. uint, long, float. /// The image to rotate, flip, or both. /// The to perform the flip. - /// A delegate which is called as progress is made processing the image. /// The - public static Image RotateFlip(this Image source, RotateType rotateType, FlipType flipType, ProgressEventHandler progressHandler = null) + public static Image RotateFlip(this Image source, RotateType rotateType, FlipType flipType) where TColor : IPackedVector where TPacked : struct { - return source.Rotate(rotateType, progressHandler).Flip(flipType, progressHandler); + return source.Rotate(rotateType).Flip(flipType); } } } diff --git a/src/ImageProcessorCore/Samplers/Skew.cs b/src/ImageProcessorCore/Samplers/Skew.cs index 7c6e8b3ef..0a76f07dd 100644 --- a/src/ImageProcessorCore/Samplers/Skew.cs +++ b/src/ImageProcessorCore/Samplers/Skew.cs @@ -20,13 +20,12 @@ namespace ImageProcessorCore /// The image to skew. /// The angle in degrees to perform the rotation along the x-axis. /// The angle in degrees to perform the rotation along the y-axis. - /// A delegate which is called as progress is made processing the image. /// The - public static Image Skew(this Image source, float degreesX, float degreesY, ProgressEventHandler progressHandler = null) + public static Image Skew(this Image source, float degreesX, float degreesY) where TColor : IPackedVector where TPacked : struct { - return Skew(source, degreesX, degreesY, true, progressHandler); + return Skew(source, degreesX, degreesY, true); } /// @@ -38,23 +37,13 @@ namespace ImageProcessorCore /// The angle in degrees to perform the rotation along the x-axis. /// The angle in degrees to perform the rotation along the y-axis. /// Whether to expand the image to fit the skewed result. - /// A delegate which is called as progress is made processing the image. /// The - public static Image Skew(this Image source, float degreesX, float degreesY, bool expand, ProgressEventHandler progressHandler = null) + public static Image Skew(this Image source, float degreesX, float degreesY, bool expand) where TColor : IPackedVector where TPacked : struct { SkewProcessor processor = new SkewProcessor { AngleX = degreesX, AngleY = degreesY, Expand = expand }; - processor.OnProgress += progressHandler; - - try - { - return source.Process(source.Width, source.Height, source.Bounds, source.Bounds, processor); - } - finally - { - processor.OnProgress -= progressHandler; - } + return source.Process(source.Width, source.Height, source.Bounds, source.Bounds, processor); } } } diff --git a/tests/ImageProcessorCore.Tests/FileTestBase.cs b/tests/ImageProcessorCore.Tests/FileTestBase.cs index 0d9622701..84f7532b1 100644 --- a/tests/ImageProcessorCore.Tests/FileTestBase.cs +++ b/tests/ImageProcessorCore.Tests/FileTestBase.cs @@ -36,10 +36,5 @@ namespace ImageProcessorCore.Tests TestImages.Gif.Rings, //TestImages.Gif.Giphy // Perf: Enable for local testing only }; - - protected void ProgressUpdate(object sender, ProgressEventArgs e) - { - Assert.InRange(e.RowsProcessed, 1, e.TotalRows); - } } -} +} \ No newline at end of file diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/CropTest.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/CropTest.cs index a92d0feb0..b92b7c196 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/CropTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/CropTest.cs @@ -28,7 +28,7 @@ namespace ImageProcessorCore.Tests Image image = new Image(stream); using (FileStream output = File.OpenWrite($"{path}/{filename}")) { - image.Crop(image.Width / 2, image.Height / 2, this.ProgressUpdate) + image.Crop(image.Width / 2, image.Height / 2) .Save(output); } } diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/FlipTests.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/FlipTests.cs index e6d4b25b4..5f4a0ae96 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/FlipTests.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/FlipTests.cs @@ -38,7 +38,7 @@ namespace ImageProcessorCore.Tests Image image = new Image(stream); using (FileStream output = File.OpenWrite($"{path}/{filename}")) { - image.Flip(flipType, this.ProgressUpdate) + image.Flip(flipType) .Save(output); } } diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/PadTest.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/PadTest.cs index 8a70b0887..e65ab4e33 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/PadTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/PadTest.cs @@ -28,7 +28,7 @@ namespace ImageProcessorCore.Tests Image image = new Image(stream); using (FileStream output = File.OpenWrite($"{path}/{filename}")) { - image.Pad(image.Width + 50, image.Height + 50, this.ProgressUpdate) + image.Pad(image.Width + 50, image.Height + 50) .Save(output); } } diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/ResizeTests.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/ResizeTests.cs index 997f30995..c149dd1b2 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/ResizeTests.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/ResizeTests.cs @@ -51,8 +51,8 @@ namespace ImageProcessorCore.Tests Image image = new Image(stream); using (FileStream output = File.OpenWrite($"{path}/{filename}")) { - image.Resize(image.Width / 2, image.Height / 2, sampler, true, this.ProgressUpdate) - //image.Resize(555, 275, sampler, false, this.ProgressUpdate) + image.Resize(image.Width / 2, image.Height / 2, sampler, true) + //image.Resize(555, 275, sampler, false) .Save(output); } } @@ -79,7 +79,7 @@ namespace ImageProcessorCore.Tests Image image = new Image(stream); using (FileStream output = File.OpenWrite($"{path}/{filename}")) { - image.Resize(image.Width / 3, 0, sampler, false, this.ProgressUpdate) + image.Resize(image.Width / 3, 0, sampler, false) .Save(output); } } @@ -106,7 +106,7 @@ namespace ImageProcessorCore.Tests Image image = new Image(stream); using (FileStream output = File.OpenWrite($"{path}/{filename}")) { - image.Resize(0, image.Height / 3, sampler, false, this.ProgressUpdate) + image.Resize(0, image.Height / 3, sampler, false) .Save(output); } } @@ -139,7 +139,7 @@ namespace ImageProcessorCore.Tests Size = new Size(image.Width / 2, image.Height) }; - image.Resize(options, this.ProgressUpdate) + image.Resize(options) .Save(output); } } @@ -172,7 +172,7 @@ namespace ImageProcessorCore.Tests Size = new Size(image.Width, image.Height / 2) }; - image.Resize(options, this.ProgressUpdate) + image.Resize(options) .Save(output); } } @@ -205,7 +205,7 @@ namespace ImageProcessorCore.Tests Mode = ResizeMode.Pad }; - image.Resize(options, this.ProgressUpdate) + image.Resize(options) .Save(output); } } @@ -239,7 +239,7 @@ namespace ImageProcessorCore.Tests Mode = ResizeMode.BoxPad }; - image.Resize(options, this.ProgressUpdate) + image.Resize(options) .Save(output); } } @@ -273,7 +273,7 @@ namespace ImageProcessorCore.Tests Mode = ResizeMode.Max }; - image.Resize(options, this.ProgressUpdate) + image.Resize(options) .Save(output); } } @@ -307,7 +307,7 @@ namespace ImageProcessorCore.Tests Mode = ResizeMode.Min }; - image.Resize(options, this.ProgressUpdate) + image.Resize(options) .Save(output); } } @@ -341,7 +341,7 @@ namespace ImageProcessorCore.Tests Mode = ResizeMode.Stretch }; - image.Resize(options, this.ProgressUpdate) + image.Resize(options) .Save(output); } } diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateFlipTest.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateFlipTest.cs index 72fcfb7b9..ea0199e0a 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateFlipTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateFlipTest.cs @@ -40,7 +40,7 @@ namespace ImageProcessorCore.Tests Image image = new Image(stream); using (FileStream output = File.OpenWrite($"{path}/{filename}")) { - image.RotateFlip(rotateType, flipType, this.ProgressUpdate) + image.RotateFlip(rotateType, flipType) .Save(output); } }