Browse Source

Renameing classes + simplifying Image<TPixel>

af/merge-core
Scott Williams 9 years ago
parent
commit
612b5e2e50
  1. 2
      samples/AvatarWithRoundedCorner/Program.cs
  2. 12
      src/ImageSharp.Drawing/DrawImage.cs
  3. 18
      src/ImageSharp.Drawing/FillRegion.cs
  4. 12
      src/ImageSharp.Drawing/Paths/DrawBeziers.cs
  5. 12
      src/ImageSharp.Drawing/Paths/DrawLines.cs
  6. 12
      src/ImageSharp.Drawing/Paths/DrawPath.cs
  7. 12
      src/ImageSharp.Drawing/Paths/DrawPathCollection.cs
  8. 12
      src/ImageSharp.Drawing/Paths/DrawPolygon.cs
  9. 12
      src/ImageSharp.Drawing/Paths/DrawRectangle.cs
  10. 8
      src/ImageSharp.Drawing/Paths/FillPathBuilder.cs
  11. 8
      src/ImageSharp.Drawing/Paths/FillPathCollection.cs
  12. 8
      src/ImageSharp.Drawing/Paths/FillPaths.cs
  13. 8
      src/ImageSharp.Drawing/Paths/FillPolygon.cs
  14. 8
      src/ImageSharp.Drawing/Paths/FillRectangle.cs
  15. 4
      src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs
  16. 16
      src/ImageSharp.Drawing/Text/DrawText.Path.cs
  17. 16
      src/ImageSharp.Drawing/Text/DrawText.cs
  18. 32
      src/ImageSharp/ApplyProcessors.cs
  19. 2
      src/ImageSharp/Configuration.cs
  20. 72
      src/ImageSharp/DefaultInternalImageProcessorApplicator.cs
  21. 11
      src/ImageSharp/IImageProcessorApplicatorFactory.cs
  22. 22
      src/ImageSharp/IImageProcessorApplicator{TPixel}.cs
  23. 10
      src/ImageSharp/Image/IImageBase.cs
  24. 30
      src/ImageSharp/Image/ImageBase{TPixel}.cs
  25. 153
      src/ImageSharp/Image/ImageExtensions.cs
  26. 44
      src/ImageSharp/Image/ImageFrame{TPixel}.cs
  27. 32
      src/ImageSharp/Image/ImageProcessingExtensions.cs
  28. 204
      src/ImageSharp/Image/Image{TPixel}.cs
  29. 62
      src/ImageSharp/ImageOperations.cs
  30. 9
      src/ImageSharp/PixelFormats/PackedPixelConverterHelper.cs
  31. 4
      src/ImageSharp/Processing/Binarization/BinaryThreshold.cs
  32. 12
      src/ImageSharp/Processing/Binarization/Dither.cs
  33. 4
      src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs
  34. 4
      src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs
  35. 8
      src/ImageSharp/Processing/ColorMatrix/Grayscale.cs
  36. 4
      src/ImageSharp/Processing/ColorMatrix/Hue.cs
  37. 4
      src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs
  38. 8
      src/ImageSharp/Processing/ColorMatrix/Lomograph.cs
  39. 8
      src/ImageSharp/Processing/ColorMatrix/Polaroid.cs
  40. 4
      src/ImageSharp/Processing/ColorMatrix/Saturation.cs
  41. 4
      src/ImageSharp/Processing/ColorMatrix/Sepia.cs
  42. 6
      src/ImageSharp/Processing/Convolution/BoxBlur.cs
  43. 14
      src/ImageSharp/Processing/Convolution/DetectEdges.cs
  44. 6
      src/ImageSharp/Processing/Convolution/GaussianBlur.cs
  45. 6
      src/ImageSharp/Processing/Convolution/GaussianSharpen.cs
  46. 2
      src/ImageSharp/Processing/Delegate.cs
  47. 4
      src/ImageSharp/Processing/Effects/Alpha.cs
  48. 8
      src/ImageSharp/Processing/Effects/BackgroundColor.cs
  49. 6
      src/ImageSharp/Processing/Effects/Brightness.cs
  50. 4
      src/ImageSharp/Processing/Effects/Contrast.cs
  51. 4
      src/ImageSharp/Processing/Effects/Invert.cs
  52. 8
      src/ImageSharp/Processing/Effects/OilPainting.cs
  53. 6
      src/ImageSharp/Processing/Effects/Pixelate.cs
  54. 24
      src/ImageSharp/Processing/Overlays/Glow.cs
  55. 24
      src/ImageSharp/Processing/Overlays/Vignette.cs
  56. 2
      src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs
  57. 4
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs
  58. 2
      src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs
  59. 4
      src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs
  60. 2
      src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs
  61. 3
      src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs
  62. 3
      src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs
  63. 2
      src/ImageSharp/Processing/Transforms/AutoOrient.cs
  64. 4
      src/ImageSharp/Processing/Transforms/Crop.cs
  65. 2
      src/ImageSharp/Processing/Transforms/EntropyCrop.cs
  66. 2
      src/ImageSharp/Processing/Transforms/Flip.cs
  67. 2
      src/ImageSharp/Processing/Transforms/Pad.cs
  68. 18
      src/ImageSharp/Processing/Transforms/Resize.cs
  69. 6
      src/ImageSharp/Processing/Transforms/Rotate.cs
  70. 2
      src/ImageSharp/Processing/Transforms/RotateFlip.cs
  71. 4
      src/ImageSharp/Processing/Transforms/Skew.cs
  72. 4
      src/ImageSharp/Quantizers/Quantize.cs
  73. 2
      src/ImageSharp/Quantizers/Quantizer{TPixel}.cs
  74. 4
      tests/ImageSharp.Benchmarks/Samplers/Glow.cs
  75. 3
      tests/ImageSharp.Tests/BaseImageOperationsExtensionTest.cs
  76. 30
      tests/ImageSharp.Tests/FakeImageOperationsProvider.cs
  77. 6
      tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs
  78. 4
      tests/ImageSharp.Tests/ImageOperationTests.cs
  79. 2
      tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs
  80. 4
      tests/ImageSharp.Tests/Processing/Processors/Binarization/DitherTest.cs
  81. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/BlackWhiteTest.cs
  82. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/ColorBlindnessTest.cs
  83. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/GrayscaleTest.cs
  84. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/HueTest.cs
  85. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/KodachromeTest.cs
  86. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/LomographTest.cs
  87. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/PolaroidTest.cs
  88. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/SaturationTest.cs
  89. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/SepiaTest.cs
  90. 2
      tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs
  91. 2
      tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs
  92. 2
      tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs
  93. 2
      tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs
  94. 2
      tests/ImageSharp.Tests/Processing/Processors/Effects/AlphaTest.cs
  95. 2
      tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs
  96. 2
      tests/ImageSharp.Tests/Processing/Processors/Effects/BrightnessTest.cs
  97. 2
      tests/ImageSharp.Tests/Processing/Processors/Effects/ContrastTest.cs
  98. 2
      tests/ImageSharp.Tests/Processing/Processors/Effects/InvertTest.cs
  99. 2
      tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs
  100. 2
      tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs

2
samples/AvatarWithRoundedCorner/Program.cs

@ -36,7 +36,7 @@ namespace AvatarWithRoundedCorner
}
// lets create our custom image mutating pipeline
private static IImageOperations<Rgba32> ConvertToAvatar(this IImageOperations<Rgba32> operations, Size size, float cornerRadius)
private static IImageProcessorApplicator<Rgba32> ConvertToAvatar(this IImageProcessorApplicator<Rgba32> operations, Size size, float cornerRadius)
{
return operations.Resize(new ImageSharp.Processing.ResizeOptions
{

12
src/ImageSharp.Drawing/DrawImage.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <param name="location">The location to draw the blended image.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawImage<TPixel>(this IImageOperations<TPixel> source, Image<TPixel> image, Size size, Point location, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawImage<TPixel>(this IImageProcessorApplicator<TPixel> source, Image<TPixel> image, Size size, Point location, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
if (size == default(Size))
@ -49,7 +49,7 @@ namespace ImageSharp
/// <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 1.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Blend<TPixel>(this IImageOperations<TPixel> source, Image<TPixel> image, float percent)
public static IImageProcessorApplicator<TPixel> Blend<TPixel>(this IImageProcessorApplicator<TPixel> source, Image<TPixel> image, float percent)
where TPixel : struct, IPixel<TPixel>
{
GraphicsOptions options = GraphicsOptions.Default;
@ -66,7 +66,7 @@ namespace ImageSharp
/// <param name="blender">The blending mode.</param>
/// <param name="percent">The opacity of the image image to blend. Must be between 0 and 1.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Blend<TPixel>(this IImageOperations<TPixel> source, Image<TPixel> image, PixelBlenderMode blender, float percent)
public static IImageProcessorApplicator<TPixel> Blend<TPixel>(this IImageProcessorApplicator<TPixel> source, Image<TPixel> image, PixelBlenderMode blender, float percent)
where TPixel : struct, IPixel<TPixel>
{
GraphicsOptions options = GraphicsOptions.Default;
@ -83,7 +83,7 @@ namespace ImageSharp
/// <param name="image">The image to blend with the currently processing image.</param>
/// <param name="options">The options, including the blending type and belnding amount.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Blend<TPixel>(this IImageOperations<TPixel> source, Image<TPixel> image, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Blend<TPixel>(this IImageProcessorApplicator<TPixel> source, Image<TPixel> image, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return DrawImage(source, image, default(Size), default(Point), options);
@ -99,7 +99,7 @@ namespace ImageSharp
/// <param name="size">The size to draw the blended image.</param>
/// <param name="location">The location to draw the blended image.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawImage<TPixel>(this IImageOperations<TPixel> source, Image<TPixel> image, float percent, Size size, Point location)
public static IImageProcessorApplicator<TPixel> DrawImage<TPixel>(this IImageProcessorApplicator<TPixel> source, Image<TPixel> image, float percent, Size size, Point location)
where TPixel : struct, IPixel<TPixel>
{
GraphicsOptions options = GraphicsOptions.Default;
@ -118,7 +118,7 @@ namespace ImageSharp
/// <param name="size">The size to draw the blended image.</param>
/// <param name="location">The location to draw the blended image.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawImage<TPixel>(this IImageOperations<TPixel> source, Image<TPixel> image, PixelBlenderMode blender, float percent, Size size, Point location)
public static IImageProcessorApplicator<TPixel> DrawImage<TPixel>(this IImageProcessorApplicator<TPixel> source, Image<TPixel> image, PixelBlenderMode blender, float percent, Size size, Point location)
where TPixel : struct, IPixel<TPixel>
{
GraphicsOptions options = GraphicsOptions.Default;

18
src/ImageSharp.Drawing/FillRegion.cs

@ -23,10 +23,10 @@ namespace ImageSharp
/// <param name="brush">The details how to fill the region of interest.</param>
/// <param name="options">The graphics options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Apply(new FillProcessor<TPixel>(brush, options));
return source.ApplyProcessor(new FillProcessor<TPixel>(brush, options));
}
/// <summary>
@ -36,7 +36,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="brush">The details how to fill the region of interest.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(brush, GraphicsOptions.Default);
@ -49,7 +49,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="color">The color.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, TPixel color)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(new SolidBrush<TPixel>(color));
@ -64,10 +64,10 @@ namespace ImageSharp
/// <param name="region">The region.</param>
/// <param name="options">The graphics options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, Region region, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, Region region, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Apply(new FillRegionProcessor<TPixel>(brush, region, options));
return source.ApplyProcessor(new FillRegionProcessor<TPixel>(brush, region, options));
}
/// <summary>
@ -78,7 +78,7 @@ namespace ImageSharp
/// <param name="brush">The brush.</param>
/// <param name="region">The region.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, Region region)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, Region region)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(brush, region, GraphicsOptions.Default);
@ -93,7 +93,7 @@ namespace ImageSharp
/// <param name="region">The region.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, TPixel color, Region region, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, Region region, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(new SolidBrush<TPixel>(color), region, options);
@ -107,7 +107,7 @@ namespace ImageSharp
/// <param name="color">The color.</param>
/// <param name="region">The region.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, TPixel color, Region region)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, Region region)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(new SolidBrush<TPixel>(color), region);

12
src/ImageSharp.Drawing/Paths/DrawBeziers.cs

@ -28,7 +28,7 @@ namespace ImageSharp
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawBeziers<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawBeziers<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new Pen<TPixel>(brush, thickness), new Path(new CubicBezierLineSegment(points)), options);
@ -43,7 +43,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawBeziers<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points)
public static IImageProcessorApplicator<TPixel> DrawBeziers<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new Pen<TPixel>(brush, thickness), new Path(new CubicBezierLineSegment(points)));
@ -58,7 +58,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawBeziers<TPixel>(this IImageOperations<TPixel> source, TPixel color, float thickness, PointF[] points)
public static IImageProcessorApplicator<TPixel> DrawBeziers<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float thickness, PointF[] points)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawBeziers(new SolidBrush<TPixel>(color), thickness, points);
@ -74,7 +74,7 @@ namespace ImageSharp
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawBeziers<TPixel>(this IImageOperations<TPixel> source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawBeziers<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawBeziers(new SolidBrush<TPixel>(color), thickness, points, options);
@ -89,7 +89,7 @@ namespace ImageSharp
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawBeziers<TPixel>(this IImageOperations<TPixel> source, IPen<TPixel> pen, PointF[] points, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawBeziers<TPixel>(this IImageProcessorApplicator<TPixel> source, IPen<TPixel> pen, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(pen, new Path(new CubicBezierLineSegment(points)), options);
@ -103,7 +103,7 @@ namespace ImageSharp
/// <param name="pen">The pen.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawBeziers<TPixel>(this IImageOperations<TPixel> source, IPen<TPixel> pen, PointF[] points)
public static IImageProcessorApplicator<TPixel> DrawBeziers<TPixel>(this IImageProcessorApplicator<TPixel> source, IPen<TPixel> pen, PointF[] points)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(pen, new Path(new CubicBezierLineSegment(points)));

12
src/ImageSharp.Drawing/Paths/DrawLines.cs

@ -28,7 +28,7 @@ namespace ImageSharp
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawLines<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawLines<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new Pen<TPixel>(brush, thickness), new Path(new LinearLineSegment(points)), options);
@ -43,7 +43,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawLines<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points)
public static IImageProcessorApplicator<TPixel> DrawLines<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new Pen<TPixel>(brush, thickness), new Path(new LinearLineSegment(points)));
@ -58,7 +58,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawLines<TPixel>(this IImageOperations<TPixel> source, TPixel color, float thickness, PointF[] points)
public static IImageProcessorApplicator<TPixel> DrawLines<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float thickness, PointF[] points)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawLines(new SolidBrush<TPixel>(color), thickness, points);
@ -74,7 +74,7 @@ namespace ImageSharp
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>>
public static IImageOperations<TPixel> DrawLines<TPixel>(this IImageOperations<TPixel> source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawLines<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawLines(new SolidBrush<TPixel>(color), thickness, points, options);
@ -89,7 +89,7 @@ namespace ImageSharp
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawLines<TPixel>(this IImageOperations<TPixel> source, IPen<TPixel> pen, PointF[] points, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawLines<TPixel>(this IImageProcessorApplicator<TPixel> source, IPen<TPixel> pen, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(pen, new Path(new LinearLineSegment(points)), options);
@ -103,7 +103,7 @@ namespace ImageSharp
/// <param name="pen">The pen.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawLines<TPixel>(this IImageOperations<TPixel> source, IPen<TPixel> pen, PointF[] points)
public static IImageProcessorApplicator<TPixel> DrawLines<TPixel>(this IImageProcessorApplicator<TPixel> source, IPen<TPixel> pen, PointF[] points)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(pen, new Path(new LinearLineSegment(points)));

12
src/ImageSharp.Drawing/Paths/DrawPath.cs

@ -25,7 +25,7 @@ namespace ImageSharp
/// <param name="path">The path.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, IPen<TPixel> pen, IPath path, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, IPen<TPixel> pen, IPath path, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(pen.StrokeFill, new ShapePath(path, pen), options);
@ -39,7 +39,7 @@ namespace ImageSharp
/// <param name="pen">The pen.</param>
/// <param name="path">The path.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, IPen<TPixel> pen, IPath path)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, IPen<TPixel> pen, IPath path)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(pen, path, GraphicsOptions.Default);
@ -55,7 +55,7 @@ namespace ImageSharp
/// <param name="path">The shape.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, float thickness, IPath path, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, float thickness, IPath path, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new Pen<TPixel>(brush, thickness), path, options);
@ -70,7 +70,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="path">The path.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, float thickness, IPath path)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, float thickness, IPath path)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new Pen<TPixel>(brush, thickness), path);
@ -86,7 +86,7 @@ namespace ImageSharp
/// <param name="path">The path.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, TPixel color, float thickness, IPath path, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float thickness, IPath path, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new SolidBrush<TPixel>(color), thickness, path, options);
@ -101,7 +101,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="path">The path.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, TPixel color, float thickness, IPath path)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float thickness, IPath path)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new SolidBrush<TPixel>(color), thickness, path);

