Browse Source

Remove progress event handler.

It was useless once multiple processors were combined and also hurt
performance.


Former-commit-id: 639ea64d56094dbaed1cfb94cdc154d5439fc446
Former-commit-id: 9cf0ff1d972ff903bc14c8121c2feb15fcbcd690
Former-commit-id: 04da60830efe9a6d774e0f80431592c9c53f1841
af/merge-core
James Jackson-South 10 years ago
parent
commit
5cd6d2de08
  1. 20
      src/ImageProcessorCore/Filters/Alpha.cs
  2. 15
      src/ImageProcessorCore/Filters/BackgroundColor.cs
  3. 20
      src/ImageProcessorCore/Filters/BinaryThreshold.cs
  4. 20
      src/ImageProcessorCore/Filters/BlackWhite.cs
  5. 20
      src/ImageProcessorCore/Filters/Blend.cs
  6. 20
      src/ImageProcessorCore/Filters/Brightness.cs
  7. 19
      src/ImageProcessorCore/Filters/ColorBlindness.cs
  8. 20
      src/ImageProcessorCore/Filters/Contrast.cs
  9. 34
      src/ImageProcessorCore/Filters/Glow.cs
  10. 19
      src/ImageProcessorCore/Filters/Grayscale.cs
  11. 20
      src/ImageProcessorCore/Filters/Hue.cs
  12. 20
      src/ImageProcessorCore/Filters/Invert.cs
  13. 22
      src/ImageProcessorCore/Filters/Kodachrome.cs
  14. 20
      src/ImageProcessorCore/Filters/Lomograph.cs
  15. 20
      src/ImageProcessorCore/Filters/Polaroid.cs
  16. 2
      src/ImageProcessorCore/Filters/Processors/AlphaProcessor.cs
  17. 4
      src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs
  18. 4
      src/ImageProcessorCore/Filters/Processors/Binarization/BinaryThresholdProcessor.cs
  19. 4
      src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs
  20. 2
      src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs
  21. 2
      src/ImageProcessorCore/Filters/Processors/ColorMatrix/ColorMatrixFilter.cs
  22. 2
      src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs
  23. 2
      src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs
  24. 10
      src/ImageProcessorCore/Filters/Processors/ImageFilter.cs
  25. 2
      src/ImageProcessorCore/Filters/Processors/InvertProcessor.cs
  26. 2
      src/ImageProcessorCore/Filters/Processors/VignetteProcessor.cs
  27. 20
      src/ImageProcessorCore/Filters/Saturation.cs
  28. 20
      src/ImageProcessorCore/Filters/Sepia.cs
  29. 36
      src/ImageProcessorCore/Filters/Vignette.cs
  30. 16
      src/ImageProcessorCore/Image/IImageProcessor.cs
  31. 30
      src/ImageProcessorCore/ImageProcessor.cs
  32. 22
      src/ImageProcessorCore/Samplers/AutoOrient.cs
  33. 22
      src/ImageProcessorCore/Samplers/BoxBlur.cs
  34. 19
      src/ImageProcessorCore/Samplers/Crop.cs
  35. 41
      src/ImageProcessorCore/Samplers/DetectEdges.cs
  36. 16
      src/ImageProcessorCore/Samplers/EntropyCrop.cs
  37. 18
      src/ImageProcessorCore/Samplers/Flip.cs
  38. 22
      src/ImageProcessorCore/Samplers/GuassianBlur.cs
  39. 20
      src/ImageProcessorCore/Samplers/GuassianSharpen.cs
  40. 25
      src/ImageProcessorCore/Samplers/OilPainting.cs
  41. 9
      src/ImageProcessorCore/Samplers/Pad.cs
  42. 25
      src/ImageProcessorCore/Samplers/Pixelate.cs
  43. 4
      src/ImageProcessorCore/Samplers/Processors/CompandingResizeProcessor.cs
  44. 4
      src/ImageProcessorCore/Samplers/Processors/Convolution/Convolution2DFilter.cs
  45. 2
      src/ImageProcessorCore/Samplers/Processors/Convolution/Convolution2PassFilter.cs
  46. 4
      src/ImageProcessorCore/Samplers/Processors/Convolution/ConvolutionFilter.cs
  47. 4
      src/ImageProcessorCore/Samplers/Processors/CropProcessor.cs
  48. 2
      src/ImageProcessorCore/Samplers/Processors/EntropyCropProcessor.cs
  49. 8
      src/ImageProcessorCore/Samplers/Processors/FlipProcessor.cs
  50. 6
      src/ImageProcessorCore/Samplers/Processors/ImageSampler.cs
  51. 2
      src/ImageProcessorCore/Samplers/Processors/OilPaintingProcessor.cs
  52. 2
      src/ImageProcessorCore/Samplers/Processors/PixelateProcessor.cs
  53. 4
      src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs
  54. 8
      src/ImageProcessorCore/Samplers/Processors/RotateProcessor.cs
  55. 2
      src/ImageProcessorCore/Samplers/Processors/SkewProcessor.cs
  56. 39
      src/ImageProcessorCore/Samplers/Resize.cs
  57. 24
      src/ImageProcessorCore/Samplers/Rotate.cs
  58. 7
      src/ImageProcessorCore/Samplers/RotateFlip.cs
  59. 19
      src/ImageProcessorCore/Samplers/Skew.cs
  60. 7
      tests/ImageProcessorCore.Tests/FileTestBase.cs
  61. 2
      tests/ImageProcessorCore.Tests/Processors/Samplers/CropTest.cs
  62. 2
      tests/ImageProcessorCore.Tests/Processors/Samplers/FlipTests.cs
  63. 2
      tests/ImageProcessorCore.Tests/Processors/Samplers/PadTest.cs
  64. 22
      tests/ImageProcessorCore.Tests/Processors/Samplers/ResizeTests.cs
  65. 2
      tests/ImageProcessorCore.Tests/Processors/Samplers/RotateFlipTest.cs

20
src/ImageProcessorCore/Filters/Alpha.cs

