diff --git a/src/ImageSharp/PixelFormats/PixelBlenderMode.cs b/src/ImageSharp/PixelFormats/PixelBlenderMode.cs
index ae70cdee4..7541be789 100644
--- a/src/ImageSharp/PixelFormats/PixelBlenderMode.cs
+++ b/src/ImageSharp/PixelFormats/PixelBlenderMode.cs
@@ -1,14 +1,10 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using System;
-using System.Collections.Generic;
-using System.Text;
-
namespace SixLabors.ImageSharp.PixelFormats
{
///
- /// The various blending modes.
+ /// Enumerates the various blending modes.
///
public enum PixelBlenderMode
{
diff --git a/src/ImageSharp/Processing/Delegate.cs b/src/ImageSharp/Processing/Delegate.cs
deleted file mode 100644
index b390e46ae..000000000
--- a/src/ImageSharp/Processing/Delegate.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) Six Labors and contributors.
-// Licensed under the Apache License, Version 2.0.
-
-using System;
-using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing;
-
-namespace SixLabors.ImageSharp
-{
- ///
- /// Extension methods for the type.
- ///
- public static partial class ImageExtensions
- {
- ///
- /// Applies the given operation to the mutable image.
- /// Useful when we need to extract information like Width/Height to parameterize the next operation working on the chain.
- /// To achieve this the method actually implements an "inline" with as it's processing logic.
- ///
- /// The pixel format.
- /// The image to mutate.
- /// The operation to perform on the source.
- /// The to allow chaining of operations.
- public static IImageProcessingContext Apply(this IImageProcessingContext source, Action> operation)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new DelegateProcessor(operation));
- }
-}
diff --git a/src/ImageSharp/Processing/Filters/Processors/LomographProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/LomographProcessor.cs
index 5ee6b4bc1..5e3d73fd1 100644
--- a/src/ImageSharp/Processing/Filters/Processors/LomographProcessor.cs
+++ b/src/ImageSharp/Processing/Filters/Processors/LomographProcessor.cs
@@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Processors.Overlays;
+using SixLabors.ImageSharp.Processing.Overlays.Processors;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Filters.Processors
diff --git a/src/ImageSharp/Processing/Filters/Processors/PolaroidProcessor.cs b/src/ImageSharp/Processing/Filters/Processors/PolaroidProcessor.cs
index 0a84eab8b..0e90efc7e 100644
--- a/src/ImageSharp/Processing/Filters/Processors/PolaroidProcessor.cs
+++ b/src/ImageSharp/Processing/Filters/Processors/PolaroidProcessor.cs
@@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Processors.Overlays;
+using SixLabors.ImageSharp.Processing.Overlays.Processors;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Filters.Processors
diff --git a/src/ImageSharp/Processing/Overlays/BackgroundColor.cs b/src/ImageSharp/Processing/Overlays/BackgroundColorExtensions.cs
similarity index 82%
rename from src/ImageSharp/Processing/Overlays/BackgroundColor.cs
rename to src/ImageSharp/Processing/Overlays/BackgroundColorExtensions.cs
index 22aad9ca6..72cba78e5 100644
--- a/src/ImageSharp/Processing/Overlays/BackgroundColor.cs
+++ b/src/ImageSharp/Processing/Overlays/BackgroundColorExtensions.cs
@@ -1,17 +1,16 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using System;
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Processors;
+using SixLabors.ImageSharp.Processing.Overlays.Processors;
using SixLabors.Primitives;
-namespace SixLabors.ImageSharp
+namespace SixLabors.ImageSharp.Processing.Overlays
{
///
- /// Extension methods for the type.
+ /// Adds extensions that allow the application of a background color to the type.
///
- public static partial class ImageExtensions
+ public static class BackgroundColorExtensions
{
///
/// Replaces the background color of image with the given one.
@@ -19,11 +18,10 @@ namespace SixLabors.ImageSharp
/// The pixel format.
/// The image this method extends.
/// The color to set as the background.
- /// The options effecting pixel blending.
/// The .
- public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color, GraphicsOptions options)
+ public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color)
where TPixel : struct, IPixel
- => source.ApplyProcessor(new BackgroundColorProcessor(source.MemoryManager, color, options));
+ => BackgroundColor(source, color, GraphicsOptions.Default);
///
/// Replaces the background color of image with the given one.
@@ -34,11 +32,10 @@ namespace SixLabors.ImageSharp
///
/// The structure that specifies the portion of the image object to alter.
///
- /// The options effecting pixel blending.
/// The .
- public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color, Rectangle rectangle, GraphicsOptions options)
+ public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color, Rectangle rectangle)
where TPixel : struct, IPixel
- => source.ApplyProcessor(new BackgroundColorProcessor(source.MemoryManager, color, options), rectangle);
+ => BackgroundColor(source, color, rectangle, GraphicsOptions.Default);
///
/// Replaces the background color of image with the given one.
@@ -46,12 +43,11 @@ namespace SixLabors.ImageSharp
/// The pixel format.
/// The image this method extends.
/// The color to set as the background.
+ /// The options effecting pixel blending.
/// The .
- public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color)
+ public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color, GraphicsOptions options)
where TPixel : struct, IPixel
- {
- return BackgroundColor(source, color, GraphicsOptions.Default);
- }
+ => source.ApplyProcessor(new BackgroundColorProcessor(color, options));
///
/// Replaces the background color of image with the given one.
@@ -62,11 +58,10 @@ namespace SixLabors.ImageSharp
///
/// The structure that specifies the portion of the image object to alter.
///
+ /// The options effecting pixel blending.
/// The .
- public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color, Rectangle rectangle)
+ public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, TPixel color, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel
- {
- return BackgroundColor(source, color, rectangle, GraphicsOptions.Default);
- }
+ => source.ApplyProcessor(new BackgroundColorProcessor(color, options), rectangle);
}
}
diff --git a/src/ImageSharp/Processing/Overlays/Glow.cs b/src/ImageSharp/Processing/Overlays/GlowExtensions.cs
similarity index 87%
rename from src/ImageSharp/Processing/Overlays/Glow.cs
rename to src/ImageSharp/Processing/Overlays/GlowExtensions.cs
index 80eb4287a..a86128f88 100644
--- a/src/ImageSharp/Processing/Overlays/Glow.cs
+++ b/src/ImageSharp/Processing/Overlays/GlowExtensions.cs
@@ -3,16 +3,15 @@
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives;
-using SixLabors.ImageSharp.Processing.Processors;
-using SixLabors.ImageSharp.Processing.Processors.Overlays;
+using SixLabors.ImageSharp.Processing.Overlays.Processors;
using SixLabors.Primitives;
-namespace SixLabors.ImageSharp
+namespace SixLabors.ImageSharp.Processing.Overlays
{
///
- /// Extension methods for the type.
+ /// Adds extensions that allow the application of a radial glow to the type.
///
- public static partial class ImageExtensions
+ public static class GlowExtensions
{
///
/// Applies a radial glow effect to an image.
@@ -22,9 +21,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Glow(this IImageProcessingContext source)
where TPixel : struct, IPixel
- {
- return Glow(source, GraphicsOptions.Default);
- }
+ => Glow(source, GraphicsOptions.Default);
///
/// Applies a radial glow effect to an image.
@@ -48,9 +45,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Glow(this IImageProcessingContext source, float radius)
where TPixel : struct, IPixel
- {
- return Glow(source, radius, GraphicsOptions.Default);
- }
+ => Glow(source, radius, GraphicsOptions.Default);
///
/// Applies a radial glow effect to an image.
@@ -63,7 +58,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Glow(this IImageProcessingContext source, Rectangle rectangle)
where TPixel : struct, IPixel
- => source.Glow(rectangle, GraphicsOptions.Default);
+ => source.Glow(rectangle, GraphicsOptions.Default);
///
/// Applies a radial glow effect to an image.
@@ -78,7 +73,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Glow(this IImageProcessingContext source, TPixel color, float radius, Rectangle rectangle)
where TPixel : struct, IPixel
- => source.Glow(color, ValueSize.Absolute(radius), rectangle, GraphicsOptions.Default);
+ => source.Glow(color, ValueSize.Absolute(radius), rectangle, GraphicsOptions.Default);
///
/// Applies a radial glow effect to an image.
@@ -89,7 +84,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Glow(this IImageProcessingContext source, GraphicsOptions options)
where TPixel : struct, IPixel
- => source.Glow(NamedColors.Black, ValueSize.PercentageOfWidth(0.5f), options);
+ => source.Glow(NamedColors.Black, ValueSize.PercentageOfWidth(0.5f), options);
///
/// Applies a radial glow effect to an image.
@@ -101,7 +96,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Glow(this IImageProcessingContext source, TPixel color, GraphicsOptions options)
where TPixel : struct, IPixel
- => source.Glow(color, ValueSize.PercentageOfWidth(0.5f), options);
+ => source.Glow(color, ValueSize.PercentageOfWidth(0.5f), options);
///
/// Applies a radial glow effect to an image.
@@ -113,7 +108,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Glow(this IImageProcessingContext source, float radius, GraphicsOptions options)
where TPixel : struct, IPixel
- => source.Glow(NamedColors.Black, ValueSize.Absolute(radius), options);
+ => source.Glow(NamedColors.Black, ValueSize.Absolute(radius), options);
///
/// Applies a radial glow effect to an image.
@@ -127,7 +122,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Glow(this IImageProcessingContext source, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel
- => source.Glow(NamedColors.Black, ValueSize.PercentageOfWidth(0.5f), rectangle, options);
+ => source.Glow(NamedColors.Black, ValueSize.PercentageOfWidth(0.5f), rectangle, options);
///
/// Applies a radial glow effect to an image.
@@ -143,7 +138,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Glow(this IImageProcessingContext source, TPixel color, float radius, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel
- => source.Glow(color, ValueSize.Absolute(radius), rectangle, options);
+ => source.Glow(color, ValueSize.Absolute(radius), rectangle, options);
///
/// Applies a radial glow effect to an image.
@@ -159,7 +154,7 @@ namespace SixLabors.ImageSharp
/// The .
private static IImageProcessingContext Glow(this IImageProcessingContext source, TPixel color, ValueSize radius, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel
- => source.ApplyProcessor(new GlowProcessor(color, radius, options), rectangle);
+ => source.ApplyProcessor(new GlowProcessor(color, radius, options), rectangle);
///
/// Applies a radial glow effect to an image.
@@ -172,6 +167,6 @@ namespace SixLabors.ImageSharp
/// The .
private static IImageProcessingContext Glow(this IImageProcessingContext source, TPixel color, ValueSize radius, GraphicsOptions options)
where TPixel : struct, IPixel
- => source.ApplyProcessor(new GlowProcessor(color, radius, options));
+ => source.ApplyProcessor(new GlowProcessor(color, radius, options));
}
}
diff --git a/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs
similarity index 82%
rename from src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs
rename to src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs
index d07dcbeed..c91cc93c2 100644
--- a/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs
+++ b/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs
@@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
-namespace SixLabors.ImageSharp.Processing.Processors
+namespace SixLabors.ImageSharp.Processing.Overlays.Processors
{
///
/// Sets the background color of the image.
@@ -17,18 +17,14 @@ namespace SixLabors.ImageSharp.Processing.Processors
internal class BackgroundColorProcessor : ImageProcessor
where TPixel : struct, IPixel
{
- private readonly MemoryManager memoryManager;
-
///
/// Initializes a new instance of the class.
///
- /// The to use for buffer allocations.
/// The to set the background color to.
/// The options defining blending algorithm and amount.
- public BackgroundColorProcessor(MemoryManager memoryManager, TPixel color, GraphicsOptions options)
+ public BackgroundColorProcessor(TPixel color, GraphicsOptions options)
{
this.Value = color;
- this.memoryManager = memoryManager;
this.GraphicsOptions = options;
}
@@ -69,13 +65,14 @@ namespace SixLabors.ImageSharp.Processing.Processors
int width = maxX - minX;
- using (IBuffer colors = this.memoryManager.Allocate(width))
- using (IBuffer amount = this.memoryManager.Allocate(width))
+ using (IBuffer colors = source.MemoryManager.Allocate(width))
+ using (IBuffer amount = source.MemoryManager.Allocate(width))
{
// Be careful! Do not capture colorSpan & amountSpan in the lambda below!
Span colorSpan = colors.Span;
Span amountSpan = amount.Span;
+ // TODO: Use Span.Fill?
for (int i = 0; i < width; i++)
{
colorSpan[i] = this.Value;
@@ -92,7 +89,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
Span destination = source.GetPixelRowSpan(y - startY).Slice(minX - startX, width);
// This switched color & destination in the 2nd and 3rd places because we are applying the target color under the current one
- blender.Blend(this.memoryManager, destination, colors.Span, destination, amount.Span);
+ blender.Blend(source.MemoryManager, destination, colors.Span, destination, amount.Span);
});
}
}
diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs
similarity index 98%
rename from src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs
rename to src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs
index abd0c15bb..7477c1390 100644
--- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs
+++ b/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs
@@ -11,7 +11,7 @@ using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives;
using SixLabors.Primitives;
-namespace SixLabors.ImageSharp.Processing.Processors.Overlays
+namespace SixLabors.ImageSharp.Processing.Overlays.Processors
{
///
/// An that applies a radial glow effect an .
diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs
similarity index 99%
rename from src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs
rename to src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs
index ad73b6553..bca63b314 100644
--- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs
+++ b/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs
@@ -11,7 +11,7 @@ using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives;
using SixLabors.Primitives;
-namespace SixLabors.ImageSharp.Processing.Processors.Overlays
+namespace SixLabors.ImageSharp.Processing.Overlays.Processors
{
///
/// An that applies a radial vignette effect to an .
diff --git a/src/ImageSharp/Processing/Overlays/Vignette.cs b/src/ImageSharp/Processing/Overlays/VignetteExtensions.cs
similarity index 85%
rename from src/ImageSharp/Processing/Overlays/Vignette.cs
rename to src/ImageSharp/Processing/Overlays/VignetteExtensions.cs
index 4df53f14e..e533c914f 100644
--- a/src/ImageSharp/Processing/Overlays/Vignette.cs
+++ b/src/ImageSharp/Processing/Overlays/VignetteExtensions.cs
@@ -3,16 +3,15 @@
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives;
-using SixLabors.ImageSharp.Processing.Processors;
-using SixLabors.ImageSharp.Processing.Processors.Overlays;
+using SixLabors.ImageSharp.Processing.Overlays.Processors;
using SixLabors.Primitives;
-namespace SixLabors.ImageSharp
+namespace SixLabors.ImageSharp.Processing.Overlays
{
///
- /// Extension methods for the type.
+ /// Adds extensions that allow the application of a radial glow to the type.
///
- public static partial class ImageExtensions
+ public static class VignetteExtensions
{
///
/// Applies a radial vignette effect to an image.
@@ -22,9 +21,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Vignette(this IImageProcessingContext source)
where TPixel : struct, IPixel
- {
- return Vignette(source, GraphicsOptions.Default);
- }
+ => Vignette(source, GraphicsOptions.Default);
///
/// Applies a radial vignette effect to an image.
@@ -35,9 +32,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Vignette(this IImageProcessingContext source, TPixel color)
where TPixel : struct, IPixel
- {
- return Vignette(source, color, GraphicsOptions.Default);
- }
+ => Vignette(source, color, GraphicsOptions.Default);
///
/// Applies a radial vignette effect to an image.
@@ -49,9 +44,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Vignette(this IImageProcessingContext source, float radiusX, float radiusY)
where TPixel : struct, IPixel
- {
- return Vignette(source, radiusX, radiusY, GraphicsOptions.Default);
- }
+ => Vignette(source, radiusX, radiusY, GraphicsOptions.Default);
///
/// Applies a radial vignette effect to an image.
@@ -64,9 +57,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Vignette(this IImageProcessingContext source, Rectangle rectangle)
where TPixel : struct, IPixel
- {
- return Vignette(source, rectangle, GraphicsOptions.Default);
- }
+ => Vignette(source, rectangle, GraphicsOptions.Default);
///
/// Applies a radial vignette effect to an image.
@@ -82,7 +73,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Vignette(this IImageProcessingContext source, TPixel color, float radiusX, float radiusY, Rectangle rectangle)
where TPixel : struct, IPixel
- => source.Vignette(color, radiusX, radiusY, rectangle, GraphicsOptions.Default);
+ => source.Vignette(color, radiusX, radiusY, rectangle, GraphicsOptions.Default);
///
/// Applies a radial vignette effect to an image.
@@ -93,7 +84,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Vignette(this IImageProcessingContext source, GraphicsOptions options)
where TPixel : struct, IPixel
- => source.VignetteInternal(NamedColors.Black, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), options);
+ => source.VignetteInternal(NamedColors.Black, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), options);
///
/// Applies a radial vignette effect to an image.
@@ -105,7 +96,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Vignette(this IImageProcessingContext source, TPixel color, GraphicsOptions options)
where TPixel : struct, IPixel
- => source.VignetteInternal(color, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), options);
+ => source.VignetteInternal(color, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), options);
///
/// Applies a radial vignette effect to an image.
@@ -118,7 +109,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Vignette(this IImageProcessingContext source, float radiusX, float radiusY, GraphicsOptions options)
where TPixel : struct, IPixel
- => source.VignetteInternal(NamedColors.Black, radiusX, radiusY, options);
+ => source.VignetteInternal(NamedColors.Black, radiusX, radiusY, options);
///
/// Applies a radial vignette effect to an image.
@@ -132,7 +123,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Vignette(this IImageProcessingContext source, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel
- => source.VignetteInternal(NamedColors.Black, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), rectangle, options);
+ => source.VignetteInternal(NamedColors.Black, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), rectangle, options);
///
/// Applies a radial vignette effect to an image.
@@ -149,7 +140,7 @@ namespace SixLabors.ImageSharp
/// The .
public static IImageProcessingContext Vignette(this IImageProcessingContext source, TPixel color, float radiusX, float radiusY, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel
- => source.VignetteInternal(color, radiusX, radiusY, rectangle, options);
+ => source.VignetteInternal(color, radiusX, radiusY, rectangle, options);
private static IImageProcessingContext VignetteInternal(this IImageProcessingContext source, TPixel color, ValueSize radiusX, ValueSize radiusY, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel
diff --git a/src/ImageSharp/ApplyProcessors.cs b/src/ImageSharp/Processing/ProcessingExtensions.cs
similarity index 73%
rename from src/ImageSharp/ApplyProcessors.cs
rename to src/ImageSharp/Processing/ProcessingExtensions.cs
index c4954ef0d..97faab88f 100644
--- a/src/ImageSharp/ApplyProcessors.cs
+++ b/src/ImageSharp/Processing/ProcessingExtensions.cs
@@ -4,14 +4,27 @@
using System;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Processors;
-namespace SixLabors.ImageSharp
+namespace SixLabors.ImageSharp.Processing
{
///
- /// Extension methods for the type.
+ /// Adds extensions that allow the processing of images to the type.
///
- public static partial class ImageExtensions
+ public static class ProcessingExtensions
{
+ ///
+ /// Applies the given operation to the mutable image.
+ /// Useful when we need to extract information like Width/Height to parametrize the next operation working on the chain.
+ /// To achieve this the method actually implements an "inline" with as it's processing logic.
+ ///
+ /// The pixel format.
+ /// The image to mutate.
+ /// The operation to perform on the source.
+ /// The to allow chaining of operations.
+ public static IImageProcessingContext Apply(this IImageProcessingContext source, Action> operation)
+ where TPixel : struct, IPixel => source.ApplyProcessor(new DelegateProcessor(operation));
+
///
/// Mutates the source image by applying the image operation to it.
///
@@ -52,7 +65,7 @@ namespace SixLabors.ImageSharp
/// The pixel format.
/// The image to clone.
/// The operation to perform on the clone.
- /// The new
+ /// The new
public static Image Clone(this Image source, Action> operation)
where TPixel : struct, IPixel
{
@@ -70,7 +83,7 @@ namespace SixLabors.ImageSharp
/// The pixel format.
/// The image to clone.
/// The operations to perform on the clone.
- /// The new
+ /// The new
public static Image Clone(this Image source, params IImageProcessor[] operations)
where TPixel : struct, IPixel
{
@@ -83,14 +96,14 @@ namespace SixLabors.ImageSharp
}
///
- /// Applies the given collection against the context
+ /// Applies the given collection against the context
///
/// The pixel format.
/// The image processing context.
/// The operations to perform on the source.
- /// The to allow chaining of operations.
+ /// The to allow chaining of operations.
public static IImageProcessingContext ApplyProcessors(this IImageProcessingContext source, params IImageProcessor[] operations)
- where TPixel : struct, IPixel
+ where TPixel : struct, IPixel
{
foreach (IImageProcessor p in operations)
{
diff --git a/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs b/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs
index a089ffe1a..e7a9fc3f7 100644
--- a/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs
@@ -6,10 +6,10 @@ using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
-namespace SixLabors.ImageSharp.Processing
+namespace SixLabors.ImageSharp.Processing.Processors
{
///
- /// Allows the application of processors to images.
+ /// Allows the application of processing algorithms to a clone of the original image.
///
/// The pixel format.
internal abstract class CloningImageProcessor : ICloningImageProcessor
diff --git a/src/ImageSharp/Processing/Processors/DelegateProcessor.cs b/src/ImageSharp/Processing/Processors/DelegateProcessor.cs
index 0bfc14977..2ff00d583 100644
--- a/src/ImageSharp/Processing/Processors/DelegateProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/DelegateProcessor.cs
@@ -5,10 +5,10 @@ using System;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
-namespace SixLabors.ImageSharp.Processing
+namespace SixLabors.ImageSharp.Processing.Processors
{
///
- /// Allows the application of processors to images.
+ /// Allows the application of processing algorithms to images via an action delegate
///
/// The pixel format.
internal class DelegateProcessor : ImageProcessor
diff --git a/src/ImageSharp/Quantizers/Box.cs b/src/ImageSharp/Processing/Quantization/Box.cs
similarity index 100%
rename from src/ImageSharp/Quantizers/Box.cs
rename to src/ImageSharp/Processing/Quantization/Box.cs
diff --git a/src/ImageSharp/Quantizers/IQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs
similarity index 100%
rename from src/ImageSharp/Quantizers/IQuantizer{TPixel}.cs
rename to src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs
diff --git a/src/ImageSharp/Quantizers/OctreeQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/OctreeQuantizer{TPixel}.cs
similarity index 100%
rename from src/ImageSharp/Quantizers/OctreeQuantizer{TPixel}.cs
rename to src/ImageSharp/Processing/Quantization/OctreeQuantizer{TPixel}.cs
diff --git a/src/ImageSharp/Quantizers/PaletteQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/PaletteQuantizer{TPixel}.cs
similarity index 100%
rename from src/ImageSharp/Quantizers/PaletteQuantizer{TPixel}.cs
rename to src/ImageSharp/Processing/Quantization/PaletteQuantizer{TPixel}.cs
diff --git a/src/ImageSharp/Quantizers/Quantization.cs b/src/ImageSharp/Processing/Quantization/Quantization.cs
similarity index 100%
rename from src/ImageSharp/Quantizers/Quantization.cs
rename to src/ImageSharp/Processing/Quantization/Quantization.cs
diff --git a/src/ImageSharp/Quantizers/Quantize.cs b/src/ImageSharp/Processing/Quantization/Quantize.cs
similarity index 98%
rename from src/ImageSharp/Quantizers/Quantize.cs
rename to src/ImageSharp/Processing/Quantization/Quantize.cs
index f2a09abb7..70e2814d8 100644
--- a/src/ImageSharp/Quantizers/Quantize.cs
+++ b/src/ImageSharp/Processing/Quantization/Quantize.cs
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Quantizers;
namespace SixLabors.ImageSharp
diff --git a/src/ImageSharp/Quantizers/QuantizedImage{TPixel}.cs b/src/ImageSharp/Processing/Quantization/QuantizedImage{TPixel}.cs
similarity index 100%
rename from src/ImageSharp/Quantizers/QuantizedImage{TPixel}.cs
rename to src/ImageSharp/Processing/Quantization/QuantizedImage{TPixel}.cs
diff --git a/src/ImageSharp/Quantizers/QuantizerBase{TPixel}.cs b/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs
similarity index 100%
rename from src/ImageSharp/Quantizers/QuantizerBase{TPixel}.cs
rename to src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs
diff --git a/src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/WuQuantizer{TPixel}.cs
similarity index 100%
rename from src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs
rename to src/ImageSharp/Processing/Quantization/WuQuantizer{TPixel}.cs
diff --git a/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs
similarity index 100%
rename from src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor.cs
rename to src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs
diff --git a/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/AutoOrientProcessor.cs
similarity index 100%
rename from src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs
rename to src/ImageSharp/Processing/Transforms/Processors/AutoOrientProcessor.cs
diff --git a/src/ImageSharp/Processing/Processors/Transforms/CenteredAffineTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs
similarity index 100%
rename from src/ImageSharp/Processing/Processors/Transforms/CenteredAffineTransformProcessor.cs
rename to src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs
diff --git a/src/ImageSharp/Processing/Processors/Transforms/CenteredProjectiveTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs
similarity index 100%
rename from src/ImageSharp/Processing/Processors/Transforms/CenteredProjectiveTransformProcessor.cs
rename to src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs
diff --git a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/CropProcessor.cs
similarity index 100%
rename from src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs
rename to src/ImageSharp/Processing/Transforms/Processors/CropProcessor.cs
diff --git a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/EntropyCropProcessor.cs
similarity index 100%
rename from src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs
rename to src/ImageSharp/Processing/Transforms/Processors/EntropyCropProcessor.cs
diff --git a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs
similarity index 100%
rename from src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs
rename to src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs
diff --git a/src/ImageSharp/Processing/Processors/Transforms/InterpolatedTransformProcessorBase.cs b/src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs
similarity index 100%
rename from src/ImageSharp/Processing/Processors/Transforms/InterpolatedTransformProcessorBase.cs
rename to src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs
diff --git a/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs
similarity index 100%
rename from src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs
rename to src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs
diff --git a/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs
similarity index 100%
rename from src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs
rename to src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs
diff --git a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs
similarity index 100%
rename from src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs
rename to src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs
diff --git a/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs
similarity index 100%
rename from src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs
rename to src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs
diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformProcessorBase.cs b/src/ImageSharp/Processing/Transforms/Processors/TransformProcessorBase.cs
similarity index 100%
rename from src/ImageSharp/Processing/Processors/Transforms/TransformProcessorBase.cs
rename to src/ImageSharp/Processing/Transforms/Processors/TransformProcessorBase.cs
diff --git a/src/ImageSharp/Processing/Processors/Transforms/WeightsBuffer.cs b/src/ImageSharp/Processing/Transforms/Processors/WeightsBuffer.cs
similarity index 100%
rename from src/ImageSharp/Processing/Processors/Transforms/WeightsBuffer.cs
rename to src/ImageSharp/Processing/Transforms/Processors/WeightsBuffer.cs
diff --git a/src/ImageSharp/Processing/Processors/Transforms/WeightsWindow.cs b/src/ImageSharp/Processing/Transforms/Processors/WeightsWindow.cs
similarity index 100%
rename from src/ImageSharp/Processing/Processors/Transforms/WeightsWindow.cs
rename to src/ImageSharp/Processing/Transforms/Processors/WeightsWindow.cs
diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs
index ce1a88599..a8042c77c 100644
--- a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs
+++ b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs
@@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
- using SixLabors.ImageSharp.PixelFormats;
+ using SixLabors.ImageSharp.Processing;
public class DrawBeziers : BenchmarkBase
{
diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs
index 4f40c001d..f89d9a684 100644
--- a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs
+++ b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs
@@ -13,6 +13,7 @@ namespace SixLabors.ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.PixelFormats;
+ using SixLabors.ImageSharp.Processing;
public class DrawLines : BenchmarkBase
{
diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs
index fd8e4ad28..aa24088ae 100644
--- a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs
+++ b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs
@@ -14,6 +14,7 @@ namespace SixLabors.ImageSharp.Benchmarks
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
+ using SixLabors.ImageSharp.Processing;
public class DrawPolygon : BenchmarkBase
{
diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs
index f948c4921..9075e02e8 100644
--- a/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs
+++ b/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs
@@ -14,6 +14,7 @@ namespace SixLabors.ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.PixelFormats;
+ using SixLabors.ImageSharp.Processing;
public class FillPolygon : BenchmarkBase
{
diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs b/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs
index b3890c101..1fd2dbe82 100644
--- a/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs
+++ b/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs
@@ -15,6 +15,7 @@ namespace SixLabors.ImageSharp.Benchmarks
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
+ using SixLabors.ImageSharp.Processing;
public class FillRectangle : BenchmarkBase
{
@@ -39,7 +40,7 @@ namespace SixLabors.ImageSharp.Benchmarks
{
using (Image image = new Image(800, 800))
{
- image.Mutate(x => x.Fill(Rgba32.HotPink, new CoreRectangle(10, 10, 190, 140)));
+ image.Mutate(x => x.Fill(Rgba32.HotPink, new CoreRectangle(10, 10, 190, 140)));
return new CoreSize(image.Width, image.Height);
}
@@ -53,10 +54,10 @@ namespace SixLabors.ImageSharp.Benchmarks
image.Mutate(x => x.FillPolygon(
Rgba32.HotPink,
new SixLabors.Primitives.PointF[] {
- new Vector2(10, 10),
- new Vector2(200, 10),
- new Vector2(200, 150),
- new Vector2(10, 150) }));
+ new Vector2(10, 10),
+ new Vector2(200, 10),
+ new Vector2(200, 150),
+ new Vector2(10, 150) }));
return new CoreSize(image.Width, image.Height);
}
diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs b/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs
index 46d02e419..64132e479 100644
--- a/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs
+++ b/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs
@@ -14,6 +14,7 @@ namespace SixLabors.ImageSharp.Benchmarks
using SixLabors.ImageSharp.Drawing.Brushes;
using CoreBrushes = ImageSharp.Drawing.Brushes.Brushes;
using SixLabors.ImageSharp.PixelFormats;
+ using SixLabors.ImageSharp.Processing;
public class FillWithPattern
{
diff --git a/tests/ImageSharp.Benchmarks/Samplers/Crop.cs b/tests/ImageSharp.Benchmarks/Samplers/Crop.cs
index 3681ff6f2..17c3933c0 100644
--- a/tests/ImageSharp.Benchmarks/Samplers/Crop.cs
+++ b/tests/ImageSharp.Benchmarks/Samplers/Crop.cs
@@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.PixelFormats;
+ using SixLabors.ImageSharp.Processing;
using CoreSize = SixLabors.Primitives.Size;
diff --git a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs
index b14630cea..2771aa2e0 100644
--- a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs
+++ b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs
@@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.PixelFormats;
- using SixLabors.ImageSharp.Processing.Processors;
+
using CoreSize = SixLabors.Primitives.Size;
using SixLabors.ImageSharp.Processing;
using System.Numerics;
@@ -18,8 +18,7 @@ namespace SixLabors.ImageSharp.Benchmarks
using SixLabors.ImageSharp.Memory;
using SixLabors.Primitives;
using SixLabors.ImageSharp.Helpers;
- using SixLabors.ImageSharp.Advanced;
- using SixLabors.ImageSharp.Processing.Processors.Overlays;
+ using SixLabors.ImageSharp.Processing.Overlays.Processors;
public class Glow : BenchmarkBase
{
diff --git a/tests/ImageSharp.Benchmarks/Samplers/Resize.cs b/tests/ImageSharp.Benchmarks/Samplers/Resize.cs
index 6e7e2c8c4..8bba227c5 100644
--- a/tests/ImageSharp.Benchmarks/Samplers/Resize.cs
+++ b/tests/ImageSharp.Benchmarks/Samplers/Resize.cs
@@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.PixelFormats;
+ using SixLabors.ImageSharp.Processing;
using CoreSize = SixLabors.Primitives.Size;
diff --git a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs
index 5ffd9f5f1..af1364af4 100644
--- a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs
+++ b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs
@@ -12,6 +12,9 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
+ using SixLabors.ImageSharp.Processing;
+ using SixLabors.ImageSharp.Processing.Overlays;
+
public class Beziers : FileTestBase
{
[Fact]
diff --git a/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs b/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs
index df029d2d7..bea0d8b07 100644
--- a/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs
+++ b/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs
@@ -11,6 +11,8 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
+ using SixLabors.ImageSharp.Processing;
+
public class BlendedShapes
{
public static IEnumerable