12
src/ImageSharp.Drawing/Paths/DrawPathCollection.cs

@ -25,7 +25,7 @@ namespace ImageSharp
/// <param name="paths">The paths.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, IPen<TPixel> pen, IPathCollection paths, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, IPen<TPixel> pen, IPathCollection paths, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
foreach (IPath path in paths)
@ -44,7 +44,7 @@ namespace ImageSharp
/// <param name="pen">The pen.</param>
/// <param name="paths">The paths.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, IPen<TPixel> pen, IPathCollection paths)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, IPen<TPixel> pen, IPathCollection paths)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(pen, paths, GraphicsOptions.Default);
@ -60,7 +60,7 @@ namespace ImageSharp
/// <param name="paths">The shapes.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, float thickness, IPathCollection paths, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, float thickness, IPathCollection paths, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new Pen<TPixel>(brush, thickness), paths, options);
@ -75,7 +75,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="paths">The paths.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, float thickness, IPathCollection paths)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, float thickness, IPathCollection paths)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new Pen<TPixel>(brush, thickness), paths);
@ -91,7 +91,7 @@ namespace ImageSharp
/// <param name="paths">The paths.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, TPixel color, float thickness, IPathCollection paths, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float thickness, IPathCollection paths, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new SolidBrush<TPixel>(color), thickness, paths, options);
@ -106,7 +106,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="paths">The paths.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, TPixel color, float thickness, IPathCollection paths)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float thickness, IPathCollection paths)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new SolidBrush<TPixel>(color), thickness, paths);

12
src/ImageSharp.Drawing/Paths/DrawPolygon.cs

@ -28,7 +28,7 @@ namespace ImageSharp
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawPolygon<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawPolygon<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new Pen<TPixel>(brush, thickness), new Polygon(new LinearLineSegment(points)), options);
@ -43,7 +43,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawPolygon<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points)
public static IImageProcessorApplicator<TPixel> DrawPolygon<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new Pen<TPixel>(brush, thickness), new Polygon(new LinearLineSegment(points)));
@ -58,7 +58,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawPolygon<TPixel>(this IImageOperations<TPixel> source, TPixel color, float thickness, PointF[] points)
public static IImageProcessorApplicator<TPixel> DrawPolygon<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float thickness, PointF[] points)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawPolygon(new SolidBrush<TPixel>(color), thickness, points);
@ -74,7 +74,7 @@ namespace ImageSharp
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawPolygon<TPixel>(this IImageOperations<TPixel> source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawPolygon<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawPolygon(new SolidBrush<TPixel>(color), thickness, points, options);
@ -88,7 +88,7 @@ namespace ImageSharp
/// <param name="pen">The pen.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawPolygon<TPixel>(this IImageOperations<TPixel> source, IPen<TPixel> pen, PointF[] points)
public static IImageProcessorApplicator<TPixel> DrawPolygon<TPixel>(this IImageProcessorApplicator<TPixel> source, IPen<TPixel> pen, PointF[] points)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(pen, new Polygon(new LinearLineSegment(points)), GraphicsOptions.Default);
@ -103,7 +103,7 @@ namespace ImageSharp
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DrawPolygon<TPixel>(this IImageOperations<TPixel> source, IPen<TPixel> pen, PointF[] points, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawPolygon<TPixel>(this IImageProcessorApplicator<TPixel> source, IPen<TPixel> pen, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(pen, new Polygon(new LinearLineSegment(points)), options);

12
src/ImageSharp.Drawing/Paths/DrawRectangle.cs

@ -25,7 +25,7 @@ namespace ImageSharp
/// <param name="shape">The shape.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, IPen<TPixel> pen, RectangleF shape, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, IPen<TPixel> pen, RectangleF shape, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(pen, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options);
@ -39,7 +39,7 @@ namespace ImageSharp
/// <param name="pen">The pen.</param>
/// <param name="shape">The shape.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, IPen<TPixel> pen, RectangleF shape)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, IPen<TPixel> pen, RectangleF shape)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(pen, shape, GraphicsOptions.Default);
@ -55,7 +55,7 @@ namespace ImageSharp
/// <param name="shape">The shape.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, float thickness, RectangleF shape, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, float thickness, RectangleF shape, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new Pen<TPixel>(brush, thickness), shape, options);
@ -70,7 +70,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="shape">The shape.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, float thickness, RectangleF shape)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, float thickness, RectangleF shape)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new Pen<TPixel>(brush, thickness), shape);
@ -86,7 +86,7 @@ namespace ImageSharp
/// <param name="shape">The shape.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, TPixel color, float thickness, RectangleF shape, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float thickness, RectangleF shape, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new SolidBrush<TPixel>(color), thickness, shape, options);
@ -101,7 +101,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="shape">The shape.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Draw<TPixel>(this IImageOperations<TPixel> source, TPixel color, float thickness, RectangleF shape)
public static IImageProcessorApplicator<TPixel> Draw<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float thickness, RectangleF shape)
where TPixel : struct, IPixel<TPixel>
{
return source.Draw(new SolidBrush<TPixel>(color), thickness, shape);

8
src/ImageSharp.Drawing/Paths/FillPathBuilder.cs

@ -25,7 +25,7 @@ namespace ImageSharp
/// <param name="path">The shape.</param>
/// <param name="options">The graphics options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, Action<PathBuilder> path, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, Action<PathBuilder> path, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
var pb = new PathBuilder();
@ -42,7 +42,7 @@ namespace ImageSharp
/// <param name="brush">The brush.</param>
/// <param name="path">The path.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, Action<PathBuilder> path)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, Action<PathBuilder> path)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(brush, path, GraphicsOptions.Default);
@ -57,7 +57,7 @@ namespace ImageSharp
/// <param name="path">The path.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, TPixel color, Action<PathBuilder> path, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, Action<PathBuilder> path, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(new SolidBrush<TPixel>(color), path, options);
@ -71,7 +71,7 @@ namespace ImageSharp
/// <param name="color">The color.</param>
/// <param name="path">The path.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, TPixel color, Action<PathBuilder> path)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, Action<PathBuilder> path)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(new SolidBrush<TPixel>(color), path);

8
src/ImageSharp.Drawing/Paths/FillPathCollection.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <param name="paths">The shapes.</param>
/// <param name="options">The graphics options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, IPathCollection paths, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, IPathCollection paths, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
foreach (IPath s in paths)
@ -43,7 +43,7 @@ namespace ImageSharp
/// <param name="brush">The brush.</param>
/// <param name="paths">The paths.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, IPathCollection paths)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, IPathCollection paths)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(brush, paths, GraphicsOptions.Default);
@ -58,7 +58,7 @@ namespace ImageSharp
/// <param name="paths">The paths.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, TPixel color, IPathCollection paths, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, IPathCollection paths, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(new SolidBrush<TPixel>(color), paths, options);
@ -72,7 +72,7 @@ namespace ImageSharp
/// <param name="color">The color.</param>
/// <param name="paths">The paths.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, TPixel color, IPathCollection paths)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, IPathCollection paths)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(new SolidBrush<TPixel>(color), paths);

8
src/ImageSharp.Drawing/Paths/FillPaths.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <param name="path">The shape.</param>
/// <param name="options">The graphics options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, IPath path, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, IPath path, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(brush, new ShapeRegion(path), options);
@ -38,7 +38,7 @@ namespace ImageSharp
/// <param name="brush">The brush.</param>
/// <param name="path">The path.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, IPath path)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, IPath path)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(brush, new ShapeRegion(path), GraphicsOptions.Default);
@ -53,7 +53,7 @@ namespace ImageSharp
/// <param name="path">The path.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, TPixel color, IPath path, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, IPath path, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(new SolidBrush<TPixel>(color), path, options);
@ -67,7 +67,7 @@ namespace ImageSharp
/// <param name="color">The color.</param>
/// <param name="path">The path.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, TPixel color, IPath path)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, IPath path)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(new SolidBrush<TPixel>(color), path);

8
src/ImageSharp.Drawing/Paths/FillPolygon.cs

@ -27,7 +27,7 @@ namespace ImageSharp
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> FillPolygon<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, PointF[] points, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> FillPolygon<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(brush, new Polygon(new LinearLineSegment(points)), options);
@ -41,7 +41,7 @@ namespace ImageSharp
/// <param name="brush">The brush.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> FillPolygon<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, PointF[] points)
public static IImageProcessorApplicator<TPixel> FillPolygon<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, PointF[] points)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(brush, new Polygon(new LinearLineSegment(points)));
@ -56,7 +56,7 @@ namespace ImageSharp
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> FillPolygon<TPixel>(this IImageOperations<TPixel> source, TPixel color, PointF[] points, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> FillPolygon<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(new SolidBrush<TPixel>(color), new Polygon(new LinearLineSegment(points)), options);
@ -70,7 +70,7 @@ namespace ImageSharp
/// <param name="color">The color.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> FillPolygon<TPixel>(this IImageOperations<TPixel> source, TPixel color, PointF[] points)
public static IImageProcessorApplicator<TPixel> FillPolygon<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, PointF[] points)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(new SolidBrush<TPixel>(color), new Polygon(new LinearLineSegment(points)));

8
src/ImageSharp.Drawing/Paths/FillRectangle.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <param name="shape">The shape.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, RectangleF shape, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, RectangleF shape, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(brush, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options);
@ -38,7 +38,7 @@ namespace ImageSharp
/// <param name="brush">The brush.</param>
/// <param name="shape">The shape.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, IBrush<TPixel> brush, RectangleF shape)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, RectangleF shape)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(brush, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height));
@ -53,7 +53,7 @@ namespace ImageSharp
/// <param name="shape">The shape.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, TPixel color, RectangleF shape, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, RectangleF shape, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(new SolidBrush<TPixel>(color), shape, options);
@ -67,7 +67,7 @@ namespace ImageSharp
/// <param name="color">The color.</param>
/// <param name="shape">The shape.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Fill<TPixel>(this IImageOperations<TPixel> source, TPixel color, RectangleF shape)
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, RectangleF shape)
where TPixel : struct, IPixel<TPixel>
{
return source.Fill(new SolidBrush<TPixel>(color), shape);

4
src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs

@ -68,13 +68,13 @@ namespace ImageSharp.Drawing.Processors
try
{
if (targetImage.Bounds.Size != this.Size)
if (targetImage.Size() != this.Size)
{
targetImage = disposableImage = this.Image.Clone(x => x.Resize(this.Size.Width, this.Size.Height));
}
// Align start/end positions.
Rectangle bounds = this.Image.Bounds;
Rectangle bounds = this.Image.Bounds();
int minX = Math.Max(this.Location.X, sourceRectangle.X);
int maxX = Math.Min(this.Location.X + bounds.Width, sourceRectangle.Width);
maxX = Math.Min(this.Location.X + this.Size.Width, maxX);

16
src/ImageSharp.Drawing/Text/DrawText.Path.cs

@ -31,7 +31,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, TPixel color, IPath path)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, TPixel color, IPath path)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawText(text, font, color, path, TextGraphicsOptions.Default);
@ -50,7 +50,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, TPixel color, IPath path, TextGraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, TPixel color, IPath path, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawText(text, font, Brushes.Solid(color), null, path, options);
@ -68,7 +68,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPath path)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPath path)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawText(text, font, brush, path, TextGraphicsOptions.Default);
@ -87,7 +87,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPath path, TextGraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPath path, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawText(text, font, brush, null, path, options);
@ -105,7 +105,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, IPen<TPixel> pen, IPath path)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, IPen<TPixel> pen, IPath path)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawText(text, font, pen, path, TextGraphicsOptions.Default);
@ -124,7 +124,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, IPen<TPixel> pen, IPath path, TextGraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, IPen<TPixel> pen, IPath path, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawText(text, font, null, pen, path, options);
@ -143,7 +143,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, IPath path)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, IPath path)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawText(text, font, brush, pen, path, TextGraphicsOptions.Default);
@ -163,7 +163,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, IPath path, TextGraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, IPath path, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
float dpiX = DefaultTextDpi;

16
src/ImageSharp.Drawing/Text/DrawText.cs