@ -19,13 +19,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="percent">The new opacity of the image. Must be between 0 and 100.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Alpha<TColor, TPacked>(this Image<TColor, TPacked> source, int percent, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Alpha<TColor, TPacked>(this Image<TColor, TPacked> source, int percent)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Alpha(source, percent, source.Bounds, progressHandler);
return Alpha(source, percent, source.Bounds);
}
/// <summary>
@ -38,23 +37,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image"/>.</returns>
public static Image<TColor, TPacked> Alpha<TColor, TPacked>(this Image<TColor, TPacked> source, int percent, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Alpha<TColor, TPacked>(this Image<TColor, TPacked> source, int percent, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
AlphaProcessor<TColor, TPacked> processor = new AlphaProcessor<TColor, TPacked>(percent);
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new AlphaProcessor<TColor, TPacked>(percent));
}
}
}

15
src/ImageProcessorCore/Filters/BackgroundColor.cs

@ -19,23 +19,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="color">The color to set as the background.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> BackgroundColor<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> BackgroundColor<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
BackgroundColorProcessor<TColor, TPacked> processor = new BackgroundColorProcessor<TColor, TPacked>(color);
processor.OnProgress += progressHandler;
try
{
return source.Process(source.Bounds, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(source.Bounds, new BackgroundColorProcessor<TColor, TPacked>(color));
}
}
}

20
src/ImageProcessorCore/Filters/BinaryThreshold.cs

@ -19,13 +19,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="threshold">The threshold to apply binerization of the image. Must be between 0 and 1.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> BinaryThreshold<TColor, TPacked>(this Image<TColor, TPacked> source, float threshold, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> BinaryThreshold<TColor, TPacked>(this Image<TColor, TPacked> source, float threshold)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return BinaryThreshold(source, threshold, source.Bounds, progressHandler);
return BinaryThreshold(source, threshold, source.Bounds);
}
/// <summary>
@ -38,23 +37,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> BinaryThreshold<TColor, TPacked>(this Image<TColor, TPacked> source, float threshold, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> BinaryThreshold<TColor, TPacked>(this Image<TColor, TPacked> source, float threshold, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
BinaryThresholdProcessor<TColor, TPacked> processor = new BinaryThresholdProcessor<TColor, TPacked>(threshold);
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new BinaryThresholdProcessor<TColor, TPacked>(threshold));
}
}
}

20
src/ImageProcessorCore/Filters/BlackWhite.cs

@ -18,13 +18,12 @@ namespace ImageProcessorCore
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> BlackWhite<TColor, TPacked>(this Image<TColor, TPacked> source, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> BlackWhite<TColor, TPacked>(this Image<TColor, TPacked> source)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return BlackWhite(source, source.Bounds, progressHandler);
return BlackWhite(source, source.Bounds);
}
/// <summary>
@ -36,23 +35,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> BlackWhite<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> BlackWhite<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
BlackWhiteProcessor<TColor, TPacked> processor = new BlackWhiteProcessor<TColor, TPacked>();
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new BlackWhiteProcessor<TColor, TPacked>());
}
}
}

20
src/ImageProcessorCore/Filters/Blend.cs

@ -20,13 +20,12 @@ namespace ImageProcessorCore
/// <param name="source">The image this method extends.</param>
/// <param name="image">The image to blend with the currently processing image.</param>
/// <param name="percent">The opacity of the image image to blend. Must be between 0 and 100.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Blend<TColor, TPacked>(this Image<TColor, TPacked> source, ImageBase<TColor, TPacked> image, int percent = 50, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Blend<TColor, TPacked>(this Image<TColor, TPacked> source, ImageBase<TColor, TPacked> image, int percent = 50)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Blend(source, image, percent, source.Bounds, progressHandler);
return Blend(source, image, percent, source.Bounds);
}
/// <summary>
@ -40,23 +39,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Blend<TColor, TPacked>(this Image<TColor, TPacked> source, ImageBase<TColor, TPacked> image, int percent, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Blend<TColor, TPacked>(this Image<TColor, TPacked> source, ImageBase<TColor, TPacked> image, int percent, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
BlendProcessor<TColor, TPacked> processor = new BlendProcessor<TColor, TPacked>(image, percent);
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new BlendProcessor<TColor, TPacked>(image, percent));
}
}
}

20
src/ImageProcessorCore/Filters/Brightness.cs

@ -19,13 +19,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="amount">The new brightness of the image. Must be between -100 and 100.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Brightness<TColor, TPacked>(this Image<TColor, TPacked> source, int amount, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Brightness<TColor, TPacked>(this Image<TColor, TPacked> source, int amount)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Brightness(source, amount, source.Bounds, progressHandler);
return Brightness(source, amount, source.Bounds);
}
/// <summary>
@ -38,23 +37,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Brightness<TColor, TPacked>(this Image<TColor, TPacked> source, int amount, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Brightness<TColor, TPacked>(this Image<TColor, TPacked> source, int amount, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
BrightnessProcessor<TColor, TPacked> processor = new BrightnessProcessor<TColor, TPacked>(amount);
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new BrightnessProcessor<TColor, TPacked>(amount));
}
}
}

19
src/ImageProcessorCore/Filters/ColorBlindness.cs

@ -19,13 +19,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="colorBlindness">The type of color blindness simulator to apply.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> ColorBlindness<TColor, TPacked>(this Image<TColor, TPacked> source, ColorBlindness colorBlindness, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> ColorBlindness<TColor, TPacked>(this Image<TColor, TPacked> source, ColorBlindness colorBlindness)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return ColorBlindness(source, colorBlindness, source.Bounds, progressHandler);
return ColorBlindness(source, colorBlindness, source.Bounds);
}
/// <summary>
@ -38,9 +37,8 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> ColorBlindness<TColor, TPacked>(this Image<TColor, TPacked> source, ColorBlindness colorBlindness, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> ColorBlindness<TColor, TPacked>(this Image<TColor, TPacked> source, ColorBlindness colorBlindness, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
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);
}
}
}

20
src/ImageProcessorCore/Filters/Contrast.cs

@ -19,13 +19,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="amount">The new contrast of the image. Must be between -100 and 100.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Contrast<TColor, TPacked>(this Image<TColor, TPacked> source, int amount, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Contrast<TColor, TPacked>(this Image<TColor, TPacked> source, int amount)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Contrast(source, amount, source.Bounds, progressHandler);
return Contrast(source, amount, source.Bounds);
}
/// <summary>
@ -38,23 +37,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Contrast<TColor, TPacked>(this Image<TColor, TPacked> source, int amount, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Contrast<TColor, TPacked>(this Image<TColor, TPacked> source, int amount, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
ContrastProcessor<TColor, TPacked> processor = new ContrastProcessor<TColor, TPacked>(amount);
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new ContrastProcessor<TColor, TPacked>(amount));
}
}
}

34
src/ImageProcessorCore/Filters/Glow.cs

@ -18,13 +18,12 @@ namespace ImageProcessorCore
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Glow<TColor, TPacked>(this Image<TColor, TPacked> source, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Glow<TColor, TPacked>(this Image<TColor, TPacked> source)
where TColor : IPackedVector<TPacked>
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);
}
/// <summary>
@ -34,13 +33,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="color">The color to set as the glow.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Glow<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Glow<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Glow(source, color, source.Bounds.Width * .5F, source.Bounds, progressHandler);
return Glow(source, color, source.Bounds.Width * .5F, source.Bounds);
}
/// <summary>
@ -50,13 +48,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="radius">The the radius.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Glow<TColor, TPacked>(this Image<TColor, TPacked> source, float radius, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Glow<TColor, TPacked>(this Image<TColor, TPacked> source, float radius)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Glow(source, default(TColor), radius, source.Bounds, progressHandler);
return Glow(source, default(TColor), radius, source.Bounds);
}
/// <summary>
@ -68,13 +65,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Glow<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Glow<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Glow(source, default(TColor), 0, rectangle, progressHandler);
return Glow(source, default(TColor), 0, rectangle);
}
/// <summary>
@ -88,9 +84,8 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Glow<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, float radius, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Glow<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, float radius, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
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);
}
}
}

19
src/ImageProcessorCore/Filters/Grayscale.cs

@ -19,13 +19,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="mode">The formula to apply to perform the operation.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Grayscale<TColor, TPacked>(this Image<TColor, TPacked> source, GrayscaleMode mode = GrayscaleMode.Bt709, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Grayscale<TColor, TPacked>(this Image<TColor, TPacked> source, GrayscaleMode mode = GrayscaleMode.Bt709)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Grayscale(source, source.Bounds, mode, progressHandler);
return Grayscale(source, source.Bounds, mode);
}
/// <summary>
@ -38,9 +37,8 @@ namespace ImageProcessorCore
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="mode">The formula to apply to perform the operation.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Grayscale<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle, GrayscaleMode mode = GrayscaleMode.Bt709, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Grayscale<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle, GrayscaleMode mode = GrayscaleMode.Bt709)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
@ -48,16 +46,7 @@ namespace ImageProcessorCore
? (IImageFilter<TColor, TPacked>)new GrayscaleBt709Processor<TColor, TPacked>()
: new GrayscaleBt601Processor<TColor, TPacked>();
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, processor);
}
}
}

20
src/ImageProcessorCore/Filters/Hue.cs

@ -19,13 +19,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="degrees">The angle in degrees to adjust the image.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Hue<TColor, TPacked>(this Image<TColor, TPacked> source, float degrees, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Hue<TColor, TPacked>(this Image<TColor, TPacked> source, float degrees)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Hue(source, degrees, source.Bounds, progressHandler);
return Hue(source, degrees, source.Bounds);
}
/// <summary>
@ -38,23 +37,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Hue<TColor, TPacked>(this Image<TColor, TPacked> source, float degrees, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Hue<TColor, TPacked>(this Image<TColor, TPacked> source, float degrees, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
HueProcessor<TColor, TPacked> processor = new HueProcessor<TColor, TPacked>(degrees);
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new HueProcessor<TColor, TPacked>(degrees));
}
}
}

20
src/ImageProcessorCore/Filters/Invert.cs

@ -18,13 +18,12 @@ namespace ImageProcessorCore
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image"/>.</returns>
public static Image<TColor, TPacked> Invert<TColor, TPacked>(this Image<TColor, TPacked> source, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Invert<TColor, TPacked>(this Image<TColor, TPacked> source)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Invert(source, source.Bounds, progressHandler);
return Invert(source, source.Bounds);
}
/// <summary>
@ -36,23 +35,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image"/>.</returns>
public static Image<TColor, TPacked> Invert<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Invert<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
InvertProcessor<TColor, TPacked> processor = new InvertProcessor<TColor, TPacked>();
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new InvertProcessor<TColor, TPacked>());
}
}
}

22
src/ImageProcessorCore/Filters/Kodachrome.cs

@ -10,8 +10,6 @@ namespace ImageProcessorCore
/// <summary>
/// Extension methods for the <see cref="Image{TColor, TPacked}"/> type.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public static partial class ImageExtensions
{
/// <summary>
@ -20,13 +18,12 @@ namespace ImageProcessorCore
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Kodachrome<TColor, TPacked>(this Image<TColor, TPacked> source, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Kodachrome<TColor, TPacked>(this Image<TColor, TPacked> source)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Kodachrome(source, source.Bounds, progressHandler);
return Kodachrome(source, source.Bounds);
}
/// <summary>
@ -38,23 +35,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Kodachrome<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Kodachrome<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
KodachromeProcessor<TColor, TPacked> processor = new KodachromeProcessor<TColor, TPacked>();
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new KodachromeProcessor<TColor, TPacked>());
}
}
}

20
src/ImageProcessorCore/Filters/Lomograph.cs

@ -18,13 +18,12 @@ namespace ImageProcessorCore
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Lomograph<TColor, TPacked>(this Image<TColor, TPacked> source, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Lomograph<TColor, TPacked>(this Image<TColor, TPacked> source)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Lomograph(source, source.Bounds, progressHandler);
return Lomograph(source, source.Bounds);
}
/// <summary>
@ -36,23 +35,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Lomograph<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Lomograph<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
LomographProcessor<TColor, TPacked> processor = new LomographProcessor<TColor, TPacked>();
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new LomographProcessor<TColor, TPacked>());
}
}
}