@ -34,7 +34,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, TPixel color, PointF location)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, TPixel color, PointF location)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawText(text, font, color, location, TextGraphicsOptions.Default);
@ -53,7 +53,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, TPixel color, PointF location, TextGraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, TPixel color, PointF location, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawText(text, font, Brushes.Solid(color), null, location, options);
@ -71,7 +71,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, IBrush<TPixel> brush, PointF location)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, IBrush<TPixel> brush, PointF location)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawText(text, font, brush, location, TextGraphicsOptions.Default);
@ -90,7 +90,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, IBrush<TPixel> brush, PointF location, TextGraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, IBrush<TPixel> brush, PointF location, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawText(text, font, brush, null, location, options);
@ -108,7 +108,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, IPen<TPixel> pen, PointF location)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, IPen<TPixel> pen, PointF location)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawText(text, font, pen, location, TextGraphicsOptions.Default);
@ -127,7 +127,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, IPen<TPixel> pen, PointF location, TextGraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, IPen<TPixel> pen, PointF location, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawText(text, font, null, pen, location, options);
@ -146,7 +146,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, PointF location)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, PointF location)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawText(text, font, brush, pen, location, TextGraphicsOptions.Default);
@ -166,7 +166,7 @@ namespace ImageSharp
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageOperations<TPixel> DrawText<TPixel>(this IImageOperations<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, PointF location, TextGraphicsOptions options)
public static IImageProcessorApplicator<TPixel> DrawText<TPixel>(this IImageProcessorApplicator<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, PointF location, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
float dpiX = DefaultTextDpi;

32
src/ImageSharp/ApplyProcessors.cs

@ -22,14 +22,15 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to rotate, flip, or both.</param>
/// <param name="operations">The operations to perform on the source.</param>
public static void Mutate<TPixel>(this Image<TPixel> source, Action<IImageOperations<TPixel>> operations)
public static void Mutate<TPixel>(this Image<TPixel> source, Action<IImageProcessorApplicator<TPixel>> operations)
where TPixel : struct, IPixel<TPixel>
{
Guard.NotNull(operations, nameof(operations));
Guard.NotNull(source, nameof(source));
// TODO: add parameter to Configuration to configure how this is created, create an IImageOperationsFactory that cna be used to switch this out with a fake for testing
IImageOperations<TPixel> operationsRunner = source.Configuration.ImageOperationsProvider.CreateMutator(source);
IInternalImageProcessorApplicator<TPixel> operationsRunner = source.Configuration.ImageOperationsProvider.CreateImageOperations(source, true);
operations(operationsRunner);
operationsRunner.Apply();
}
/// <summary>
@ -42,10 +43,11 @@ namespace ImageSharp
where TPixel : struct, IPixel<TPixel>
{
Guard.NotNull(operations, nameof(operations));
Guard.NotNull(source, nameof(source));
// TODO: add parameter to Configuration to configure how this is created, create an IImageOperationsFactory that cna be used to switch this out with a fake for testing
IImageOperations<TPixel> operationsRunner = source.Configuration.ImageOperationsProvider.CreateMutator(source);
IInternalImageProcessorApplicator<TPixel> operationsRunner = source.Configuration.ImageOperationsProvider.CreateImageOperations(source, true);
operationsRunner.ApplyProcessors(operations);
operationsRunner.Apply();
}
/// <summary>
@ -55,16 +57,15 @@ namespace ImageSharp
/// <param name="source">The image to rotate, flip, or both.</param>
/// <param name="operations">The operations to perform on the source.</param>
/// <returns>Anew Image which has teh data from the <paramref name="source"/> but with the <paramref name="operations"/> applied.</returns>
public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, Action<IImageOperations<TPixel>> operations)
public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, Action<IImageProcessorApplicator<TPixel>> operations)
where TPixel : struct, IPixel<TPixel>
{
Guard.NotNull(operations, nameof(operations));
var generated = new Image<TPixel>(source);
Guard.NotNull(source, nameof(source));
// TODO: add parameter to Configuration to configure how this is created, create an IImageOperationsFactory that cna be used to switch this out with a fake for testing
IImageOperations<TPixel> operationsRunner = source.Configuration.ImageOperationsProvider.CreateMutator(generated);
IInternalImageProcessorApplicator<TPixel> operationsRunner = source.Configuration.ImageOperationsProvider.CreateImageOperations(source, false);
operations(operationsRunner);
return generated;
return operationsRunner.Apply();
}
/// <summary>
@ -78,12 +79,11 @@ namespace ImageSharp
where TPixel : struct, IPixel<TPixel>
{
Guard.NotNull(operations, nameof(operations));
var generated = new Image<TPixel>(source);
Guard.NotNull(source, nameof(source));
// TODO: add parameter to Configuration to configure how this is created, create an IImageOperationsFactory that cna be used to switch this out with a fake for testing
IImageOperations<TPixel> operationsRunner = source.Configuration.ImageOperationsProvider.CreateMutator(generated);
IInternalImageProcessorApplicator<TPixel> operationsRunner = source.Configuration.ImageOperationsProvider.CreateImageOperations(source, false);
operationsRunner.ApplyProcessors(operations);
return generated;
return operationsRunner.Apply();
}
/// <summary>
@ -93,10 +93,10 @@ namespace ImageSharp
/// <param name="source">The image to rotate, flip, or both.</param>
/// <param name="operations">The operations to perform on the source.</param>
/// <returns>returns the current optinoatins class to allow chaining of oprations.</returns>
public static IImageOperations<TPixel> ApplyProcessors<TPixel>(this IImageOperations<TPixel> source, params IImageProcessor<TPixel>[] operations)
public static IImageProcessorApplicator<TPixel> ApplyProcessors<TPixel>(this IImageProcessorApplicator<TPixel> source, params IImageProcessor<TPixel>[] operations)
where TPixel : struct, IPixel<TPixel>
{
foreach (var p in operations)
foreach (IImageProcessor<TPixel> p in operations)
{
source = source.ApplyProcessor(p);
}

2
src/ImageSharp/Configuration.cs

@ -111,7 +111,7 @@ namespace ImageSharp
/// <summary>
/// Gets or sets the image operations providers.
/// </summary>
internal IImageOperationsProvider ImageOperationsProvider { get; set; } = new DefaultImageOperationsProvider();
internal IImageProcessorApplicatorFactory ImageOperationsProvider { get; set; } = new DefaultImageOperationsProvider();
/// <summary>
/// Registers a new format provider.

72
src/ImageSharp/DefaultInternalImageProcessorApplicator.cs

@ -0,0 +1,72 @@
// <copyright file="DefaultInternalImageProcessorApplicator.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.Collections.Generic;
using ImageSharp.PixelFormats;
using ImageSharp.Processing;
using SixLabors.Primitives;
/// <summary>
/// The static collection of all the default image formats
/// </summary>
/// <typeparam name="TPixel">The pixel format</typeparam>
internal class DefaultInternalImageProcessorApplicator<TPixel> : IInternalImageProcessorApplicator<TPixel>
where TPixel : struct, IPixel<TPixel>
{
private readonly bool mutate;
private readonly Image<TPixel> source;
private Image<TPixel> destination;
/// <summary>
/// Initializes a new instance of the <see cref="DefaultInternalImageProcessorApplicator{TPixel}"/> class.
/// </summary>
/// <param name="source">The image.</param>
/// <param name="mutate">The mutate.</param>
public DefaultInternalImageProcessorApplicator(Image<TPixel> source, bool mutate)
{
this.mutate = mutate;
this.source = source;
if (this.mutate)
{
this.destination = source;
}
}
/// <inheritdoc/>
public Image<TPixel> Apply()
{
if (!this.mutate && this.destination == null)
{
// ensure we have cloned it if we are not mutating as we might have failed to register any Processors
this.destination = this.source.Clone();
}
return this.destination;
}
/// <inheritdoc/>
public IImageProcessorApplicator<TPixel> ApplyProcessor(IImageProcessor<TPixel> processor, Rectangle rectangle)
{
if (!this.mutate && this.destination == null)
{
// TODO check if the processor implements a special interface and if it does then allow it to take
// over and crereate the clone on behalf ImageOperations class.
this.destination = this.source.Clone();
}
processor.Apply(this.destination, rectangle);
return this;
}
/// <inheritdoc/>
public IImageProcessorApplicator<TPixel> ApplyProcessor(IImageProcessor<TPixel> processor)
{
return this.ApplyProcessor(processor, this.source.Bounds());
}
}
}

11
src/ImageSharp/IImageOperationsProvider.cs → src/ImageSharp/IImageProcessorApplicatorFactory.cs

@ -11,28 +11,29 @@ namespace ImageSharp
/// <summary>
/// Represents an interface that will create IImageOperations
/// </summary>
internal interface IImageOperationsProvider
internal interface IImageProcessorApplicatorFactory
{
/// <summary>
/// Called during Mutate operations to generate the imageoperations provider.
/// </summary>
/// <typeparam name="TPixel">The pixel format</typeparam>
/// <param name="source">The source image.</param>
/// <param name="mutate">A flag to determin with the image operations is allowed to mutate the source image or not.</param>
/// <returns>A new IImageOPeration</returns>
IImageOperations<TPixel> CreateMutator<TPixel>(Image<TPixel> source)
IInternalImageProcessorApplicator<TPixel> CreateImageOperations<TPixel>(Image<TPixel> source, bool mutate)
where TPixel : struct, IPixel<TPixel>;
}
/// <summary>
/// The default implmentation of IImageOperationsProvider
/// </summary>
internal class DefaultImageOperationsProvider : IImageOperationsProvider
internal class DefaultImageOperationsProvider : IImageProcessorApplicatorFactory
{
/// <inheritdoc/>
public IImageOperations<TPixel> CreateMutator<TPixel>(Image<TPixel> source)
public IInternalImageProcessorApplicator<TPixel> CreateImageOperations<TPixel>(Image<TPixel> source, bool mutate)
where TPixel : struct, IPixel<TPixel>
{
return new ImageOperations<TPixel>(source);
return new DefaultInternalImageProcessorApplicator<TPixel>(source, mutate);
}
}
}

22
src/ImageSharp/IImageOperations{TPixel}.cs → src/ImageSharp/IImageProcessorApplicator{TPixel}.cs

@ -1,4 +1,4 @@
// <copyright file="IImageFormat.cs" company="James Jackson-South">
// <copyright file="IImageProcessorApplicator.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
@ -15,7 +15,7 @@ namespace ImageSharp
/// An interface to queue up image operations.
/// </summary>
/// <typeparam name="TPixel">The pixel format</typeparam>
public interface IImageOperations<TPixel>
public interface IImageProcessorApplicator<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
@ -24,13 +24,27 @@ namespace ImageSharp
/// <param name="processor">The processor to apply</param>
/// <param name="rectangle">The area to apply it to</param>
/// <returns>returns the current optinoatins class to allow chaining of oprations.</returns>
IImageOperations<TPixel> ApplyProcessor(IImageProcessor<TPixel> processor, Rectangle rectangle);
IImageProcessorApplicator<TPixel> ApplyProcessor(IImageProcessor<TPixel> processor, Rectangle rectangle);
/// <summary>
/// Adds the processor to the current setr of image operations to be applied.
/// </summary>
/// <param name="processor">The processor to apply</param>
/// <returns>returns the current optinoatins class to allow chaining of oprations.</returns>
IImageOperations<TPixel> ApplyProcessor(IImageProcessor<TPixel> processor);
IImageProcessorApplicator<TPixel> ApplyProcessor(IImageProcessor<TPixel> processor);
}
/// <summary>
/// An internal interface to queue up image operations and have a method to apply them to and return a result
/// </summary>
/// <typeparam name="TPixel">The pixel format</typeparam>
public interface IInternalImageProcessorApplicator<TPixel> : IImageProcessorApplicator<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// Adds the processors to the current image
/// </summary>
/// <returns>returns the current image or a new image depending on withere this is alloed to mutate the source image.</returns>
Image<TPixel> Apply();
}
}

10
src/ImageSharp/Image/IImageBase.cs

@ -12,11 +12,6 @@ namespace ImageSharp
/// </summary>
public interface IImageBase
{
/// <summary>
/// Gets the <see cref="Rectangle"/> representing the bounds of the image.
/// </summary>
Rectangle Bounds { get; }
/// <summary>
/// Gets the width in pixels.
/// </summary>
@ -27,11 +22,6 @@ namespace ImageSharp
/// </summary>
int Height { get; }
/// <summary>
/// Gets the pixel ratio made up of the width and height.
/// </summary>
double PixelRatio { get; }
/// <summary>
/// Gets the configuration providing initialization code which allows extending the library.
/// </summary>

30
src/ImageSharp/Image/ImageBase{TPixel}.cs

@ -19,7 +19,6 @@ namespace ImageSharp
/// images in different pixel formats.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
[DebuggerDisplay("Image: {Width}x{Height}")]
public abstract class ImageBase<TPixel> : IImageBase<TPixel>
where TPixel : struct, IPixel<TPixel>
{
@ -105,12 +104,8 @@ namespace ImageSharp
// Rent then copy the pixels. Unsafe.CopyBlock gives us a nice speed boost here.
this.RentPixels();
using (PixelAccessor<TPixel> sourcePixels = other.Lock())
using (PixelAccessor<TPixel> target = this.Lock())
{
// Check we can do this without crashing
sourcePixels.CopyTo(target);
}
other.Pixels.CopyTo(this.Pixels);
}
/// <inheritdoc/>
@ -122,12 +117,6 @@ namespace ImageSharp
/// <inheritdoc/>
public int Height { get; private set; }
/// <inheritdoc/>
public double PixelRatio => (double)this.Width / this.Height;
/// <inheritdoc/>
public Rectangle Bounds => new Rectangle(0, 0, this.Width, this.Height);
/// <summary>
/// Gets the configuration providing initialization code which allows extending the library.
/// </summary>
@ -194,6 +183,15 @@ namespace ImageSharp
return this.Pixels.Slice((y * this.Width) + x, this.Width - x);
}
/// <summary>
/// Clones the image
/// </summary>
/// <returns>A new items which is a clone of the original.</returns>
public ImageBase<TPixel> Clone()
{
return this.CloneInternal();
}
/// <inheritdoc />
public void Dispose()
{
@ -246,6 +244,12 @@ namespace ImageSharp
this.PixelBuffer = newPixels;
}
/// <summary>
/// Clones the image
/// </summary>
/// <returns>A new items which is a clone of the original.</returns>
protected abstract ImageBase<TPixel> CloneInternal();
/// <summary>
/// Copies the properties from the other <see cref="IImageBase"/>.
/// </summary>

153
src/ImageSharp/Image/ImageExtensions.cs