20
src/ImageProcessorCore/Filters/Polaroid.cs

@ -18,13 +18,12 @@ namespace ImageProcessorCore
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Polaroid<TColor, TPacked>(this Image<TColor, TPacked> source, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Polaroid<TColor, TPacked>(this Image<TColor, TPacked> source)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Polaroid(source, source.Bounds, progressHandler);
return Polaroid(source, source.Bounds);
}
/// <summary>
@ -36,23 +35,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Polaroid<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Polaroid<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
PolaroidProcessor<TColor, TPacked> processor = new PolaroidProcessor<TColor, TPacked>();
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new PolaroidProcessor<TColor, TPacked>());
}
}
}

2
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();
});
}
}

4
src/ImageProcessorCore/Filters/Processors/BackgroundColorProcessor.cs

@ -12,6 +12,8 @@ namespace ImageProcessorCore.Processors
/// <summary>
/// Sets the background color of the image.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public class BackgroundColorProcessor<TColor, TPacked> : ImageFilter<TColor, TPacked>
where TColor : IPackedVector<TPacked>
where TPacked : struct
@ -89,8 +91,6 @@ namespace ImageProcessorCore.Processors
packed.PackFromVector4(color);
sourcePixels[offsetX, offsetY] = packed;
}
this.OnRowProcessed();
});
}
}

4
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();
});
}
}
}
}
}

4
src/ImageProcessorCore/Filters/Processors/BlendProcessor.cs

@ -99,10 +99,8 @@ namespace ImageProcessorCore.Processors
packed.PackFromVector4(color);
sourcePixels[offsetX, offsetY] = packed;
}
this.OnRowProcessed();
});
}
}
}
}
}

2
src/ImageProcessorCore/Filters/Processors/BrightnessProcessor.cs

@ -83,8 +83,6 @@ namespace ImageProcessorCore.Processors
sourcePixels[offsetX, offsetY] = packed;
}
this.OnRowProcessed();
});
}
}

2
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();
});
}
}

2
src/ImageProcessorCore/Filters/Processors/ContrastProcessor.cs

@ -83,8 +83,6 @@ namespace ImageProcessorCore.Processors
packed.PackFromVector4(vector.Compress());
sourcePixels[offsetX, offsetY] = packed;
}
this.OnRowProcessed();
});
}
}

2
src/ImageProcessorCore/Filters/Processors/GlowProcessor.cs

@ -87,8 +87,6 @@ namespace ImageProcessorCore.Processors
sourcePixels[offsetX, offsetY] = packed;
}
}
this.OnRowProcessed();
});
}
}

10
src/ImageProcessorCore/Filters/Processors/ImageFilter.cs

@ -1,4 +1,9 @@
namespace ImageProcessorCore.Processors
// <copyright file="ImageFilter.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
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);

2
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();
});
}
}

2
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();
});
}
}

20
src/ImageProcessorCore/Filters/Saturation.cs

@ -19,13 +19,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="amount">The new saturation of the image. Must be between -100 and 100.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Saturation<TColor, TPacked>(this Image<TColor, TPacked> source, int amount, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Saturation<TColor, TPacked>(this Image<TColor, TPacked> source, int amount)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Saturation(source, amount, source.Bounds, progressHandler);
return Saturation(source, amount, source.Bounds);
}
/// <summary>
@ -38,23 +37,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Saturation<TColor, TPacked>(this Image<TColor, TPacked> source, int amount, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Saturation<TColor, TPacked>(this Image<TColor, TPacked> source, int amount, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
SaturationProcessor<TColor, TPacked> processor = new SaturationProcessor<TColor, TPacked>(amount);
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new SaturationProcessor<TColor, TPacked>(amount));
}
}
}

20
src/ImageProcessorCore/Filters/Sepia.cs

@ -18,13 +18,12 @@ namespace ImageProcessorCore
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image"/>.</returns>
public static Image<TColor, TPacked> Sepia<TColor, TPacked>(this Image<TColor, TPacked> source, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Sepia<TColor, TPacked>(this Image<TColor, TPacked> source)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Sepia(source, source.Bounds, progressHandler);
return Sepia(source, source.Bounds);
}
/// <summary>
@ -36,23 +35,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image"/>.</returns>
public static Image<TColor, TPacked> Sepia<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Sepia<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
SepiaProcessor<TColor, TPacked> processor = new SepiaProcessor<TColor, TPacked>();
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new SepiaProcessor<TColor, TPacked>());
}
}
}

36
src/ImageProcessorCore/Filters/Vignette.cs

@ -18,13 +18,12 @@ namespace ImageProcessorCore
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Vignette<TColor, TPacked>(this Image<TColor, TPacked> source, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Vignette<TColor, TPacked>(this Image<TColor, TPacked> source)
where TColor : IPackedVector<TPacked>
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);
}
/// <summary>
@ -34,13 +33,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="color">The color to set as the vignette.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Vignette<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Vignette<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color)
where TColor : IPackedVector<TPacked>
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);
}
/// <summary>
@ -51,13 +49,12 @@ namespace ImageProcessorCore
/// <param name="source">The image this method extends.</param>
/// <param name="radiusX">The the x-radius.</param>
/// <param name="radiusY">The the y-radius.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Vignette<TColor, TPacked>(this Image<TColor, TPacked> source, float radiusX, float radiusY, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Vignette<TColor, TPacked>(this Image<TColor, TPacked> source, float radiusX, float radiusY)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Vignette(source, default(TColor), radiusX, radiusY, source.Bounds, progressHandler);
return Vignette(source, default(TColor), radiusX, radiusY, source.Bounds);
}
/// <summary>
@ -69,13 +66,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Vignette<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Vignette<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Vignette(source, default(TColor), 0, 0, rectangle, progressHandler);
return Vignette(source, default(TColor), 0, 0, rectangle);
}
/// <summary>
@ -90,9 +86,8 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Vignette<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, float radiusX, float radiusY, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Vignette<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, float radiusX, float radiusY, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
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);
}
}
}
}

16
src/ImageProcessorCore/Image/IImageProcessor.cs

@ -7,27 +7,11 @@ namespace ImageProcessorCore.Processors
{
using System.Threading.Tasks;
/// <summary>
/// A delegate which is called as progress is made processing an image.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">An object that contains the event data.</param>
public delegate void ProgressEventHandler(object sender, ProgressEventArgs e);
/// <summary>
/// Encapsulates methods to alter the pixels of an image.
/// </summary>
public interface IImageProcessor
{
/// <summary>
/// Event fires when each row of the source image has been processed.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
event ProgressEventHandler OnProgress;
/// <summary>
/// Gets or sets the parallel options for processing tasks in parallel.
/// </summary>

30
src/ImageProcessorCore/ImageProcessor.cs

@ -5,8 +5,6 @@
namespace ImageProcessorCore.Processors
{
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
@ -18,14 +16,6 @@ namespace ImageProcessorCore.Processors
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
/// <summary>
/// Gets or sets the number of rows processed by a derived class.
/// </summary>
protected int NumRowsProcessed;
/// <inheritdoc/>
public event ProgressEventHandler OnProgress;
/// <inheritdoc/>
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.
/// </summary>
protected int TotalRows { get; set; }
/// <summary>
/// Must be called by derived classes after processing a single row.
/// </summary>
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 });
}
}
}
}

22
src/ImageProcessorCore/Samplers/AutoOrient.cs

@ -5,8 +5,6 @@
namespace ImageProcessorCore
{
using Processors;
/// <summary>
/// Extension methods for the <see cref="Image{TColor, TPacked}"/> type.
/// </summary>
@ -19,7 +17,7 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image to auto rotate.</param>
/// <returns>The <see cref="Image"/></returns>
public static Image<TColor, TPacked> AutoOrient<TColor, TPacked>(this Image<TColor, TPacked> source, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> AutoOrient<TColor, TPacked>(this Image<TColor, TPacked> source)
where TColor : IPackedVector<TPacked>
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:

22
src/ImageProcessorCore/Samplers/BoxBlur.cs

@ -19,42 +19,30 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="radius">The 'radius' value representing the size of the area to sample.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> BoxBlur<TColor, TPacked>(this Image<TColor, TPacked> source, int radius = 7, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> BoxBlur<TColor, TPacked>(this Image<TColor, TPacked> source, int radius = 7)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return BoxBlur(source, radius, source.Bounds, progressHandler);
return BoxBlur(source, radius, source.Bounds);
}
/// <summary>
/// Applies a box blur to the image.
/// </summary>
/// <typeparam name="T">The pixel format.</typeparam>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="radius">The 'radius' value representing the size of the area to sample.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> BoxBlur<TColor, TPacked>(this Image<TColor, TPacked> source, int radius, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> BoxBlur<TColor, TPacked>(this Image<TColor, TPacked> source, int radius, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
BoxBlurProcessor<TColor, TPacked> processor = new BoxBlurProcessor<TColor, TPacked>(radius);
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new BoxBlurProcessor<TColor, TPacked>(radius));
}
}
}

19
src/ImageProcessorCore/Samplers/Crop.cs

@ -20,13 +20,12 @@ namespace ImageProcessorCore
/// <param name="source">The image to resize.</param>
/// <param name="width">The target image width.</param>
/// <param name="height">The target image height.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/></returns>
public static Image<TColor, TPacked> Crop<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Crop<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Crop(source, width, height, source.Bounds, progressHandler);
return Crop(source, width, height, source.Bounds);
}
/// <summary>
@ -44,9 +43,8 @@ namespace ImageProcessorCore
/// <param name="sourceRectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image"/></returns>
public static Image<TColor, TPacked> Crop<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height, Rectangle sourceRectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Crop<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height, Rectangle sourceRectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
@ -61,16 +59,7 @@ namespace ImageProcessorCore
}
CropProcessor<TColor, TPacked> processor = new CropProcessor<TColor, TPacked>();
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);
}
}
}

41
src/ImageProcessorCore/Samplers/DetectEdges.cs

@ -19,13 +19,12 @@ namespace ImageProcessorCore
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> DetectEdges<TColor, TPacked>(this Image<TColor, TPacked> source, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> DetectEdges<TColor, TPacked>(this Image<TColor, TPacked> source)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return DetectEdges(source, source.Bounds, new SobelProcessor<TColor, TPacked> { Grayscale = true }, progressHandler);
return DetectEdges(source, source.Bounds, new SobelProcessor<TColor, TPacked> { Grayscale = true });
}
/// <summary>
@ -38,13 +37,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> DetectEdges<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> DetectEdges<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return DetectEdges(source, rectangle, new SobelProcessor<TColor, TPacked> { Grayscale = true }, progressHandler);
return DetectEdges(source, rectangle, new SobelProcessor<TColor, TPacked> { Grayscale = true });
}
/// <summary>
@ -55,13 +53,12 @@ namespace ImageProcessorCore
/// <param name="source">The image this method extends.</param>
/// <param name="filter">The filter for detecting edges.</param>
/// <param name="grayscale">Whether to convert the image to Grayscale first. Defaults to true.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> DetectEdges<TColor, TPacked>(this Image<TColor, TPacked> source, EdgeDetection filter, bool grayscale = true, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> DetectEdges<TColor, TPacked>(this Image<TColor, TPacked> source, EdgeDetection filter, bool grayscale = true)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return DetectEdges(source, filter, source.Bounds, grayscale, progressHandler);
return DetectEdges(source, filter, source.Bounds, grayscale);
}
/// <summary>
@ -75,9 +72,8 @@ namespace ImageProcessorCore
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="grayscale">Whether to convert the image to Grayscale first. Defaults to true.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> DetectEdges<TColor, TPacked>(this Image<TColor, TPacked> source, EdgeDetection filter, Rectangle rectangle, bool grayscale = true, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> DetectEdges<TColor, TPacked>(this Image<TColor, TPacked> source, EdgeDetection filter, Rectangle rectangle, bool grayscale = true)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
@ -126,7 +122,7 @@ namespace ImageProcessorCore
break;
}
return DetectEdges(source, rectangle, processor, progressHandler);
return DetectEdges(source, rectangle, processor);
}
/// <summary>
@ -136,13 +132,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="filter">The filter for detecting edges.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> DetectEdges<TColor, TPacked>(this Image<TColor, TPacked> source, IEdgeDetectorFilter<TColor, TPacked> filter, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> DetectEdges<TColor, TPacked>(this Image<TColor, TPacked> source, IEdgeDetectorFilter<TColor, TPacked> filter)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return DetectEdges(source, source.Bounds, filter, progressHandler);
return DetectEdges(source, source.Bounds, filter);
}
/// <summary>
@ -155,22 +150,12 @@ namespace ImageProcessorCore
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="filter">The filter for detecting edges.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> DetectEdges<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle, IEdgeDetectorFilter<TColor, TPacked> filter, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> DetectEdges<TColor, TPacked>(this Image<TColor, TPacked> source, Rectangle rectangle, IEdgeDetectorFilter<TColor, TPacked> filter)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
filter.OnProgress += progressHandler;
try
{
return source.Process(rectangle, filter);
}
finally
{
filter.OnProgress -= progressHandler;
}
return source.Process(rectangle, filter);
}
}
}
}