@ -0,0 +1,153 @@
// <copyright file="ImageBase{TPixel}.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using ImageSharp.Formats;
using ImageSharp.PixelFormats;
using SixLabors.Primitives;
/// <summary>
/// Extension methods over Image{TPixel}
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Gets the bounds of the image.
/// </summary>
/// <typeparam name="TPixel">The Pixel format.</typeparam>
/// <param name="source">The source image</param>
/// <returns>Returns the bounds of the image</returns>
public static Rectangle Bounds<TPixel>(this ImageBase<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> new Rectangle(0, 0, source.Width, source.Height);
/// <summary>
/// Gets the size of the image.
/// </summary>
/// <typeparam name="TPixel">The Pixel format.</typeparam>
/// <param name="source">The source image</param>
/// <returns>Returns the bounds of the image</returns>
public static Size Size<TPixel>(this ImageBase<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> new Size(source.Width, source.Height);
#if !NETSTANDARD1_1
/// <summary>
/// Saves the image to the given stream using the currently loaded image format.
/// </summary>
/// <typeparam name="TPixel">The Pixel format.</typeparam>
/// <param name="source">The source image</param>
/// <param name="filePath">The file path to save the image to.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
public static void Save<TPixel>(this Image<TPixel> source, string filePath)
where TPixel : struct, IPixel<TPixel>
{
Guard.NotNullOrEmpty(filePath, nameof(filePath));
string ext = Path.GetExtension(filePath).Trim('.');
IImageFormat format = source.Configuration.FindFormatByFileExtensions(ext);
if (format == null)
{
var stringBuilder = new StringBuilder();
stringBuilder.AppendLine($"Can't find a format that is associated with the file extention '{ext}'. Registered formats with there extensions include:");
foreach (IImageFormat fmt in source.Configuration.ImageFormats)
{
stringBuilder.AppendLine($" - {fmt.Name} : {string.Join(", ", fmt.FileExtensions)}");
}
throw new NotSupportedException(stringBuilder.ToString());
}
IImageEncoder encoder = source.Configuration.FindEncoder(format);
if (encoder == null)
{
var stringBuilder = new StringBuilder();
stringBuilder.AppendLine($"Can't find encoder for file extention '{ext}' using image format '{format.Name}'. Registered encoders include:");
foreach (KeyValuePair<IImageFormat, IImageEncoder> enc in source.Configuration.ImageEncoders)
{
stringBuilder.AppendLine($" - {enc.Key} : {enc.Value.GetType().Name}");
}
throw new NotSupportedException(stringBuilder.ToString());
}
source.Save(filePath, encoder);
}
/// <summary>
/// Saves the image to the given stream using the currently loaded image format.
/// </summary>
/// <typeparam name="TPixel">The Pixel format.</typeparam>
/// <param name="source">The source image</param>
/// <param name="filePath">The file path to save the image to.</param>
/// <param name="encoder">The encoder to save the image with.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the encoder is null.</exception>
public static void Save<TPixel>(this Image<TPixel> source, string filePath, IImageEncoder encoder)
where TPixel : struct, IPixel<TPixel>
{
Guard.NotNull(encoder, nameof(encoder));
using (Stream fs = source.Configuration.FileSystem.Create(filePath))
{
source.Save(fs, encoder);
}
}
#endif
/// <summary>
/// Saves the image to the given stream using the currently loaded image format.
/// </summary>
/// <typeparam name="TPixel">The Pixel format.</typeparam>
/// <param name="source">The source image</param>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="format">The format to save the image to.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
public static void Save<TPixel>(this Image<TPixel> source, Stream stream, IImageFormat format)
where TPixel : struct, IPixel<TPixel>
{
Guard.NotNull(format, nameof(format));
IImageEncoder encoder = source.Configuration.FindEncoder(format);
if (encoder == null)
{
var stringBuilder = new StringBuilder();
stringBuilder.AppendLine("Can't find encoder for provided mime type. Available encoded:");
foreach (KeyValuePair<IImageFormat, IImageEncoder> val in source.Configuration.ImageEncoders)
{
stringBuilder.AppendLine($" - {val.Key.Name} : {val.Value.GetType().Name}");
}
throw new NotSupportedException(stringBuilder.ToString());
}
source.Save(stream, encoder);
}
/// <summary>
/// Returns a Base64 encoded string from the given image.
/// </summary>
/// <example><see href="data:image/gif;base64,R0lGODlhAQABAIABAEdJRgAAACwAAAAAAQABAAACAkQBAA=="/></example>
/// <typeparam name="TPixel">The Pixel format.</typeparam>
/// <param name="source">The source image</param>
/// <param name="format">The format.</param>
/// <returns>The <see cref="string"/></returns>
public static string ToBase64String<TPixel>(this Image<TPixel> source, IImageFormat format)
where TPixel : struct, IPixel<TPixel>
{
using (var stream = new MemoryStream())
{
source.Save(stream, format);
stream.Flush();
return $"data:{format.DefaultMimeType};base64,{Convert.ToBase64String(stream.ToArray())}";
}
}
}
}

44
src/ImageSharp/Image/ImageFrame{TPixel}.cs

@ -14,39 +14,49 @@ namespace ImageSharp
/// Represents a single frame in a animation.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
public class ImageFrame<TPixel> : ImageBase<TPixel>, IImageFrame
public sealed class ImageFrame<TPixel> : ImageBase<TPixel>, IImageFrame
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// Initializes a new instance of the <see cref="ImageFrame{TPixel}"/> class.
/// </summary>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <param name="configuration">
/// The configuration providing initialization code which allows extending the library.
/// </param>
public ImageFrame(int width, int height, Configuration configuration = null)
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
public ImageFrame(Configuration configuration, int width, int height)
: base(configuration, width, height)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ImageFrame{TPixel}"/> class.
/// </summary>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
public ImageFrame(int width, int height)
: this(null, width, height)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ImageFrame{TPixel}"/> class.
/// </summary>
/// <param name="image">The image to create the frame from.</param>
public ImageFrame(ImageFrame<TPixel> image)
internal ImageFrame(ImageBase<TPixel> image)
: base(image)
{
this.CopyProperties(image);
}
/// <summary>
/// Initializes a new instance of the <see cref="ImageFrame{TPixel}"/> class.
/// </summary>
/// <param name="image">The image to create the frame from.</param>
public ImageFrame(ImageBase<TPixel> image)
private ImageFrame(ImageFrame<TPixel> image)
: base(image)
{
this.CopyProperties(image);
}
/// <summary>
@ -63,15 +73,19 @@ namespace ImageSharp
/// <summary>
/// Returns a copy of the image frame in the given pixel format.
/// </summary>
/// <param name="scaleFunc">A function that allows for the correction of vector scaling between unknown color formats.</param>
/// <typeparam name="TPixel2">The pixel format.</typeparam>
/// <returns>The <see cref="ImageFrame{TPixel2}"/></returns>
public ImageFrame<TPixel2> To<TPixel2>(Func<Vector4, Vector4> scaleFunc = null)
public ImageFrame<TPixel2> CloneAs<TPixel2>()
where TPixel2 : struct, IPixel<TPixel2>
{
scaleFunc = PackedPixelConverterHelper.ComputeScaleFunction<TPixel, TPixel2>(scaleFunc);
if (typeof(TPixel2) == typeof(TPixel))
{
return this.Clone() as ImageFrame<TPixel2>;
}
ImageFrame<TPixel2> target = new ImageFrame<TPixel2>(this.Width, this.Height, this.Configuration);
Func<Vector4, Vector4> scaleFunc = PackedPixelConverterHelper.ComputeScaleFunction<TPixel, TPixel2>();
var target = new ImageFrame<TPixel2>(this.Configuration, this.Width, this.Height);
target.CopyProperties(this);
using (PixelAccessor<TPixel> pixels = this.Lock())
@ -99,11 +113,17 @@ namespace ImageSharp
/// Clones the current instance.
/// </summary>
/// <returns>The <see cref="ImageFrame{TPixel}"/></returns>
internal virtual ImageFrame<TPixel> Clone()
public new ImageFrame<TPixel> Clone()
{
return new ImageFrame<TPixel>(this);
}
/// <inheritdoc/>
protected override ImageBase<TPixel> CloneInternal()
{
return this.Clone();
}
/// <summary>
/// Copies the properties from the other <see cref="IImageFrame"/>.
/// </summary>

32
src/ImageSharp/Image/ImageProcessingExtensions.cs

@ -1,32 +0,0 @@
// <copyright file="ImageProcessingExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using ImageSharp.PixelFormats;
using ImageSharp.Processing;
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Applies the processor to the image.
/// <remarks>This method does not resize the target image.</remarks>
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="processor">The processor to apply to the image.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Apply<TPixel>(this IImageOperations<TPixel> source, IImageProcessor<TPixel> processor)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(processor);
return source;
}
}
}

204
src/ImageSharp/Image/Image{TPixel}.cs

@ -22,8 +22,7 @@ namespace ImageSharp
/// Encapsulates an image, which consists of the pixel data for a graphics image and its attributes.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
[DebuggerDisplay("Image: {Width}x{Height}")]
public class Image<TPixel> : ImageBase<TPixel>, IImage
public sealed class Image<TPixel> : ImageBase<TPixel>, IImage
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
@ -51,20 +50,36 @@ namespace ImageSharp
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Image{TPixel}"/> class
/// with the height and the width of the image.
/// </summary>
/// <param name="configuration">
/// The configuration providing initialization code which allows extending the library.
/// </param>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <param name="metadata">The images metadata.</param>
internal Image(Configuration configuration, int width, int height, ImageMetaData metadata)
: base(configuration, width, height)
{
this.MetaData = metadata ?? new ImageMetaData();
}
/// <summary>
/// Initializes a new instance of the <see cref="Image{TPixel}"/> class
/// by making a copy from another image.
/// </summary>
/// <param name="other">The other image, where the clone should be made from.</param>
/// <exception cref="System.ArgumentNullException"><paramref name="other"/> is null.</exception>
public Image(Image<TPixel> other)
private Image(Image<TPixel> other)
: base(other)
{
foreach (ImageFrame<TPixel> frame in other.Frames)
{
if (frame != null)
{
this.Frames.Add(new ImageFrame<TPixel>(frame));
this.Frames.Add(frame.Clone());
}
}
@ -77,101 +92,22 @@ namespace ImageSharp
/// </summary>
/// <param name="other">The other image, where the clone should be made from.</param>
/// <exception cref="System.ArgumentNullException"><paramref name="other"/> is null.</exception>
public Image(ImageBase<TPixel> other)
private Image(ImageBase<TPixel> other)
: base(other)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Image{TPixel}"/> class
/// with the height and the width of the image.
/// </summary>
/// <param name="configuration">
/// The configuration providing initialization code which allows extending the library.
/// </param>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <param name="metadata">The images metadata.</param>
internal Image(Configuration configuration, int width, int height, ImageMetaData metadata)
: base(configuration, width, height)
{
this.MetaData = metadata ?? new ImageMetaData();
}
/// <summary>
/// Gets the meta data of the image.
/// </summary>
public ImageMetaData MetaData { get; private set; } = new ImageMetaData();
/// <summary>
/// Gets the width of the image in inches. It is calculated as the width of the image
/// in pixels multiplied with the density. When the density is equals or less than zero
/// the default value is used.
/// </summary>
/// <value>The width of the image in inches.</value>
public double InchWidth => this.Width / this.MetaData.HorizontalResolution;
/// <summary>
/// Gets the height of the image in inches. It is calculated as the height of the image
/// in pixels multiplied with the density. When the density is equals or less than zero
/// the default value is used.
/// </summary>
/// <value>The height of the image in inches.</value>
public double InchHeight => this.Height / this.MetaData.VerticalResolution;
/// <summary>
/// Gets a value indicating whether this image is animated.
/// </summary>
/// <value>
/// <c>True</c> if this image is animated; otherwise, <c>false</c>.
/// </value>
public bool IsAnimated => this.Frames.Count > 0;
/// <summary>
/// Gets the other frames for the animation.
/// Gets the other frames associated with this image.
/// </summary>
/// <value>The list of frame images.</value>
public IList<ImageFrame<TPixel>> Frames { get; } = new List<ImageFrame<TPixel>>();
/// <summary>
/// Applies the processor to the image.
/// </summary>
/// <param name="processor">The processor to apply to the image.</param>
/// <param name="rectangle">The <see cref="Rectangle" /> structure that specifies the portion of the image object to draw.</param>
public virtual void ApplyProcessor(IImageProcessor<TPixel> processor, Rectangle rectangle)
{
// we want to put this on on here as it gives us a really go place to test/verify processor settings
processor.Apply(this, rectangle);
}
/// <summary>
/// Saves the image to the given stream using the currently loaded image format.
/// </summary>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="format">The format to save the image to.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public Image<TPixel> Save(Stream stream, IImageFormat format)
{
Guard.NotNull(format, nameof(format));
IImageEncoder encoder = this.Configuration.FindEncoder(format);
if (encoder == null)
{
var stringBuilder = new StringBuilder();
stringBuilder.AppendLine("Can't find encoder for provided mime type. Available encoded:");
foreach (KeyValuePair<IImageFormat, IImageEncoder> val in this.Configuration.ImageEncoders)
{
stringBuilder.AppendLine($" - {val.Key.Name} : {val.Value.GetType().Name}");
}
throw new NotSupportedException(stringBuilder.ToString());
}
return this.Save(stream, encoder);
}
/// <summary>
/// Saves the image to the given stream using the given image encoder.
/// </summary>
@ -191,70 +127,11 @@ namespace ImageSharp
return this;
}
#if !NETSTANDARD1_1
/// <summary>
/// Saves the image to the given stream using the currently loaded image format.
/// </summary>
/// <param name="filePath">The file path to save the image to.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public Image<TPixel> Save(string filePath)
{
Guard.NotNullOrEmpty(filePath, nameof(filePath));
string ext = Path.GetExtension(filePath).Trim('.');
var format = this.Configuration.FindFormatByFileExtensions(ext);
if (format == null)
{
var stringBuilder = new StringBuilder();
stringBuilder.AppendLine($"Can't find a format that is associated with the file extention '{ext}'. Registered formats with there extensions include:");
foreach (IImageFormat fmt in this.Configuration.ImageFormats)
{
stringBuilder.AppendLine($" - {fmt.Name} : {string.Join(", ", fmt.FileExtensions)}");
}
throw new NotSupportedException(stringBuilder.ToString());
}
IImageEncoder encoder = this.Configuration.FindEncoder(format);
if (encoder == null)
{
var stringBuilder = new StringBuilder();
stringBuilder.AppendLine($"Can't find encoder for file extention '{ext}' using image format '{format.Name}'. Registered encoders include:");
foreach (KeyValuePair<IImageFormat, IImageEncoder> enc in this.Configuration.ImageEncoders)
{
stringBuilder.AppendLine($" - {enc.Key} : {enc.Value.GetType().Name}");
}
throw new NotSupportedException(stringBuilder.ToString());
}
return this.Save(filePath, encoder);
}
/// <summary>
/// Saves the image to the given stream using the currently loaded image format.
/// </summary>
/// <param name="filePath">The file path to save the image to.</param>
/// <param name="encoder">The encoder to save the image with.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the encoder is null.</exception>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public Image<TPixel> Save(string filePath, IImageEncoder encoder)
{
Guard.NotNull(encoder, nameof(encoder));
using (Stream fs = this.Configuration.FileSystem.Create(filePath))
{
return this.Save(fs, encoder);
}
}
#endif
/// <summary>
/// Clones the current image
/// </summary>
/// <returns>Returns a new image with all the same metadata as the original.</returns>
public Image<TPixel> Clone()
public new Image<TPixel> Clone()
{
return new Image<TPixel>(this);
}
@ -265,32 +142,21 @@ namespace ImageSharp
return $"Image<{typeof(TPixel).Name}>: {this.Width}x{this.Height}";
}
/// <summary>
/// Returns a Base64 encoded string from the given image.
/// </summary>
/// <example><see href="data:image/gif;base64,R0lGODlhAQABAIABAEdJRgAAACwAAAAAAQABAAACAkQBAA=="/></example>
/// <param name="format">The format.</param>
/// <returns>The <see cref="string"/></returns>
public string ToBase64String(IImageFormat format)
{
using (var stream = new MemoryStream())
{
this.Save(stream, format);
stream.Flush();
return $"data:{format.DefaultMimeType};base64,{Convert.ToBase64String(stream.ToArray())}";
}
}
/// <summary>
/// Returns a copy of the image in the given pixel format.
/// </summary>
/// <param name="scaleFunc">A function that allows for the correction of vector scaling between unknown color formats.</param>
/// <typeparam name="TPixel2">The pixel format.</typeparam>
/// <returns>The <see cref="Image{TPixel2}"/></returns>
public Image<TPixel2> To<TPixel2>(Func<Vector4, Vector4> scaleFunc = null)
public Image<TPixel2> CloneAs<TPixel2>()
where TPixel2 : struct, IPixel<TPixel2>
{
scaleFunc = PackedPixelConverterHelper.ComputeScaleFunction<TPixel, TPixel2>(scaleFunc);
if (typeof(TPixel2) == typeof(TPixel))
{
// short circuit when same pixel types
return this.Clone() as Image<TPixel2>;
}
Func<Vector4, Vector4> scaleFunc = PackedPixelConverterHelper.ComputeScaleFunction<TPixel, TPixel2>();
var target = new Image<TPixel2>(this.Configuration, this.Width, this.Height);
target.CopyProperties(this);
@ -315,7 +181,7 @@ namespace ImageSharp
for (int i = 0; i < this.Frames.Count; i++)
{
target.Frames.Add(this.Frames[i].To<TPixel2>());
target.Frames.Add(this.Frames[i].CloneAs<TPixel2>());
}
return target;
@ -325,7 +191,7 @@ namespace ImageSharp
/// Creates a new <see cref="ImageFrame{TPixel}"/> from this instance
/// </summary>
/// <returns>The <see cref="ImageFrame{TPixel}"/></returns>
internal virtual ImageFrame<TPixel> ToFrame()
internal ImageFrame<TPixel> ToFrame()
{
return new ImageFrame<TPixel>(this);
}
@ -342,6 +208,12 @@ namespace ImageSharp
base.Dispose(disposing);
}
/// <inheritdoc/>
protected override ImageBase<TPixel> CloneInternal()
{
return this.Clone();
}
/// <summary>
/// Copies the properties from the other <see cref="IImage"/>.
/// </summary>