16
src/ImageProcessorCore/Samplers/EntropyCrop.cs

@ -19,23 +19,13 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image to crop.</param>
/// <param name="threshold">The threshold for entropic density.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image"/></returns>
public static Image<TColor, TPacked> EntropyCrop<TColor, TPacked>(this Image<TColor, TPacked> source, float threshold = .5f, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> EntropyCrop<TColor, TPacked>(this Image<TColor, TPacked> source, float threshold = .5f)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
EntropyCropProcessor<TColor, TPacked> processor = new EntropyCropProcessor<TColor, TPacked>(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);
}
}
}
}

18
src/ImageProcessorCore/Samplers/Flip.cs

@ -1,4 +1,4 @@
// <copyright file="RotateFlip.cs" company="James Jackson-South">
// <copyright file="Flip.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
@ -19,23 +19,13 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image to rotate, flip, or both.</param>
/// <param name="flipType">The <see cref="FlipType"/> to perform the flip.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image"/></returns>
public static Image<TColor, TPacked> Flip<TColor, TPacked>(this Image<TColor, TPacked> source, FlipType flipType, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Flip<TColor, TPacked>(this Image<TColor, TPacked> source, FlipType flipType)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
FlipProcessor<TColor, TPacked> processor = new FlipProcessor<TColor, TPacked>(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);
}
}
}
}

22
src/ImageProcessorCore/Samplers/GuassianBlur.cs

@ -19,13 +19,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="sigma">The 'sigma' value representing the weight of the blur.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> GuassianBlur<TColor, TPacked>(this Image<TColor, TPacked> source, float sigma = 3f, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> GuassianBlur<TColor, TPacked>(this Image<TColor, TPacked> source, float sigma = 3f)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return GuassianBlur(source, sigma, source.Bounds, progressHandler);
return GuassianBlur(source, sigma, source.Bounds);
}
/// <summary>
@ -38,23 +37,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> GuassianBlur<TColor, TPacked>(this Image<TColor, TPacked> source, float sigma, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> GuassianBlur<TColor, TPacked>(this Image<TColor, TPacked> source, float sigma, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
GuassianBlurProcessor<TColor, TPacked> processor = new GuassianBlurProcessor<TColor, TPacked>(sigma);
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new GuassianBlurProcessor<TColor, TPacked>(sigma));
}
}
}
}

20
src/ImageProcessorCore/Samplers/GuassianSharpen.cs

@ -19,13 +19,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="sigma">The 'sigma' value representing the weight of the blur.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> GuassianSharpen<TColor, TPacked>(this Image<TColor, TPacked> source, float sigma = 3f, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> GuassianSharpen<TColor, TPacked>(this Image<TColor, TPacked> source, float sigma = 3f)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return GuassianSharpen(source, sigma, source.Bounds, progressHandler);
return GuassianSharpen(source, sigma, source.Bounds);
}
/// <summary>
@ -38,23 +37,12 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> GuassianSharpen<TColor, TPacked>(this Image<TColor, TPacked> source, float sigma, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> GuassianSharpen<TColor, TPacked>(this Image<TColor, TPacked> source, float sigma, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
GuassianSharpenProcessor<TColor, TPacked> processor = new GuassianSharpenProcessor<TColor, TPacked>(sigma);
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new GuassianSharpenProcessor<TColor, TPacked>(sigma));
}
}
}

25
src/ImageProcessorCore/Samplers/OilPainting.cs

@ -1,13 +1,14 @@
// <copyright file="Pixelate.cs" company="James Jackson-South">
// <copyright file="OilPainting.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageProcessorCore
{
using Processors;
using System;
using Processors;
/// <summary>
/// Extension methods for the <see cref="Image{TColor, TPacked}"/> type.
/// </summary>
@ -21,13 +22,12 @@ namespace ImageProcessorCore
/// <param name="source">The image this method extends.</param>
/// <param name="levels">The number of intensity levels. Higher values result in a broader range of colour intensities forming part of the result image.</param>
/// <param name="brushSize">The number of neighbouring pixels used in calculating each individual pixel value.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> OilPaint<TColor, TPacked>(this Image<TColor, TPacked> source, int levels = 10, int brushSize = 15, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> OilPaint<TColor, TPacked>(this Image<TColor, TPacked> source, int levels = 10, int brushSize = 15)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return OilPaint(source, levels, brushSize, source.Bounds, progressHandler);
return OilPaint(source, levels, brushSize, source.Bounds);
}
/// <summary>
@ -41,9 +41,8 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> OilPaint<TColor, TPacked>(this Image<TColor, TPacked> source, int levels, int brushSize, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> OilPaint<TColor, TPacked>(this Image<TColor, TPacked> source, int levels, int brushSize, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
@ -54,17 +53,7 @@ namespace ImageProcessorCore
throw new ArgumentOutOfRangeException(nameof(brushSize));
}
OilPaintingProcessor<TColor, TPacked> processor = new OilPaintingProcessor<TColor, TPacked>(levels, brushSize);
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new OilPaintingProcessor<TColor, TPacked>(levels, brushSize));
}
}
}

9
src/ImageProcessorCore/Samplers/Pad.cs

@ -5,8 +5,6 @@
namespace ImageProcessorCore
{
using Processors;
/// <summary>
/// Extension methods for the <see cref="Image{TColor, TPacked}"/> type.
/// </summary>
@ -20,9 +18,8 @@ namespace ImageProcessorCore
/// <param name="source">The source image to pad.</param>
/// <param name="width">The new width.</param>
/// <param name="height">The new height.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Pad<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Pad<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
@ -33,7 +30,7 @@ namespace ImageProcessorCore
Sampler = new NearestNeighborResampler()
};
return Resize(source, options, progressHandler);
return Resize(source, options);
}
}
}
}

25
src/ImageProcessorCore/Samplers/Pixelate.cs

@ -5,9 +5,10 @@
namespace ImageProcessorCore
{
using Processors;
using System;
using Processors;
/// <summary>
/// Extension methods for the <see cref="Image{TColor, TPacked}"/> type.
/// </summary>
@ -20,13 +21,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="size">The size of the pixels.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Pixelate<TColor, TPacked>(this Image<TColor, TPacked> source, int size = 4, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Pixelate<TColor, TPacked>(this Image<TColor, TPacked> source, int size = 4)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Pixelate(source, size, source.Bounds, progressHandler);
return Pixelate(source, size, source.Bounds);
}
/// <summary>
@ -39,9 +39,8 @@ namespace ImageProcessorCore
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Pixelate<TColor, TPacked>(this Image<TColor, TPacked> source, int size, Rectangle rectangle, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Pixelate<TColor, TPacked>(this Image<TColor, TPacked> source, int size, Rectangle rectangle)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
@ -50,17 +49,7 @@ namespace ImageProcessorCore
throw new ArgumentOutOfRangeException(nameof(size));
}
PixelateProcessor<TColor, TPacked> processor = new PixelateProcessor<TColor, TPacked>(size);
processor.OnProgress += progressHandler;
try
{
return source.Process(rectangle, processor);
}
finally
{
processor.OnProgress -= progressHandler;
}
return source.Process(rectangle, new PixelateProcessor<TColor, TPacked>(size));
}
}
}
}

4
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();
});
}
}

4
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();
}
});
}
}
}
}
}

2
src/ImageProcessorCore/Samplers/Processors/Convolution/Convolution2PassFilter.cs

@ -100,8 +100,6 @@ namespace ImageProcessorCore.Processors
packed.PackFromVector4(destination);
targetPixels[x, y] = packed;
}
this.OnRowProcessed();
});
}
}

4
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();
}
});
}
}
}
}
}

4
src/ImageProcessorCore/Samplers/Processors/CropProcessor.cs

@ -37,10 +37,8 @@ namespace ImageProcessorCore.Processors
{
targetPixels[x, y] = sourcePixels[x + sourceX, y + sourceY];
}
this.OnRowProcessed();
});
}
}
}
}
}

2
src/ImageProcessorCore/Samplers/Processors/EntropyCropProcessor.cs

@ -71,8 +71,6 @@ namespace ImageProcessorCore.Processors
{
targetPixels[x - startX, y - targetY] = sourcePixels[x, y];
}
this.OnRowProcessed();
});
}
}

8
src/ImageProcessorCore/Samplers/Processors/FlipProcessor.cs

@ -1,4 +1,4 @@
// <copyright file="RotateFlipProcessor.cs" company="James Jackson-South">
// <copyright file="FlipProcessor.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
@ -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();
});
}
}
}
}
}

6
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);

2
src/ImageProcessorCore/Samplers/Processors/OilPaintingProcessor.cs

@ -145,8 +145,6 @@ namespace ImageProcessorCore.Processors
}
}
this.OnRowProcessed();
});
}
}

2
src/ImageProcessorCore/Samplers/Processors/PixelateProcessor.cs

@ -104,8 +104,6 @@ namespace ImageProcessorCore.Processors
}
}
}
this.OnRowProcessed();
});
}
}

4
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();
});
}
}

8
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();
});
}

2
src/ImageProcessorCore/Samplers/Processors/SkewProcessor.cs

@ -72,8 +72,6 @@ namespace ImageProcessorCore.Processors
targetPixels[x, y] = sourcePixels[transformedPoint.X, transformedPoint.Y];
}
}
OnRowProcessed();
});
}
}

39
src/ImageProcessorCore/Samplers/Resize.cs