62
src/ImageSharp/ImageOperations.cs

@ -1,62 +0,0 @@
// <copyright file="IImageFormat.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System.Collections.Generic;
using ImageSharp.PixelFormats;
using ImageSharp.Processing;
using SixLabors.Primitives;
/// <summary>
/// The static collection of all the default image formats
/// </summary>
/// <typeparam name="TPixel">The pixel format</typeparam>
internal class ImageOperations<TPixel> : IImageOperations<TPixel>
where TPixel : struct, IPixel<TPixel>
{
private readonly Image<TPixel> image;
/// <summary>
/// Initializes a new instance of the <see cref="ImageOperations{TPixel}"/> class.
/// </summary>
/// <param name="image">The image.</param>
public ImageOperations(Image<TPixel> image)
{
this.image = image;
}
/// <inheritdoc/>
public IImageOperations<TPixel> ApplyProcessor(IImageProcessor<TPixel> processor, Rectangle rectangle)
{
// TODO : make this queue, and allow special processors managage the cloing operation for 'generate'
// to allow things like resize to not need to retain an extra copy of image data in memory, and to
// prevent an pixel copy operation
this.image.ApplyProcessor(processor, rectangle);
return this;
}
/// <inheritdoc/>
public IImageOperations<TPixel> ApplyProcessor(IImageProcessor<TPixel> processor)
{
return this.ApplyProcessor(processor, this.image.Bounds);
}
/// <summary>
/// Applies a bluck colelctino of pressorce at once
/// </summary>
/// <param name="processors">Processors to apply</param>
/// <returns>this </returns>
public IImageOperations<TPixel> ApplyProcessors(IEnumerable<IImageProcessor<TPixel>> processors)
{
foreach (var processor in processors)
{
return this.ApplyProcessor(processor);
}
return this;
}
}
}

9
src/ImageSharp/PixelFormats/PackedPixelConverterHelper.cs

@ -21,18 +21,11 @@ namespace ImageSharp.PixelFormats
/// <summary>
/// Returns the correct scaling function for the given types The compute scale function.
/// </summary>
/// <param name="scaleFunc">The scale function.</param>
/// <typeparam name="TPixel">The source pixel format.</typeparam>
/// <typeparam name="TPixel2">The target pixel format.</typeparam>
/// <returns>The <see cref="Func{Vector4,Vector4}"/></returns>
public static Func<Vector4, Vector4> ComputeScaleFunction<TPixel, TPixel2>(Func<Vector4, Vector4> scaleFunc)
public static Func<Vector4, Vector4> ComputeScaleFunction<TPixel, TPixel2>()
{
// Custom type with a custom function.
if (scaleFunc != null)
{
return scaleFunc;
}
Type source = typeof(TPixel);
Type target = typeof(TPixel2);

4
src/ImageSharp/Processing/Binarization/BinaryThreshold.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> BinaryThreshold<TPixel>(this IImageOperations<TPixel> source, float threshold)
public static IImageProcessorApplicator<TPixel> BinaryThreshold<TPixel>(this IImageProcessorApplicator<TPixel> source, float threshold)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new BinaryThresholdProcessor<TPixel>(threshold));
@ -41,7 +41,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> BinaryThreshold<TPixel>(this IImageOperations<TPixel> source, float threshold, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> BinaryThreshold<TPixel>(this IImageProcessorApplicator<TPixel> source, float threshold, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new BinaryThresholdProcessor<TPixel>(threshold), rectangle);

12
src/ImageSharp/Processing/Binarization/Dither.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="dither">The ordered ditherer.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Dither<TPixel>(this IImageOperations<TPixel> source, IOrderedDither dither)
public static IImageProcessorApplicator<TPixel> Dither<TPixel>(this IImageProcessorApplicator<TPixel> source, IOrderedDither dither)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new OrderedDitherProcessor<TPixel>(dither, 0));
@ -39,7 +39,7 @@ namespace ImageSharp
/// <param name="dither">The ordered ditherer.</param>
/// <param name="index">The component index to test the threshold against. Must range from 0 to 3.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Dither<TPixel>(this IImageOperations<TPixel> source, IOrderedDither dither, int index)
public static IImageProcessorApplicator<TPixel> Dither<TPixel>(this IImageProcessorApplicator<TPixel> source, IOrderedDither dither, int index)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new OrderedDitherProcessor<TPixel>(dither, index));
@ -56,7 +56,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Dither<TPixel>(this IImageOperations<TPixel> source, IOrderedDither dither, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Dither<TPixel>(this IImageProcessorApplicator<TPixel> source, IOrderedDither dither, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new OrderedDitherProcessor<TPixel>(dither, 0), rectangle);
@ -74,7 +74,7 @@ namespace ImageSharp
/// </param>
/// <param name="index">The component index to test the threshold against. Must range from 0 to 3.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Dither<TPixel>(this IImageOperations<TPixel> source, IOrderedDither dither, Rectangle rectangle, int index)
public static IImageProcessorApplicator<TPixel> Dither<TPixel>(this IImageProcessorApplicator<TPixel> source, IOrderedDither dither, Rectangle rectangle, int index)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new OrderedDitherProcessor<TPixel>(dither, index), rectangle);
@ -89,7 +89,7 @@ namespace ImageSharp
/// <param name="diffuser">The diffusion algorithm to apply.</param>
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Dither<TPixel>(this IImageOperations<TPixel> source, IErrorDiffuser diffuser, float threshold)
public static IImageProcessorApplicator<TPixel> Dither<TPixel>(this IImageProcessorApplicator<TPixel> source, IErrorDiffuser diffuser, float threshold)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new ErrorDiffusionDitherProcessor<TPixel>(diffuser, threshold));
@ -107,7 +107,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Dither<TPixel>(this IImageOperations<TPixel> source, IErrorDiffuser diffuser, float threshold, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Dither<TPixel>(this IImageProcessorApplicator<TPixel> source, IErrorDiffuser diffuser, float threshold, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new ErrorDiffusionDitherProcessor<TPixel>(diffuser, threshold), rectangle);

4
src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> BlackWhite<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> BlackWhite<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new BlackWhiteProcessor<TPixel>());
@ -40,7 +40,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> BlackWhite<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> BlackWhite<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new BlackWhiteProcessor<TPixel>(), rectangle);

4
src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs

@ -25,7 +25,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="colorBlindness">The type of color blindness simulator to apply.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> ColorBlindness<TPixel>(this IImageOperations<TPixel> source, ColorBlindness colorBlindness)
public static IImageProcessorApplicator<TPixel> ColorBlindness<TPixel>(this IImageProcessorApplicator<TPixel> source, ColorBlindness colorBlindness)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(GetProcessor<TPixel>(colorBlindness));
@ -42,7 +42,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> ColorBlindness<TPixel>(this IImageOperations<TPixel> source, ColorBlindness colorBlindness, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> ColorBlindness<TPixel>(this IImageProcessorApplicator<TPixel> source, ColorBlindness colorBlindness, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(GetProcessor<TPixel>(colorBlindness), rectangle);

8
src/ImageSharp/Processing/ColorMatrix/Grayscale.cs

@ -22,7 +22,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Grayscale<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> Grayscale<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
{
return Grayscale(source, GrayscaleMode.Bt709);
@ -35,7 +35,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="mode">The formula to apply to perform the operation.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Grayscale<TPixel>(this IImageOperations<TPixel> source, GrayscaleMode mode)
public static IImageProcessorApplicator<TPixel> Grayscale<TPixel>(this IImageProcessorApplicator<TPixel> source, GrayscaleMode mode)
where TPixel : struct, IPixel<TPixel>
{
IImageProcessor<TPixel> processor = mode == GrayscaleMode.Bt709
@ -55,7 +55,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Grayscale<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Grayscale<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
return Grayscale(source, GrayscaleMode.Bt709, rectangle);
@ -71,7 +71,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Grayscale<TPixel>(this IImageOperations<TPixel> source, GrayscaleMode mode, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Grayscale<TPixel>(this IImageProcessorApplicator<TPixel> source, GrayscaleMode mode, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
IImageProcessor<TPixel> processor = mode == GrayscaleMode.Bt709

4
src/ImageSharp/Processing/ColorMatrix/Hue.cs

@ -25,7 +25,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="degrees">The angle in degrees to adjust the image.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Hue<TPixel>(this IImageOperations<TPixel> source, float degrees)
public static IImageProcessorApplicator<TPixel> Hue<TPixel>(this IImageProcessorApplicator<TPixel> source, float degrees)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new HueProcessor<TPixel>(degrees));
@ -42,7 +42,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Hue<TPixel>(this IImageOperations<TPixel> source, float degrees, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Hue<TPixel>(this IImageProcessorApplicator<TPixel> source, float degrees, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new HueProcessor<TPixel>(degrees), rectangle);

4
src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Kodachrome<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> Kodachrome<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new KodachromeProcessor<TPixel>());
@ -40,7 +40,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Kodachrome<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Kodachrome<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new KodachromeProcessor<TPixel>(), rectangle);

8
src/ImageSharp/Processing/ColorMatrix/Lomograph.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Lomograph<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> Lomograph<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
{
return Lomograph(source, GraphicsOptions.Default);
@ -39,7 +39,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Lomograph<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Lomograph<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
return Lomograph(source, rectangle, GraphicsOptions.Default);
@ -52,7 +52,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Lomograph<TPixel>(this IImageOperations<TPixel> source, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Lomograph<TPixel>(this IImageProcessorApplicator<TPixel> source, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new LomographProcessor<TPixel>(options));
@ -69,7 +69,7 @@ namespace ImageSharp
/// </param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Lomograph<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Lomograph<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new LomographProcessor<TPixel>(options), rectangle);

8
src/ImageSharp/Processing/ColorMatrix/Polaroid.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Polaroid<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> Polaroid<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
{
return Polaroid(source, GraphicsOptions.Default);
@ -39,7 +39,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Polaroid<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Polaroid<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
return Polaroid(source, rectangle, GraphicsOptions.Default);
@ -52,7 +52,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Polaroid<TPixel>(this IImageOperations<TPixel> source, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Polaroid<TPixel>(this IImageProcessorApplicator<TPixel> source, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new PolaroidProcessor<TPixel>(options));
@ -69,7 +69,7 @@ namespace ImageSharp
/// </param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Polaroid<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Polaroid<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new PolaroidProcessor<TPixel>(options), rectangle);

4
src/ImageSharp/Processing/ColorMatrix/Saturation.cs

@ -25,7 +25,7 @@ namespace ImageSharp
/// <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>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Saturation<TPixel>(this IImageOperations<TPixel> source, int amount)
public static IImageProcessorApplicator<TPixel> Saturation<TPixel>(this IImageProcessorApplicator<TPixel> source, int amount)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new SaturationProcessor<TPixel>(amount));
@ -42,7 +42,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Saturation<TPixel>(this IImageOperations<TPixel> source, int amount, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Saturation<TPixel>(this IImageProcessorApplicator<TPixel> source, int amount, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(new SaturationProcessor<TPixel>(amount), rectangle);

4
src/ImageSharp/Processing/ColorMatrix/Sepia.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Sepia<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> Sepia<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new SepiaProcessor<TPixel>());
@ -37,7 +37,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Sepia<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Sepia<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new SepiaProcessor<TPixel>(), rectangle);
}

6
src/ImageSharp/Processing/Convolution/BoxBlur.cs

@ -23,7 +23,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> BoxBlur<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> BoxBlur<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new BoxBlurProcessor<TPixel>(7));
@ -34,7 +34,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="radius">The 'radius' value representing the size of the area to sample.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> BoxBlur<TPixel>(this IImageOperations<TPixel> source, int radius)
public static IImageProcessorApplicator<TPixel> BoxBlur<TPixel>(this IImageProcessorApplicator<TPixel> source, int radius)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new BoxBlurProcessor<TPixel>(radius));
@ -48,7 +48,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> BoxBlur<TPixel>(this IImageOperations<TPixel> source, int radius, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> BoxBlur<TPixel>(this IImageProcessorApplicator<TPixel> source, int radius, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new BoxBlurProcessor<TPixel>(radius), rectangle);
}

14
src/ImageSharp/Processing/Convolution/DetectEdges.cs

@ -25,7 +25,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DetectEdges<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> DetectEdges<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
{
return DetectEdges(source, new SobelProcessor<TPixel> { Grayscale = true });
@ -41,7 +41,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DetectEdges<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> DetectEdges<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
return DetectEdges(source, rectangle, new SobelProcessor<TPixel> { Grayscale = true });
@ -54,7 +54,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="filter">The filter for detecting edges.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DetectEdges<TPixel>(this IImageOperations<TPixel> source, EdgeDetection filter)
public static IImageProcessorApplicator<TPixel> DetectEdges<TPixel>(this IImageProcessorApplicator<TPixel> source, EdgeDetection filter)
where TPixel : struct, IPixel<TPixel>
=> DetectEdges(source, GetProcessor<TPixel>(filter, true));
@ -66,7 +66,7 @@ namespace ImageSharp
/// <param name="filter">The filter for detecting edges.</param>
/// <param name="grayscale">Whether to convert the image to Grayscale first. Defaults to true.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DetectEdges<TPixel>(this IImageOperations<TPixel> source, EdgeDetection filter, bool grayscale)
public static IImageProcessorApplicator<TPixel> DetectEdges<TPixel>(this IImageProcessorApplicator<TPixel> source, EdgeDetection filter, bool grayscale)
where TPixel : struct, IPixel<TPixel>
=> DetectEdges(source, GetProcessor<TPixel>(filter, grayscale));
@ -81,7 +81,7 @@ namespace ImageSharp
/// </param>
/// <param name="grayscale">Whether to convert the image to Grayscale first. Defaults to true.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DetectEdges<TPixel>(this IImageOperations<TPixel> source, EdgeDetection filter, Rectangle rectangle, bool grayscale = true)
public static IImageProcessorApplicator<TPixel> DetectEdges<TPixel>(this IImageProcessorApplicator<TPixel> source, EdgeDetection filter, Rectangle rectangle, bool grayscale = true)
where TPixel : struct, IPixel<TPixel>
=> DetectEdges(source, rectangle, GetProcessor<TPixel>(filter, grayscale));
@ -92,7 +92,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="filter">The filter for detecting edges.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DetectEdges<TPixel>(this IImageOperations<TPixel> source, IEdgeDetectorProcessor<TPixel> filter)
public static IImageProcessorApplicator<TPixel> DetectEdges<TPixel>(this IImageProcessorApplicator<TPixel> source, IEdgeDetectorProcessor<TPixel> filter)
where TPixel : struct, IPixel<TPixel>
{
return source.ApplyProcessor(filter);
@ -108,7 +108,7 @@ namespace ImageSharp
/// </param>
/// <param name="filter">The filter for detecting edges.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> DetectEdges<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle, IEdgeDetectorProcessor<TPixel> filter)
public static IImageProcessorApplicator<TPixel> DetectEdges<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle, IEdgeDetectorProcessor<TPixel> filter)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(filter, rectangle);

6
src/ImageSharp/Processing/Convolution/GaussianBlur.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> GaussianBlur<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> GaussianBlur<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new GaussianBlurProcessor<TPixel>(3f));
@ -35,7 +35,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="sigma">The 'sigma' value representing the weight of the blur.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> GaussianBlur<TPixel>(this IImageOperations<TPixel> source, float sigma)
public static IImageProcessorApplicator<TPixel> GaussianBlur<TPixel>(this IImageProcessorApplicator<TPixel> source, float sigma)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new GaussianBlurProcessor<TPixel>(sigma));
@ -49,7 +49,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> GaussianBlur<TPixel>(this IImageOperations<TPixel> source, float sigma, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> GaussianBlur<TPixel>(this IImageProcessorApplicator<TPixel> source, float sigma, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new GaussianBlurProcessor<TPixel>(sigma), rectangle);
}

6
src/ImageSharp/Processing/Convolution/GaussianSharpen.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> GaussianSharpen<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> GaussianSharpen<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new GaussianSharpenProcessor<TPixel>(3f));
@ -35,7 +35,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="sigma">The 'sigma' value representing the weight of the blur.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> GaussianSharpen<TPixel>(this IImageOperations<TPixel> source, float sigma)
public static IImageProcessorApplicator<TPixel> GaussianSharpen<TPixel>(this IImageProcessorApplicator<TPixel> source, float sigma)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new GaussianSharpenProcessor<TPixel>(sigma));
@ -49,7 +49,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> GaussianSharpen<TPixel>(this IImageOperations<TPixel> source, float sigma, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> GaussianSharpen<TPixel>(this IImageProcessorApplicator<TPixel> source, float sigma, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new GaussianSharpenProcessor<TPixel>(sigma), rectangle);
}

2
src/ImageSharp/Processing/Delegate.cs

@ -23,7 +23,7 @@ namespace ImageSharp
/// <param name="source">The image to rotate, flip, or both.</param>
/// <param name="operation">The operations to perform on the source.</param>
/// <returns>returns the current optinoatins class to allow chaining of oprations.</returns>
public static IImageOperations<TPixel> Run<TPixel>(this IImageOperations<TPixel> source, Action<Image<TPixel>> operation)
public static IImageProcessorApplicator<TPixel> Run<TPixel>(this IImageProcessorApplicator<TPixel> source, Action<Image<TPixel>> operation)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new DelegateProcessor<TPixel>(operation));
}

4
src/ImageSharp/Processing/Effects/Alpha.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="percent">The new opacity of the image. Must be between 0 and 1.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Alpha<TPixel>(this IImageOperations<TPixel> source, float percent)
public static IImageProcessorApplicator<TPixel> Alpha<TPixel>(this IImageProcessorApplicator<TPixel> source, float percent)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new AlphaProcessor<TPixel>(percent));
@ -38,7 +38,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Alpha<TPixel>(this IImageOperations<TPixel> source, float percent, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Alpha<TPixel>(this IImageProcessorApplicator<TPixel> source, float percent, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new AlphaProcessor<TPixel>(percent), rectangle);
}

8
src/ImageSharp/Processing/Effects/BackgroundColor.cs

@ -25,7 +25,7 @@ namespace ImageSharp
/// <param name="color">The color to set as the background.</param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> BackgroundColor<TPixel>(this IImageOperations<TPixel> source, TPixel color, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> BackgroundColor<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new BackgroundColorProcessor<TPixel>(color, options));
@ -40,7 +40,7 @@ namespace ImageSharp
/// </param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> BackgroundColor<TPixel>(this IImageOperations<TPixel> source, TPixel color, Rectangle rectangle, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> BackgroundColor<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new BackgroundColorProcessor<TPixel>(color, options), rectangle);
@ -51,7 +51,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="color">The color to set as the background.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> BackgroundColor<TPixel>(this IImageOperations<TPixel> source, TPixel color)
public static IImageProcessorApplicator<TPixel> BackgroundColor<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color)
where TPixel : struct, IPixel<TPixel>
{
return BackgroundColor(source, color, GraphicsOptions.Default);
@ -67,7 +67,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> BackgroundColor<TPixel>(this IImageOperations<TPixel> source, TPixel color, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> BackgroundColor<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
return BackgroundColor(source, color, rectangle, GraphicsOptions.Default);

6
src/ImageSharp/Processing/Effects/Brightness.cs

@ -24,8 +24,8 @@ namespace ImageSharp
/// <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>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Brightness<TPixel>(this IImageOperations<TPixel> source, int amount)
where TPixel : struct, IPixel<TPixel>
public static IImageProcessorApplicator<TPixel> Brightness<TPixel>(this IImageProcessorApplicator<TPixel> source, int amount)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new BrightnessProcessor<TPixel>(amount));
/// <summary>
@ -38,7 +38,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Brightness<TPixel>(this IImageOperations<TPixel> source, int amount, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Brightness<TPixel>(this IImageProcessorApplicator<TPixel> source, int amount, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new BrightnessProcessor<TPixel>(amount), rectangle);
}

4
src/ImageSharp/Processing/Effects/Contrast.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <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>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Contrast<TPixel>(this IImageOperations<TPixel> source, int amount)
public static IImageProcessorApplicator<TPixel> Contrast<TPixel>(this IImageProcessorApplicator<TPixel> source, int amount)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new ContrastProcessor<TPixel>(amount));
@ -38,7 +38,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Contrast<TPixel>(this IImageOperations<TPixel> source, int amount, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Contrast<TPixel>(this IImageProcessorApplicator<TPixel> source, int amount, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new ContrastProcessor<TPixel>(amount), rectangle);
}

4
src/ImageSharp/Processing/Effects/Invert.cs

@ -23,7 +23,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Invert<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> Invert<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new InvertProcessor<TPixel>());
@ -36,7 +36,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Invert<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Invert<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new InvertProcessor<TPixel>(), rectangle);
}

8
src/ImageSharp/Processing/Effects/OilPainting.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> OilPaint<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> OilPaint<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
{
return OilPaint(source, 10, 15);
@ -40,7 +40,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> OilPaint<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> OilPaint<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
return OilPaint(source, 10, 15, rectangle);
@ -54,7 +54,7 @@ namespace ImageSharp
/// <param name="levels">The number of intensity levels. Higher values result in a broader range of color intensities forming part of the result image.</param>
/// <param name="brushSize">The number of neighboring pixels used in calculating each individual pixel value.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> OilPaint<TPixel>(this IImageOperations<TPixel> source, int levels, int brushSize)
public static IImageProcessorApplicator<TPixel> OilPaint<TPixel>(this IImageProcessorApplicator<TPixel> source, int levels, int brushSize)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new OilPaintingProcessor<TPixel>(levels, brushSize));
@ -69,7 +69,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> OilPaint<TPixel>(this IImageOperations<TPixel> source, int levels, int brushSize, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> OilPaint<TPixel>(this IImageProcessorApplicator<TPixel> source, int levels, int brushSize, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new OilPaintingProcessor<TPixel>(levels, brushSize), rectangle);
}

6
src/ImageSharp/Processing/Effects/Pixelate.cs

@ -23,7 +23,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Pixelate<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> Pixelate<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new PixelateProcessor<TPixel>(4));
@ -34,7 +34,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="size">The size of the pixels.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Pixelate<TPixel>(this IImageOperations<TPixel> source, int size)
public static IImageProcessorApplicator<TPixel> Pixelate<TPixel>(this IImageProcessorApplicator<TPixel> source, int size)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new PixelateProcessor<TPixel>(size));
@ -48,7 +48,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Pixelate<TPixel>(this IImageOperations<TPixel> source, int size, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Pixelate<TPixel>(this IImageProcessorApplicator<TPixel> source, int size, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new PixelateProcessor<TPixel>(size), rectangle);
}

24
src/ImageSharp/Processing/Overlays/Glow.cs