@ -19,10 +19,9 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image to resize.</param>
/// <param name="options">The resize options.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/></returns>
/// <remarks>Passing zero for one of height or width within the resize options will automatically preserve the aspect ratio of the original image</remarks>
public static Image<TColor, TPacked> Resize<TColor, TPacked>(this Image<TColor, TPacked> source, ResizeOptions options, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Resize<TColor, TPacked>(this Image<TColor, TPacked> source, ResizeOptions options)
where TColor : IPackedVector<TPacked>
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);
}
/// <summary>
@ -50,14 +49,13 @@ namespace ImageProcessorCore
/// <param name="source">The image to resize.</param>
/// <param name="width">The target image width.</param>
/// <param name="height">The target image height.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static Image<TColor, TPacked> Resize<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Resize<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Resize(source, width, height, new BicubicResampler(), false, progressHandler);
return Resize(source, width, height, new BicubicResampler(), false);
}
/// <summary>
@ -69,14 +67,13 @@ namespace ImageProcessorCore
/// <param name="width">The target image width.</param>
/// <param name="height">The target image height.</param>
/// <param name="compand">Whether to compress and expand the image color-space to gamma correct the image during processing.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static Image<TColor, TPacked> Resize<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height, bool compand, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Resize<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height, bool compand)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Resize(source, width, height, new BicubicResampler(), compand, progressHandler);
return Resize(source, width, height, new BicubicResampler(), compand);
}
/// <summary>
@ -88,14 +85,13 @@ namespace ImageProcessorCore
/// <param name="width">The target image width.</param>
/// <param name="height">The target image height.</param>
/// <param name="sampler">The <see cref="IResampler"/> to perform the resampling.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static Image<TColor, TPacked> Resize<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height, IResampler sampler, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Resize<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height, IResampler sampler)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Resize(source, width, height, sampler, false, progressHandler);
return Resize(source, width, height, sampler, false);
}
/// <summary>
@ -108,14 +104,13 @@ namespace ImageProcessorCore
/// <param name="height">The target image height.</param>
/// <param name="sampler">The <see cref="IResampler"/> to perform the resampling.</param>
/// <param name="compand">Whether to compress and expand the image color-space to gamma correct the image during processing.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static Image<TColor, TPacked> Resize<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height, IResampler sampler, bool compand, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Resize<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height, IResampler sampler, bool compand)
where TColor : IPackedVector<TPacked>
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);
}
/// <summary>
@ -135,10 +130,9 @@ namespace ImageProcessorCore
/// The <see cref="Rectangle"/> structure that specifies the portion of the target image object to draw to.
/// </param>
/// <param name="compand">Whether to compress and expand the image color-space to gamma correct the image during processing.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static Image<TColor, TPacked> Resize<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height, IResampler sampler, Rectangle sourceRectangle, Rectangle targetRectangle, bool compand = false, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Resize<TColor, TPacked>(this Image<TColor, TPacked> source, int width, int height, IResampler sampler, Rectangle sourceRectangle, Rectangle targetRectangle, bool compand = false)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
@ -168,16 +162,7 @@ namespace ImageProcessorCore
processor = new ResizeProcessor<TColor, TPacked>(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);
}
}
}

24
src/ImageProcessorCore/Samplers/Rotate.cs

@ -19,13 +19,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image to rotate.</param>
/// <param name="degrees">The angle in degrees to perform the rotation.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image"/></returns>
public static Image<TColor, TPacked> Rotate<TColor, TPacked>(this Image<TColor, TPacked> source, float degrees, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Rotate<TColor, TPacked>(this Image<TColor, TPacked> source, float degrees)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Rotate(source, degrees, true, progressHandler);
return Rotate(source, degrees, true);
}
/// <summary>
@ -35,13 +34,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image to rotate.</param>
/// <param name="rotateType">The <see cref="RotateType"/> to perform the rotation.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image"/></returns>
public static Image<TColor, TPacked> Rotate<TColor, TPacked>(this Image<TColor, TPacked> source, RotateType rotateType, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Rotate<TColor, TPacked>(this Image<TColor, TPacked> source, RotateType rotateType)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Rotate(source, (float)rotateType, false, progressHandler);
return Rotate(source, (float)rotateType, false);
}
/// <summary>
@ -52,23 +50,13 @@ namespace ImageProcessorCore
/// <param name="source">The image to rotate.</param>
/// <param name="degrees">The angle in degrees to perform the rotation.</param>
/// <param name="expand">Whether to expand the image to fit the rotated result.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image"/></returns>
public static Image<TColor, TPacked> Rotate<TColor, TPacked>(this Image<TColor, TPacked> source, float degrees, bool expand, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Rotate<TColor, TPacked>(this Image<TColor, TPacked> source, float degrees, bool expand)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
RotateProcessor<TColor, TPacked> processor = new RotateProcessor<TColor, TPacked> { 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);
}
}
}

7
src/ImageProcessorCore/Samplers/RotateFlip.cs

@ -5,8 +5,6 @@
namespace ImageProcessorCore
{
using Processors;
/// <summary>
/// Extension methods for the <see cref="Image{TColor, TPacked}"/> type.
/// </summary>
@ -19,13 +17,12 @@ namespace ImageProcessorCore
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
/// <param name="source">The image to rotate, flip, or both.</param>
/// <param name="flipType">The <see cref="FlipType"/> to perform the flip.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image"/></returns>
public static Image<TColor, TPacked> RotateFlip<TColor, TPacked>(this Image<TColor, TPacked> source, RotateType rotateType, FlipType flipType, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> RotateFlip<TColor, TPacked>(this Image<TColor, TPacked> source, RotateType rotateType, FlipType flipType)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return source.Rotate(rotateType, progressHandler).Flip(flipType, progressHandler);
return source.Rotate(rotateType).Flip(flipType);
}
}
}

19
src/ImageProcessorCore/Samplers/Skew.cs

@ -20,13 +20,12 @@ namespace ImageProcessorCore
/// <param name="source">The image to skew.</param>
/// <param name="degreesX">The angle in degrees to perform the rotation along the x-axis.</param>
/// <param name="degreesY">The angle in degrees to perform the rotation along the y-axis.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image"/></returns>
public static Image<TColor, TPacked> Skew<TColor, TPacked>(this Image<TColor, TPacked> source, float degreesX, float degreesY, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Skew<TColor, TPacked>(this Image<TColor, TPacked> source, float degreesX, float degreesY)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
return Skew(source, degreesX, degreesY, true, progressHandler);
return Skew(source, degreesX, degreesY, true);
}
/// <summary>
@ -38,23 +37,13 @@ namespace ImageProcessorCore
/// <param name="degreesX">The angle in degrees to perform the rotation along the x-axis.</param>
/// <param name="degreesY">The angle in degrees to perform the rotation along the y-axis.</param>
/// <param name="expand">Whether to expand the image to fit the skewed result.</param>
/// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
/// <returns>The <see cref="Image"/></returns>
public static Image<TColor, TPacked> Skew<TColor, TPacked>(this Image<TColor, TPacked> source, float degreesX, float degreesY, bool expand, ProgressEventHandler progressHandler = null)
public static Image<TColor, TPacked> Skew<TColor, TPacked>(this Image<TColor, TPacked> source, float degreesX, float degreesY, bool expand)
where TColor : IPackedVector<TPacked>
where TPacked : struct
{
SkewProcessor<TColor, TPacked> processor = new SkewProcessor<TColor, TPacked> { 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);
}
}
}

7
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);
}
}
}
}

2
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);
}
}

2
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);
}
}

2
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);
}
}

22
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);
}
}

2
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);
}
}

Loading…
Cancel
Save