@ -21,7 +21,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Glow<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> Glow<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
{
return Glow(source, GraphicsOptions.Default);
@ -34,7 +34,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="color">The color to set as the glow.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Glow<TPixel>(this IImageOperations<TPixel> source, TPixel color)
public static IImageProcessorApplicator<TPixel> Glow<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color)
where TPixel : struct, IPixel<TPixel>
{
return Glow(source, color, GraphicsOptions.Default);
@ -47,7 +47,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="radius">The the radius.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Glow<TPixel>(this IImageOperations<TPixel> source, float radius)
public static IImageProcessorApplicator<TPixel> Glow<TPixel>(this IImageProcessorApplicator<TPixel> source, float radius)
where TPixel : struct, IPixel<TPixel>
{
return Glow(source, radius, GraphicsOptions.Default);
@ -62,7 +62,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Glow<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Glow<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.Glow(rectangle, GraphicsOptions.Default);
@ -77,7 +77,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Glow<TPixel>(this IImageOperations<TPixel> source, TPixel color, float radius, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Glow<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float radius, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.Glow(color, ValueSize.Absolute(radius), rectangle, GraphicsOptions.Default);
@ -88,7 +88,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options effecting things like blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Glow<TPixel>(this IImageOperations<TPixel> source, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Glow<TPixel>(this IImageProcessorApplicator<TPixel> source, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.Glow(NamedColors<TPixel>.Black, ValueSize.PercentageOfWidth(0.5f), options);
@ -100,7 +100,7 @@ namespace ImageSharp
/// <param name="color">The color to set as the glow.</param>
/// <param name="options">The options effecting things like blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Glow<TPixel>(this IImageOperations<TPixel> source, TPixel color, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Glow<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.Glow(color, ValueSize.PercentageOfWidth(0.5f), options);
@ -112,7 +112,7 @@ namespace ImageSharp
/// <param name="radius">The the radius.</param>
/// <param name="options">The options effecting things like blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Glow<TPixel>(this IImageOperations<TPixel> source, float radius, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Glow<TPixel>(this IImageProcessorApplicator<TPixel> source, float radius, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.Glow(NamedColors<TPixel>.Black, ValueSize.Absolute(radius), options);
@ -126,7 +126,7 @@ namespace ImageSharp
/// </param>
/// <param name="options">The options effecting things like blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Glow<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Glow<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.Glow(NamedColors<TPixel>.Black, ValueSize.PercentageOfWidth(0.5f), rectangle, options);
@ -142,7 +142,7 @@ namespace ImageSharp
/// </param>
/// <param name="options">The options effecting things like blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Glow<TPixel>(this IImageOperations<TPixel> source, TPixel color, float radius, Rectangle rectangle, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Glow<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float radius, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.Glow(color, ValueSize.Absolute(radius), rectangle, options);
@ -158,7 +158,7 @@ namespace ImageSharp
/// </param>
/// <param name="options">The options effecting things like blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
private static IImageOperations<TPixel> Glow<TPixel>(this IImageOperations<TPixel> source, TPixel color, ValueSize radius, Rectangle rectangle, GraphicsOptions options)
private static IImageProcessorApplicator<TPixel> Glow<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, ValueSize radius, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new GlowProcessor<TPixel>(color, radius, options), rectangle);
@ -171,7 +171,7 @@ namespace ImageSharp
/// <param name="radius">The the radius.</param>
/// <param name="options">The options effecting things like blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
private static IImageOperations<TPixel> Glow<TPixel>(this IImageOperations<TPixel> source, TPixel color, ValueSize radius, GraphicsOptions options)
private static IImageProcessorApplicator<TPixel> Glow<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, ValueSize radius, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new GlowProcessor<TPixel>(color, radius, options));
}

24
src/ImageSharp/Processing/Overlays/Vignette.cs

@ -21,7 +21,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Vignette<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> Vignette<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
{
return Vignette(source, GraphicsOptions.Default);
@ -34,7 +34,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="color">The color to set as the vignette.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Vignette<TPixel>(this IImageOperations<TPixel> source, TPixel color)
public static IImageProcessorApplicator<TPixel> Vignette<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color)
where TPixel : struct, IPixel<TPixel>
{
return Vignette(source, color, GraphicsOptions.Default);
@ -48,7 +48,7 @@ namespace ImageSharp
/// <param name="radiusX">The the x-radius.</param>
/// <param name="radiusY">The the y-radius.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Vignette<TPixel>(this IImageOperations<TPixel> source, float radiusX, float radiusY)
public static IImageProcessorApplicator<TPixel> Vignette<TPixel>(this IImageProcessorApplicator<TPixel> source, float radiusX, float radiusY)
where TPixel : struct, IPixel<TPixel>
{
return Vignette(source, radiusX, radiusY, GraphicsOptions.Default);
@ -63,7 +63,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Vignette<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Vignette<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
return Vignette(source, rectangle, GraphicsOptions.Default);
@ -81,7 +81,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Vignette<TPixel>(this IImageOperations<TPixel> source, TPixel color, float radiusX, float radiusY, Rectangle rectangle)
public static IImageProcessorApplicator<TPixel> Vignette<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float radiusX, float radiusY, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.Vignette(color, radiusX, radiusY, rectangle, GraphicsOptions.Default);
@ -92,7 +92,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Vignette<TPixel>(this IImageOperations<TPixel> source, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Vignette<TPixel>(this IImageProcessorApplicator<TPixel> source, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.VignetteInternal(NamedColors<TPixel>.Black, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), options);
@ -104,7 +104,7 @@ namespace ImageSharp
/// <param name="color">The color to set as the vignette.</param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Vignette<TPixel>(this IImageOperations<TPixel> source, TPixel color, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Vignette<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.VignetteInternal(color, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), options);
@ -117,7 +117,7 @@ namespace ImageSharp
/// <param name="radiusY">The the y-radius.</param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Vignette<TPixel>(this IImageOperations<TPixel> source, float radiusX, float radiusY, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Vignette<TPixel>(this IImageProcessorApplicator<TPixel> source, float radiusX, float radiusY, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.VignetteInternal(NamedColors<TPixel>.Black, radiusX, radiusY, options);
@ -131,7 +131,7 @@ namespace ImageSharp
/// </param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Vignette<TPixel>(this IImageOperations<TPixel> source, Rectangle rectangle, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Vignette<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.VignetteInternal(NamedColors<TPixel>.Black, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), rectangle, options);
@ -148,15 +148,15 @@ namespace ImageSharp
/// </param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Vignette<TPixel>(this IImageOperations<TPixel> source, TPixel color, float radiusX, float radiusY, Rectangle rectangle, GraphicsOptions options)
public static IImageProcessorApplicator<TPixel> Vignette<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, float radiusX, float radiusY, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.VignetteInternal(color, radiusX, radiusY, rectangle, options);
private static IImageOperations<TPixel> VignetteInternal<TPixel>(this IImageOperations<TPixel> source, TPixel color, ValueSize radiusX, ValueSize radiusY, Rectangle rectangle, GraphicsOptions options)
private static IImageProcessorApplicator<TPixel> VignetteInternal<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, ValueSize radiusX, ValueSize radiusY, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new VignetteProcessor<TPixel>(color, radiusX, radiusY, options), rectangle);
private static IImageOperations<TPixel> VignetteInternal<TPixel>(this IImageOperations<TPixel> source, TPixel color, ValueSize radiusX, ValueSize radiusY, GraphicsOptions options)
private static IImageProcessorApplicator<TPixel> VignetteInternal<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, ValueSize radiusX, ValueSize radiusY, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new VignetteProcessor<TPixel>(color, radiusX, radiusY, options));
}

2
src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs

@ -50,7 +50,7 @@ namespace ImageSharp.Processing.Processors
using (var firstPassPixels = new PixelAccessor<TPixel>(width, height))
using (PixelAccessor<TPixel> sourcePixels = source.Lock())
{
this.ApplyConvolution(firstPassPixels, sourcePixels, source.Bounds, this.KernelX);
this.ApplyConvolution(firstPassPixels, sourcePixels, source.Bounds(), this.KernelX);
this.ApplyConvolution(sourcePixels, firstPassPixels, sourceRectangle, this.KernelY);
}
}

4
src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs

@ -89,7 +89,7 @@ namespace ImageSharp.Processing.Processors
int maxY = Math.Min(source.Height, endY);
// we need a clean copy for each pass to start from
using (ImageBase<TPixel> cleanCopy = new Image<TPixel>(source))
using (ImageBase<TPixel> cleanCopy = source.Clone())
{
new ConvolutionProcessor<TPixel>(kernels[0]).Apply(source, sourceRectangle);
@ -116,7 +116,7 @@ namespace ImageSharp.Processing.Processors
// ReSharper disable once ForCanBeConvertedToForeach
for (int i = 1; i < kernels.Length; i++)
{
using (ImageBase<TPixel> pass = new Image<TPixel>(cleanCopy))
using (ImageBase<TPixel> pass = cleanCopy.Clone())
{
new ConvolutionProcessor<TPixel>(kernels[i]).Apply(pass, sourceRectangle);

2
src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs

@ -62,7 +62,7 @@ namespace ImageSharp.Processing.Processors
TPixel glowColor = this.GlowColor;
Vector2 centre = Rectangle.Center(sourceRectangle);
var finalRadius = this.Radius.Calculate(source.Bounds.Size);
var finalRadius = this.Radius.Calculate(source.Size());
float maxDistance = finalRadius > 0 ? MathF.Min(finalRadius, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F;

4
src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs

@ -81,8 +81,8 @@ namespace ImageSharp.Processing.Processors
TPixel vignetteColor = this.VignetteColor;
Vector2 centre = Rectangle.Center(sourceRectangle);
var finalradiusX = this.RadiusX.Calculate(source.Bounds.Size);
var finalradiusY = this.RadiusY.Calculate(source.Bounds.Size);
var finalradiusX = this.RadiusX.Calculate(source.Size());
var finalradiusY = this.RadiusY.Calculate(source.Size());
float rX = finalradiusX > 0 ? MathF.Min(finalradiusX, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F;
float rY = finalradiusY > 0 ? MathF.Min(finalradiusY, sourceRectangle.Height * .5F) : sourceRectangle.Height * .5F;
float maxDistance = MathF.Sqrt((rX * rX) + (rY * rY));

2
src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs

@ -39,7 +39,7 @@ namespace ImageSharp.Processing.Processors
/// <inheritdoc/>
protected override void OnApply(ImageBase<TPixel> source, Rectangle sourceRectangle)
{
using (ImageBase<TPixel> temp = new Image<TPixel>(source))
using (ImageBase<TPixel> temp = source.Clone())
{
// Detect the edges.
new SobelProcessor<TPixel>().Apply(temp, sourceRectangle);

3
src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs

@ -45,6 +45,7 @@ namespace ImageSharp.Processing.Processors
int height = this.CanvasRectangle.Height;
int width = this.CanvasRectangle.Width;
Matrix3x2 matrix = this.GetCenteredMatrix(source, this.processMatrix);
Rectangle sourceBounds = source.Bounds();
using (var targetPixels = new PixelAccessor<TPixel>(width, height))
{
@ -60,7 +61,7 @@ namespace ImageSharp.Processing.Processors
{
var transformedPoint = Point.Rotate(new Point(x, y), matrix);
if (source.Bounds.Contains(transformedPoint.X, transformedPoint.Y))
if (sourceBounds.Contains(transformedPoint.X, transformedPoint.Y))
{
targetRow[x] = source[transformedPoint.X, transformedPoint.Y];
}

3
src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs

@ -45,6 +45,7 @@ namespace ImageSharp.Processing.Processors
int height = this.CanvasRectangle.Height;
int width = this.CanvasRectangle.Width;
Matrix3x2 matrix = this.GetCenteredMatrix(source, this.processMatrix);
Rectangle sourceBounds = source.Bounds();
using (var targetPixels = new PixelAccessor<TPixel>(width, height))
{
@ -60,7 +61,7 @@ namespace ImageSharp.Processing.Processors
{
var transformedPoint = Point.Skew(new Point(x, y), matrix);
if (source.Bounds.Contains(transformedPoint.X, transformedPoint.Y))
if (sourceBounds.Contains(transformedPoint.X, transformedPoint.Y))
{
targetRow[x] = source[transformedPoint.X, transformedPoint.Y];
}

2
src/ImageSharp/Processing/Transforms/AutoOrient.cs

@ -21,7 +21,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to auto rotate.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageOperations<TPixel> AutoOrient<TPixel>(this IImageOperations<TPixel> source)
public static IImageProcessorApplicator<TPixel> AutoOrient<TPixel>(this IImageProcessorApplicator<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new Processing.Processors.AutoRotateProcessor<TPixel>());
}

4
src/ImageSharp/Processing/Transforms/Crop.cs

@ -25,7 +25,7 @@ namespace ImageSharp
/// <param name="width">The target image width.</param>
/// <param name="height">The target image height.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageOperations<TPixel> Crop<TPixel>(this IImageOperations<TPixel> source, int width, int height)
public static IImageProcessorApplicator<TPixel> Crop<TPixel>(this IImageProcessorApplicator<TPixel> source, int width, int height)
where TPixel : struct, IPixel<TPixel>
=> Crop(source, new Rectangle(0, 0, width, height));
@ -38,7 +38,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to retain.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageOperations<TPixel> Crop<TPixel>(this IImageOperations<TPixel> source, Rectangle cropRectangle)
public static IImageProcessorApplicator<TPixel> Crop<TPixel>(this IImageProcessorApplicator<TPixel> source, Rectangle cropRectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new CropProcessor<TPixel>(cropRectangle));
}

2
src/ImageSharp/Processing/Transforms/EntropyCrop.cs

@ -23,7 +23,7 @@ namespace ImageSharp
/// <param name="source">The image to crop.</param>
/// <param name="threshold">The threshold for entropic density.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageOperations<TPixel> EntropyCrop<TPixel>(this IImageOperations<TPixel> source, float threshold = .5f)
public static IImageProcessorApplicator<TPixel> EntropyCrop<TPixel>(this IImageProcessorApplicator<TPixel> source, float threshold = .5f)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new EntropyCropProcessor<TPixel>(threshold));
}

2
src/ImageSharp/Processing/Transforms/Flip.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <param name="source">The image to rotate, flip, or both.</param>
/// <param name="flipType">The <see cref="FlipType"/> to perform the flip.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageOperations<TPixel> Flip<TPixel>(this IImageOperations<TPixel> source, FlipType flipType)
public static IImageProcessorApplicator<TPixel> Flip<TPixel>(this IImageProcessorApplicator<TPixel> source, FlipType flipType)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new FlipProcessor<TPixel>(flipType));
}

2
src/ImageSharp/Processing/Transforms/Pad.cs

@ -26,7 +26,7 @@ namespace ImageSharp
/// <param name="width">The new width.</param>
/// <param name="height">The new height.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Pad<TPixel>(this IImageOperations<TPixel> source, int width, int height)
public static IImageProcessorApplicator<TPixel> Pad<TPixel>(this IImageProcessorApplicator<TPixel> source, int width, int height)
where TPixel : struct, IPixel<TPixel>
{
ResizeOptions options = new ResizeOptions

18
src/ImageSharp/Processing/Transforms/Resize.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <param name="options">The resize options.</param>
/// <returns>The <see cref="Image{TPixel}"/></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 IImageOperations<TPixel> Resize<TPixel>(this IImageOperations<TPixel> source, ResizeOptions options)
public static IImageProcessorApplicator<TPixel> Resize<TPixel>(this IImageProcessorApplicator<TPixel> source, ResizeOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.Run(img =>
@ -56,7 +56,7 @@ namespace ImageSharp
/// <param name="size">The target image size.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static IImageOperations<TPixel> Resize<TPixel>(this IImageOperations<TPixel> source, Size size)
public static IImageProcessorApplicator<TPixel> Resize<TPixel>(this IImageProcessorApplicator<TPixel> source, Size size)
where TPixel : struct, IPixel<TPixel>
{
return Resize(source, size.Width, size.Height, new BicubicResampler(), false);
@ -71,7 +71,7 @@ namespace ImageSharp
/// <param name="compand">Whether to compress and expand the image color-space to gamma correct the image during processing.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static IImageOperations<TPixel> Resize<TPixel>(this IImageOperations<TPixel> source, Size size, bool compand)
public static IImageProcessorApplicator<TPixel> Resize<TPixel>(this IImageProcessorApplicator<TPixel> source, Size size, bool compand)
where TPixel : struct, IPixel<TPixel>
{
return Resize(source, size.Width, size.Height, new BicubicResampler(), compand);
@ -86,7 +86,7 @@ namespace ImageSharp
/// <param name="height">The target image height.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static IImageOperations<TPixel> Resize<TPixel>(this IImageOperations<TPixel> source, int width, int height)
public static IImageProcessorApplicator<TPixel> Resize<TPixel>(this IImageProcessorApplicator<TPixel> source, int width, int height)
where TPixel : struct, IPixel<TPixel>
{
return Resize(source, width, height, new BicubicResampler(), false);
@ -102,7 +102,7 @@ namespace ImageSharp
/// <param name="compand">Whether to compress and expand the image color-space to gamma correct the image during processing.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static IImageOperations<TPixel> Resize<TPixel>(this IImageOperations<TPixel> source, int width, int height, bool compand)
public static IImageProcessorApplicator<TPixel> Resize<TPixel>(this IImageProcessorApplicator<TPixel> source, int width, int height, bool compand)
where TPixel : struct, IPixel<TPixel>
{
return Resize(source, width, height, new BicubicResampler(), compand);
@ -118,7 +118,7 @@ namespace ImageSharp
/// <param name="sampler">The <see cref="IResampler"/> to perform the resampling.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static IImageOperations<TPixel> Resize<TPixel>(this IImageOperations<TPixel> source, int width, int height, IResampler sampler)
public static IImageProcessorApplicator<TPixel> Resize<TPixel>(this IImageProcessorApplicator<TPixel> source, int width, int height, IResampler sampler)
where TPixel : struct, IPixel<TPixel>
{
return Resize(source, width, height, sampler, false);
@ -135,7 +135,7 @@ namespace ImageSharp
/// <param name="compand">Whether to compress and expand the image color-space to gamma correct the image during processing.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static IImageOperations<TPixel> Resize<TPixel>(this IImageOperations<TPixel> source, int width, int height, IResampler sampler, bool compand)
public static IImageProcessorApplicator<TPixel> Resize<TPixel>(this IImageProcessorApplicator<TPixel> source, int width, int height, IResampler sampler, bool compand)
where TPixel : struct, IPixel<TPixel>
{
return Resize(source, width, height, sampler, new Rectangle(0, 0, width, height), compand);
@ -159,7 +159,7 @@ namespace ImageSharp
/// <param name="compand">Whether to compress and expand the image color-space to gamma correct the image during processing.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static IImageOperations<TPixel> Resize<TPixel>(this IImageOperations<TPixel> source, int width, int height, IResampler sampler, Rectangle sourceRectangle, Rectangle targetRectangle, bool compand)
public static IImageProcessorApplicator<TPixel> Resize<TPixel>(this IImageProcessorApplicator<TPixel> source, int width, int height, IResampler sampler, Rectangle sourceRectangle, Rectangle targetRectangle, bool compand)
where TPixel : struct, IPixel<TPixel>
{
return source.Run(img =>
@ -199,7 +199,7 @@ namespace ImageSharp
/// <param name="compand">Whether to compress and expand the image color-space to gamma correct the image during processing.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static IImageOperations<TPixel> Resize<TPixel>(this IImageOperations<TPixel> source, int width, int height, IResampler sampler, Rectangle targetRectangle, bool compand)
public static IImageProcessorApplicator<TPixel> Resize<TPixel>(this IImageProcessorApplicator<TPixel> source, int width, int height, IResampler sampler, Rectangle targetRectangle, bool compand)
where TPixel : struct, IPixel<TPixel>
{
return source.Run(img =>

6
src/ImageSharp/Processing/Transforms/Rotate.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <param name="source">The image to rotate.</param>
/// <param name="degrees">The angle in degrees to perform the rotation.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageOperations<TPixel> Rotate<TPixel>(this IImageOperations<TPixel> source, float degrees)
public static IImageProcessorApplicator<TPixel> Rotate<TPixel>(this IImageProcessorApplicator<TPixel> source, float degrees)
where TPixel : struct, IPixel<TPixel>
{
return Rotate(source, degrees, true);
@ -37,7 +37,7 @@ namespace ImageSharp
/// <param name="source">The image to rotate.</param>
/// <param name="rotateType">The <see cref="RotateType"/> to perform the rotation.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageOperations<TPixel> Rotate<TPixel>(this IImageOperations<TPixel> source, RotateType rotateType)
public static IImageProcessorApplicator<TPixel> Rotate<TPixel>(this IImageProcessorApplicator<TPixel> source, RotateType rotateType)
where TPixel : struct, IPixel<TPixel>
=> Rotate(source, (float)rotateType, false);
@ -49,7 +49,7 @@ namespace ImageSharp
/// <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>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageOperations<TPixel> Rotate<TPixel>(this IImageOperations<TPixel> source, float degrees, bool expand)
public static IImageProcessorApplicator<TPixel> Rotate<TPixel>(this IImageProcessorApplicator<TPixel> source, float degrees, bool expand)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new RotateProcessor<TPixel> { Angle = degrees, Expand = expand });
}

2
src/ImageSharp/Processing/Transforms/RotateFlip.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <param name="rotateType">The <see cref="RotateType"/> to perform the rotation.</param>
/// <param name="flipType">The <see cref="FlipType"/> to perform the flip.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageOperations<TPixel> RotateFlip<TPixel>(this IImageOperations<TPixel> source, RotateType rotateType, FlipType flipType)
public static IImageProcessorApplicator<TPixel> RotateFlip<TPixel>(this IImageProcessorApplicator<TPixel> source, RotateType rotateType, FlipType flipType)
where TPixel : struct, IPixel<TPixel>
{
return source.Rotate(rotateType).Flip(flipType);

4
src/ImageSharp/Processing/Transforms/Skew.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <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>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageOperations<TPixel> Skew<TPixel>(this IImageOperations<TPixel> source, float degreesX, float degreesY)
public static IImageProcessorApplicator<TPixel> Skew<TPixel>(this IImageProcessorApplicator<TPixel> source, float degreesX, float degreesY)
where TPixel : struct, IPixel<TPixel>
{
return Skew(source, degreesX, degreesY, true);
@ -39,7 +39,7 @@ namespace ImageSharp
/// <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>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageOperations<TPixel> Skew<TPixel>(this IImageOperations<TPixel> source, float degreesX, float degreesY, bool expand)
public static IImageProcessorApplicator<TPixel> Skew<TPixel>(this IImageProcessorApplicator<TPixel> source, float degreesX, float degreesY, bool expand)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new SkewProcessor<TPixel> { AngleX = degreesX, AngleY = degreesY, Expand = expand });
}

4
src/ImageSharp/Quantizers/Quantize.cs

@ -24,7 +24,7 @@ namespace ImageSharp
/// <param name="mode">The quantization mode to apply to perform the operation.</param>
/// <param name="maxColors">The maximum number of colors to return. Defaults to 256.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Quantize<TPixel>(this IImageOperations<TPixel> source, Quantization mode = Quantization.Octree, int maxColors = 256)
public static IImageProcessorApplicator<TPixel> Quantize<TPixel>(this IImageProcessorApplicator<TPixel> source, Quantization mode = Quantization.Octree, int maxColors = 256)
where TPixel : struct, IPixel<TPixel>
{
IQuantizer<TPixel> quantizer;
@ -54,7 +54,7 @@ namespace ImageSharp
/// <param name="quantizer">The quantizer to apply to perform the operation.</param>
/// <param name="maxColors">The maximum number of colors to return.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageOperations<TPixel> Quantize<TPixel>(this IImageOperations<TPixel> source, IQuantizer<TPixel> quantizer, int maxColors)
public static IImageProcessorApplicator<TPixel> Quantize<TPixel>(this IImageProcessorApplicator<TPixel> source, IQuantizer<TPixel> quantizer, int maxColors)
where TPixel : struct, IPixel<TPixel>
{
return source.Run(img =>

2
src/ImageSharp/Quantizers/Quantizer{TPixel}.cs

@ -70,7 +70,7 @@ namespace ImageSharp.Quantizers
if (this.Dither)
{
// We clone the image as we don't want to alter the original.
using (var clone = new Image<TPixel>(image))
using (ImageBase<TPixel> clone = image.Clone())
{
this.SecondPass(clone, quantizedPixels, width, height);
}

4
tests/ImageSharp.Benchmarks/Samplers/Glow.cs

@ -35,7 +35,7 @@ namespace ImageSharp.Benchmarks
{
using (Image<Rgba32> image = new Image<Rgba32>(800, 800))
{
image.ApplyProcessor(bulk, image.Bounds);
bulk.Apply(image, image.Bounds());
return new CoreSize(image.Width, image.Height);
}
}
@ -45,7 +45,7 @@ namespace ImageSharp.Benchmarks
{
using (Image<Rgba32> image = new Image<Rgba32>(800, 800))
{
image.ApplyProcessor(parallel, image.Bounds);
parallel.Apply(image, image.Bounds());
return new CoreSize(image.Width, image.Height);
}
}

3
tests/ImageSharp.Tests/BaseImageOperationsExtensionTest.cs

@ -17,7 +17,7 @@ namespace ImageSharp.Tests
{
this.options = new GraphicsOptions(false) { };
this.rect = new Rectangle(91, 123, 324, 56); // make this random?
this.operations = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(null);
this.operations = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(null, false);
}
public T Verify<T>(int index = 0)
@ -28,6 +28,7 @@ namespace ImageSharp.Tests
return Assert.IsType<T>(operation.Processor);
}
public T Verify<T>(Rectangle rect, int index = 0)
{
Assert.InRange(index, 0, this.operations.applied.Count - 1);

30
tests/ImageSharp.Tests/FakeImageOperationsProvider.cs

@ -8,7 +8,7 @@
using ImageSharp.Processing;
using SixLabors.Primitives;
public class FakeImageOperationsProvider : IImageOperationsProvider
public class FakeImageOperationsProvider : IImageProcessorApplicatorFactory
{
private List<object> ImageOperators = new List<object>();
@ -29,27 +29,41 @@
.SelectMany(x => x.applied);
}
public IImageOperations<TPixel> CreateMutator<TPixel>(Image<TPixel> source) where TPixel : struct, IPixel<TPixel>
public IInternalImageProcessorApplicator<TPixel> CreateImageOperations<TPixel>(Image<TPixel> source, bool mutate) where TPixel : struct, IPixel<TPixel>
{
var op = new FakeImageOperations<TPixel>(source);
var op = new FakeImageOperations<TPixel>(source, mutate);
this.ImageOperators.Add(op);
return op;
}
public class FakeImageOperations<TPixel> : IImageOperations<TPixel>
public class FakeImageOperations<TPixel> : IInternalImageProcessorApplicator<TPixel>
where TPixel : struct, IPixel<TPixel>
{
public Image<TPixel> source;
public List<AppliedOpperation> applied = new List<AppliedOpperation>();
public bool mutate;
public FakeImageOperations(Image<TPixel> source)
public FakeImageOperations(Image<TPixel> source, bool mutate)
{
this.source = source;
this.mutate = mutate;
if (mutate)
{
this.source = source;
}
else
{
this.source = source.Clone();
}
}
public Image<TPixel> Apply()
{
return source;
}
public IImageOperations<TPixel> ApplyProcessor(IImageProcessor<TPixel> processor, Rectangle rectangle)
public IImageProcessorApplicator<TPixel> ApplyProcessor(IImageProcessor<TPixel> processor, Rectangle rectangle)
{
applied.Add(new AppliedOpperation
{
@ -59,7 +73,7 @@
return this;
}
public IImageOperations<TPixel> ApplyProcessor(IImageProcessor<TPixel> processor)
public IImageProcessorApplicator<TPixel> ApplyProcessor(IImageProcessor<TPixel> processor)
{
applied.Add(new AppliedOpperation
{

6
tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs

@ -64,7 +64,7 @@ namespace ImageSharp.Tests
{
using (Image<Rgba32> srcImage = Image.Load<Rgba32>(file.Bytes, out var mimeType))
{
using (Image<Rgba32> image = new Image<Rgba32>(srcImage))
using (Image<Rgba32> image = srcImage.Clone())
{
using (FileStream output = File.OpenWrite($"{path}/Octree-{file.FileName}"))
{
@ -74,7 +74,7 @@ namespace ImageSharp.Tests
}
}
using (Image<Rgba32> image = new Image<Rgba32>(srcImage))
using (Image<Rgba32> image = srcImage.Clone())
{
using (FileStream output = File.OpenWrite($"{path}/Wu-{file.FileName}"))
{
@ -83,7 +83,7 @@ namespace ImageSharp.Tests
}
}
using (Image<Rgba32> image = new Image<Rgba32>(srcImage))
using (Image<Rgba32> image = srcImage.Clone())
{
using (FileStream output = File.OpenWrite($"{path}/Palette-{file.FileName}"))
{

4
tests/ImageSharp.Tests/ImageOperationTests.cs

@ -92,9 +92,9 @@ namespace ImageSharp.Tests
}
[Fact]
public void ApplyProcessors_ListOfProcessors_AppliesALlProcessorsToOperation()
public void ApplyProcessors_ListOfProcessors_AppliesAllProcessorsToOperation()
{
var operations = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(null);
var operations = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(null, false);
operations.ApplyProcessors(this.processor);
Assert.Contains(this.processor, operations.applied.Select(x => x.Processor));
}

2
tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs

@ -37,7 +37,7 @@ namespace ImageSharp.Tests.Processing.Processors.Binarization
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

4
tests/ImageSharp.Tests/Processing/Processors/Binarization/DitherTest.cs

@ -49,7 +49,7 @@ namespace ImageSharp.Tests.Processing.Processors.Binarization
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);
@ -78,7 +78,7 @@ namespace ImageSharp.Tests.Processing.Processors.Binarization
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/BlackWhiteTest.cs

@ -29,7 +29,7 @@ namespace ImageSharp.Tests.Processing.Processors.ColorMatrix
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/ColorBlindnessTest.cs

@ -43,7 +43,7 @@ namespace ImageSharp.Tests.Processing.Processors.ColorMatrix
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/GrayscaleTest.cs

@ -48,7 +48,7 @@ namespace ImageSharp.Tests.Processing.Processors.ColorMatrix
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
image.Mutate(x => x.Grayscale(value, bounds));

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/HueTest.cs

@ -36,7 +36,7 @@ namespace ImageSharp.Tests.Processing.Processors.ColorMatrix
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/KodachromeTest.cs

@ -29,7 +29,7 @@ namespace ImageSharp.Tests.Processing.Processors.ColorMatrix
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/LomographTest.cs

@ -31,7 +31,7 @@ namespace ImageSharp.Tests.Processing.Processors.ColorMatrix
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/PolaroidTest.cs

@ -29,7 +29,7 @@ namespace ImageSharp.Tests.Processing.Processors.ColorMatrix
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/SaturationTest.cs

@ -36,7 +36,7 @@ namespace ImageSharp.Tests.Processing.Processors.ColorMatrix
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/SepiaTest.cs

@ -29,7 +29,7 @@ namespace ImageSharp.Tests.Processing.Processors.ColorMatrix
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs

@ -36,7 +36,7 @@ namespace ImageSharp.Tests.Processing.Processors.Convolution
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs

@ -45,7 +45,7 @@ namespace ImageSharp.Tests.Processing.Processors.Convolution
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs

@ -36,7 +36,7 @@ namespace ImageSharp.Tests.Processing.Processors.Convolution
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs

@ -36,7 +36,7 @@ namespace ImageSharp.Tests.Processing.Processors.Convolution
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/Effects/AlphaTest.cs

@ -36,7 +36,7 @@ namespace ImageSharp.Tests.Processing.Processors.Effects
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs

@ -29,7 +29,7 @@ namespace ImageSharp.Tests.Processing.Processors.Effects
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/Effects/BrightnessTest.cs

@ -36,7 +36,7 @@ namespace ImageSharp.Tests.Processing.Processors.Effects
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/Effects/ContrastTest.cs

@ -36,7 +36,7 @@ namespace ImageSharp.Tests.Processing.Processors.Effects
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/Effects/InvertTest.cs

@ -29,7 +29,7 @@ namespace ImageSharp.Tests.Processing.Processors.Effects
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs

@ -36,7 +36,7 @@ namespace ImageSharp.Tests.Processing.Processors.Effects
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

2
tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs

@ -52,7 +52,7 @@ namespace ImageSharp.Tests.Processing.Processors.Effects
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = new Image<TPixel>(source))
using (var image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save