diff --git a/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs
index e217fd9a6c..e1dbefdb66 100644
--- a/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs
+++ b/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs
@@ -60,10 +60,10 @@ public class DrawImageProcessor : IImageProcessor
public float Opacity { get; }
///
- public IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixelBg : struct, IPixel
{
- var visitor = new ProcessorFactoryVisitor(this, source, sourceRectangle);
+ var visitor = new ProcessorFactoryVisitor(configuration, this, source, sourceRectangle);
this.Image.AcceptVisitor(visitor);
return visitor.Result;
}
@@ -71,12 +71,14 @@ public IImageProcessor CreatePixelSpecificProcessor(Image : IImageVisitor
where TPixelBg : struct, IPixel
{
+ private readonly Configuration configuration;
private readonly DrawImageProcessor definition;
private readonly Image source;
private readonly Rectangle sourceRectangle;
- public ProcessorFactoryVisitor(DrawImageProcessor definition, Image source, Rectangle sourceRectangle)
+ public ProcessorFactoryVisitor(Configuration configuration, DrawImageProcessor definition, Image source, Rectangle sourceRectangle)
{
+ this.configuration = configuration;
this.definition = definition;
this.source = source;
this.sourceRectangle = sourceRectangle;
@@ -88,6 +90,7 @@ public void Visit(Image image)
where TPixelFg : struct, IPixel
{
this.Result = new DrawImageProcessor(
+ this.configuration,
image,
this.source,
this.sourceRectangle,
diff --git a/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs b/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs
index eab6b2f4a1..55f72c7fc9 100644
--- a/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs
+++ b/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs
@@ -22,6 +22,7 @@ internal class DrawImageProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The foreground to blend with the currently processing image.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
@@ -30,6 +31,7 @@ internal class DrawImageProcessor : ImageProcessor
/// The Alpha blending mode to use when drawing the image.
/// The opacity of the image to blend. Must be between 0 and 1.
public DrawImageProcessor(
+ Configuration configuration,
Image image,
Image source,
Rectangle sourceRectangle,
@@ -37,7 +39,7 @@ internal class DrawImageProcessor : ImageProcessor
PixelColorBlendingMode colorBlendingMode,
PixelAlphaCompositionMode alphaCompositionMode,
float opacity)
- : base(source, sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
diff --git a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs
index 3963f99a5c..c94e0c179b 100644
--- a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs
+++ b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs
@@ -34,10 +34,8 @@ public FillProcessor(GraphicsOptions options, IBrush brush)
public GraphicsOptions Options { get; }
///
- public IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel
- {
- return new FillProcessor(this, source, sourceRectangle);
- }
+ => new FillProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor{TPixel}.cs
index fc94826187..524b66e05a 100644
--- a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor{TPixel}.cs
+++ b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor{TPixel}.cs
@@ -6,7 +6,6 @@
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
-using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
@@ -21,8 +20,8 @@ internal class FillProcessor : ImageProcessor
{
private readonly FillProcessor definition;
- public FillProcessor(FillProcessor definition, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ public FillProcessor(Configuration configuration, FillProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.definition = definition;
}
@@ -112,7 +111,7 @@ private bool IsSolidBrushWithoutBlending(out SolidBrush solidBrush)
{
solidBrush = this.definition.Brush as SolidBrush;
- if (solidBrush == null)
+ if (solidBrush is null)
{
return false;
}
diff --git a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor.cs b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor.cs
index 7d51be1c51..6cfeb785ce 100644
--- a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor.cs
+++ b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor.cs
@@ -42,10 +42,8 @@ public FillRegionProcessor(GraphicsOptions options, IBrush brush, Region region)
public GraphicsOptions Options { get; }
///
- public IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel
- {
- return new FillRegionProcessor(this, source, sourceRectangle);
- }
+ => new FillRegionProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs
index 4744a4e920..7d632ad23d 100644
--- a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs
+++ b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs
@@ -23,8 +23,8 @@ internal class FillRegionProcessor : ImageProcessor
{
private readonly FillRegionProcessor definition;
- public FillRegionProcessor(FillRegionProcessor definition, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ public FillRegionProcessor(Configuration configuration, FillRegionProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.definition = definition;
}
diff --git a/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor.cs b/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor.cs
index 775cf55abf..75774a6285 100644
--- a/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor.cs
+++ b/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor.cs
@@ -72,10 +72,8 @@ public DrawTextProcessor(TextGraphicsOptions options, string text, Font font, IB
public PointF Location { get; }
///
- public IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel
- {
- return new DrawTextProcessor(this, source, sourceRectangle);
- }
+ => new DrawTextProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs
index 64d32efb80..c47f764a29 100644
--- a/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs
+++ b/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs
@@ -27,8 +27,8 @@ internal class DrawTextProcessor : ImageProcessor
private readonly DrawTextProcessor definition;
- public DrawTextProcessor(DrawTextProcessor definition, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ public DrawTextProcessor(Configuration configuration, DrawTextProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.definition = definition;
}
diff --git a/src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs b/src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs
index 328ccdf941..5d986b6ccc 100644
--- a/src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs
+++ b/src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs
@@ -1,10 +1,8 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
-using SixLabors.Memory;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
@@ -23,10 +21,12 @@ internal class DefaultImageProcessorContext : IInternalImageProcessingCo
///
/// Initializes a new instance of the class.
///
- /// The image.
- /// The mutate.
- public DefaultImageProcessorContext(Image source, bool mutate)
+ /// The configuration which allows altering default behaviour or extending the library.
+ /// The source image.
+ /// Whether to mutate the image.
+ public DefaultImageProcessorContext(Configuration configuration, Image source, bool mutate)
{
+ this.Configuration = configuration;
this.mutate = mutate;
this.source = source;
@@ -38,7 +38,7 @@ public DefaultImageProcessorContext(Image source, bool mutate)
}
///
- public MemoryAllocator MemoryAllocator => this.source.GetConfiguration().MemoryAllocator;
+ public Configuration Configuration { get; }
///
public Image GetResultImage()
@@ -71,7 +71,7 @@ public IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectang
// interim clone if the first processor in the pipeline is a cloning processor.
if (processor is ICloningImageProcessor cloningImageProcessor)
{
- using (ICloningImageProcessor pixelProcessor = cloningImageProcessor.CreatePixelSpecificCloningProcessor(this.source, rectangle))
+ using (ICloningImageProcessor pixelProcessor = cloningImageProcessor.CreatePixelSpecificCloningProcessor(this.Configuration, this.source, rectangle))
{
this.destination = pixelProcessor.CloneAndExecute();
return this;
@@ -83,7 +83,7 @@ public IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectang
}
// Standard processing pipeline.
- using (IImageProcessor specificProcessor = processor.CreatePixelSpecificProcessor(this.destination, rectangle))
+ using (IImageProcessor specificProcessor = processor.CreatePixelSpecificProcessor(this.Configuration, this.destination, rectangle))
{
specificProcessor.Execute();
}
diff --git a/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs b/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs
index 40b1c439e6..36966c2966 100644
--- a/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs
+++ b/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs
@@ -20,12 +20,22 @@ public static class ProcessingExtensions
/// The image to mutate.
/// The operation to perform on the source.
public static void Mutate(this Image source, Action operation)
+ => Mutate(source, source.GetConfiguration(), operation);
+
+ ///
+ /// Mutates the source image by applying the image operation to it.
+ ///
+ /// The image to mutate.
+ /// The configuration which allows altering default behaviour or extending the library.
+ /// The operation to perform on the source.
+ public static void Mutate(this Image source, Configuration configuration, Action operation)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.NotNull(source, nameof(source));
Guard.NotNull(operation, nameof(operation));
source.EnsureNotDisposed();
- source.AcceptVisitor(new ProcessingVisitor(operation, true));
+ source.AcceptVisitor(new ProcessingVisitor(configuration, operation, true));
}
///
@@ -36,14 +46,25 @@ public static void Mutate(this Image source, Action ope
/// The operation to perform on the source.
public static void Mutate(this Image source, Action operation)
where TPixel : struct, IPixel
+ => Mutate(source, source.GetConfiguration(), operation);
+
+ ///
+ /// Mutates the source image by applying the image operation to it.
+ ///
+ /// The pixel format.
+ /// The image to mutate.
+ /// The configuration which allows altering default behaviour or extending the library.
+ /// The operation to perform on the source.
+ public static void Mutate(this Image source, Configuration configuration, Action operation)
+ where TPixel : struct, IPixel
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.NotNull(source, nameof(source));
Guard.NotNull(operation, nameof(operation));
source.EnsureNotDisposed();
IInternalImageProcessingContext operationsRunner
- = source.GetConfiguration()
- .ImageOperationsProvider.CreateImageProcessingContext(source, true);
+ = configuration.ImageOperationsProvider.CreateImageProcessingContext(configuration, source, true);
operation(operationsRunner);
}
@@ -56,14 +77,24 @@ IInternalImageProcessingContext operationsRunner
/// The operations to perform on the source.
public static void Mutate(this Image source, params IImageProcessor[] operations)
where TPixel : struct, IPixel
+ => Mutate(source, source.GetConfiguration(), operations);
+
+ ///
+ /// Mutates the source image by applying the operations to it.
+ ///
+ /// The pixel format.
+ /// The image to mutate.
+ /// The configuration which allows altering default behaviour or extending the library.
+ /// The operations to perform on the source.
+ public static void Mutate(this Image source, Configuration configuration, params IImageProcessor[] operations)
+ where TPixel : struct, IPixel
{
Guard.NotNull(source, nameof(source));
Guard.NotNull(operations, nameof(operations));
source.EnsureNotDisposed();
IInternalImageProcessingContext operationsRunner
- = source.GetConfiguration()
- .ImageOperationsProvider.CreateImageProcessingContext(source, true);
+ = configuration.ImageOperationsProvider.CreateImageProcessingContext(configuration, source, true);
operationsRunner.ApplyProcessors(operations);
}
@@ -75,12 +106,23 @@ IInternalImageProcessingContext operationsRunner
/// The operation to perform on the clone.
/// The new .
public static Image Clone(this Image source, Action operation)
+ => Clone(source, source.GetConfiguration(), operation);
+
+ ///
+ /// Creates a deep clone of the current image. The clone is then mutated by the given operation.
+ ///
+ /// The image to clone.
+ /// The configuration which allows altering default behaviour or extending the library.
+ /// The operation to perform on the clone.
+ /// The new .
+ public static Image Clone(this Image source, Configuration configuration, Action operation)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.NotNull(source, nameof(source));
Guard.NotNull(operation, nameof(operation));
source.EnsureNotDisposed();
- var visitor = new ProcessingVisitor(operation, false);
+ var visitor = new ProcessingVisitor(configuration, operation, false);
source.AcceptVisitor(visitor);
return visitor.ResultImage;
}
@@ -94,14 +136,26 @@ public static Image Clone(this Image source, Action ope
/// The new
public static Image Clone(this Image source, Action operation)
where TPixel : struct, IPixel
+ => Clone(source, source.GetConfiguration(), operation);
+
+ ///
+ /// Creates a deep clone of the current image. The clone is then mutated by the given operation.
+ ///
+ /// The pixel format.
+ /// The image to clone.
+ /// The configuration which allows altering default behaviour or extending the library.
+ /// The operation to perform on the clone.
+ /// The new
+ public static Image Clone(this Image source, Configuration configuration, Action operation)
+ where TPixel : struct, IPixel
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.NotNull(source, nameof(source));
Guard.NotNull(operation, nameof(operation));
source.EnsureNotDisposed();
IInternalImageProcessingContext operationsRunner
- = source.GetConfiguration()
- .ImageOperationsProvider.CreateImageProcessingContext(source, false);
+ = configuration.ImageOperationsProvider.CreateImageProcessingContext(configuration, source, false);
operation(operationsRunner);
return operationsRunner.GetResultImage();
@@ -116,14 +170,26 @@ IInternalImageProcessingContext operationsRunner
/// The new
public static Image Clone(this Image source, params IImageProcessor[] operations)
where TPixel : struct, IPixel
+ => Clone(source, source.GetConfiguration(), operations);
+
+ ///
+ /// Creates a deep clone of the current image. The clone is then mutated by the given operations.
+ ///
+ /// The pixel format.
+ /// The image to clone.
+ /// The configuration which allows altering default behaviour or extending the library.
+ /// The operations to perform on the clone.
+ /// The new
+ public static Image Clone(this Image source, Configuration configuration, params IImageProcessor[] operations)
+ where TPixel : struct, IPixel
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.NotNull(source, nameof(source));
Guard.NotNull(operations, nameof(operations));
source.EnsureNotDisposed();
IInternalImageProcessingContext operationsRunner
- = source.GetConfiguration()
- .ImageOperationsProvider.CreateImageProcessingContext(source, false);
+ = configuration.ImageOperationsProvider.CreateImageProcessingContext(configuration, source, false);
operationsRunner.ApplyProcessors(operations);
return operationsRunner.GetResultImage();
@@ -149,12 +215,15 @@ IInternalImageProcessingContext operationsRunner
private class ProcessingVisitor : IImageVisitor
{
+ private readonly Configuration configuration;
+
private readonly Action operation;
private readonly bool mutate;
- public ProcessingVisitor(Action operation, bool mutate)
+ public ProcessingVisitor(Configuration configuration, Action operation, bool mutate)
{
+ this.configuration = configuration;
this.operation = operation;
this.mutate = mutate;
}
@@ -165,8 +234,7 @@ public void Visit(Image image)
where TPixel : struct, IPixel
{
IInternalImageProcessingContext operationsRunner =
- image.GetConfiguration()
- .ImageOperationsProvider.CreateImageProcessingContext(image, this.mutate);
+ this.configuration.ImageOperationsProvider.CreateImageProcessingContext(this.configuration, image, this.mutate);
this.operation(operationsRunner);
this.ResultImage = operationsRunner.GetResultImage();
diff --git a/src/ImageSharp/Processing/IImageProcessingContext.cs b/src/ImageSharp/Processing/IImageProcessingContext.cs
index 509b1313d9..e10c14088f 100644
--- a/src/ImageSharp/Processing/IImageProcessingContext.cs
+++ b/src/ImageSharp/Processing/IImageProcessingContext.cs
@@ -13,10 +13,9 @@ namespace SixLabors.ImageSharp.Processing
public interface IImageProcessingContext
{
///
- /// Gets a reference to the used to allocate buffers
- /// for this context.
+ /// Gets the configuration which allows altering default behaviour or extending the library.
///
- MemoryAllocator MemoryAllocator { get; }
+ Configuration Configuration { get; }
///
/// Gets the image dimensions at the current point in the processing pipeline.
@@ -39,4 +38,4 @@ public interface IImageProcessingContext
/// The current operations class to allow chaining of operations.
IImageProcessingContext ApplyProcessor(IImageProcessor processor);
}
-}
\ No newline at end of file
+}
diff --git a/src/ImageSharp/Processing/IImageProcessingContextFactory.cs b/src/ImageSharp/Processing/IImageProcessingContextFactory.cs
index 948e70b445..e3051ccdd9 100644
--- a/src/ImageSharp/Processing/IImageProcessingContextFactory.cs
+++ b/src/ImageSharp/Processing/IImageProcessingContextFactory.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Six Labors and contributors.
+// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
@@ -14,10 +14,11 @@ internal interface IImageProcessingContextFactory
/// Called during mutate operations to generate the image operations provider.
///
/// The pixel format
+ /// The configuration which allows altering default behaviour or extending the library.
/// The source image.
/// A flag to determine whether image operations are allowed to mutate the source image.
/// A new
- IInternalImageProcessingContext CreateImageProcessingContext(Image source, bool mutate)
+ IInternalImageProcessingContext CreateImageProcessingContext(Configuration configuration, Image source, bool mutate)
where TPixel : struct, IPixel;
}
@@ -27,10 +28,10 @@ IInternalImageProcessingContext CreateImageProcessingContext(Ima
internal class DefaultImageOperationsProviderFactory : IImageProcessingContextFactory
{
///
- public IInternalImageProcessingContext CreateImageProcessingContext(Image source, bool mutate)
+ public IInternalImageProcessingContext CreateImageProcessingContext(Configuration configuration, Image source, bool mutate)
where TPixel : struct, IPixel
{
- return new DefaultImageProcessorContext(source, mutate);
+ return new DefaultImageProcessorContext(configuration, source, mutate);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/ImageSharp/Processing/IInternalImageProcessingContext{TPixel}.cs b/src/ImageSharp/Processing/IInternalImageProcessingContext{TPixel}.cs
index 55303b1ef9..9d023cca84 100644
--- a/src/ImageSharp/Processing/IInternalImageProcessingContext{TPixel}.cs
+++ b/src/ImageSharp/Processing/IInternalImageProcessingContext{TPixel}.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Six Labors and contributors.
+// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
@@ -13,10 +13,10 @@ internal interface IInternalImageProcessingContext : IImageProcessingCon
where TPixel : struct, IPixel
{
///
- /// Returns the result image to return by
+ /// Returns the result image to return by
/// (and other overloads).
///
/// The current image or a new image depending on whether it is requested to mutate the source image.
Image GetResultImage();
}
-}
\ No newline at end of file
+}
diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor.cs
index 80164793b2..caedf87ba6 100644
--- a/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor.cs
@@ -70,8 +70,8 @@ public BinaryErrorDiffusionProcessor(IErrorDiffuser diffuser, float threshold, C
public Color LowerColor { get; }
///
- public IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel
- => new BinaryErrorDiffusionProcessor(this, source, sourceRectangle);
+ => new BinaryErrorDiffusionProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor{TPixel}.cs
index c59e77b10c..cdea1780fc 100644
--- a/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor{TPixel}.cs
@@ -22,11 +22,12 @@ internal sealed class BinaryErrorDiffusionProcessor : ImageProcessor
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The defining the processor parameters.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public BinaryErrorDiffusionProcessor(BinaryErrorDiffusionProcessor definition, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ public BinaryErrorDiffusionProcessor(Configuration configuration, BinaryErrorDiffusionProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.definition = definition;
}
diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs
index 0a426c893a..6a2ee7623e 100644
--- a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs
@@ -52,8 +52,8 @@ public BinaryOrderedDitherProcessor(IOrderedDither dither, Color upperColor, Col
public Color LowerColor { get; }
///
- public IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel
- => new BinaryOrderedDitherProcessor(this, source, sourceRectangle);
+ => new BinaryOrderedDitherProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor{TPixel}.cs
index d750c9f077..64fb617c6d 100644
--- a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor{TPixel}.cs
@@ -22,11 +22,12 @@ internal class BinaryOrderedDitherProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The defining the processor parameters.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public BinaryOrderedDitherProcessor(BinaryOrderedDitherProcessor definition, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ public BinaryOrderedDitherProcessor(Configuration configuration, BinaryOrderedDitherProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.definition = definition;
}
diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs
index a33c464694..102232b132 100644
--- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs
@@ -50,8 +50,8 @@ public BinaryThresholdProcessor(float threshold, Color upperColor, Color lowerCo
public Color LowerColor { get; }
///
- public IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel
- => new BinaryThresholdProcessor(this, source, sourceRectangle);
+ => new BinaryThresholdProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs
index 20a22fba3f..45cb1d9f70 100644
--- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs
@@ -22,11 +22,12 @@ internal class BinaryThresholdProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The defining the processor parameters.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public BinaryThresholdProcessor(BinaryThresholdProcessor definition, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ public BinaryThresholdProcessor(Configuration configuration, BinaryThresholdProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.definition = definition;
}
diff --git a/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs b/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs
index 5e9ca2e542..3b88cf7f07 100644
--- a/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs
@@ -12,11 +12,11 @@ namespace SixLabors.ImageSharp.Processing.Processors
public abstract class CloningImageProcessor : ICloningImageProcessor
{
///
- public abstract ICloningImageProcessor CreatePixelSpecificCloningProcessor(Image source, Rectangle sourceRectangle)
+ public abstract ICloningImageProcessor CreatePixelSpecificCloningProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel;
///
- IImageProcessor IImageProcessor.CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
- => this.CreatePixelSpecificCloningProcessor(source, sourceRectangle);
+ IImageProcessor IImageProcessor.CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
+ => this.CreatePixelSpecificCloningProcessor(configuration, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs
index 42d2f0e1df..8aef51c037 100644
--- a/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
@@ -22,13 +21,14 @@ public abstract class CloningImageProcessor : ICloningImageProcessor
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- protected CloningImageProcessor(Image source, Rectangle sourceRectangle)
+ protected CloningImageProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
{
+ this.Configuration = configuration;
this.Source = source;
this.SourceRectangle = sourceRectangle;
- this.Configuration = this.Source.GetConfiguration();
}
///
@@ -54,7 +54,7 @@ Image ICloningImageProcessor.CloneAndExecute()
Image clone = this.CreateTarget();
this.CheckFrameCount(this.Source, clone);
- Configuration configuration = this.Source.GetConfiguration();
+ Configuration configuration = this.Configuration;
this.BeforeImageApply(clone);
for (int i = 0; i < this.Source.Frames.Count; i++)
@@ -176,7 +176,7 @@ private Image CreateTarget()
// We will always be creating the clone even for mutate because we may need to resize the canvas
IEnumerable> frames = source.Frames.Select, ImageFrame>(
x => new ImageFrame(
- source.GetConfiguration(),
+ this.Configuration,
targetSize.Width,
targetSize.Height,
x.Metadata.DeepClone()));
diff --git a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs
index 1812884b8e..477c3da9ad 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs
@@ -71,10 +71,8 @@ public BokehBlurProcessor(int radius, int components, float gamma)
public float Gamma { get; }
///
- public IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel
- {
- return new BokehBlurProcessor(this, source, sourceRectangle);
- }
+ => new BokehBlurProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs
index efd18dafba..6ffda59a85 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs
@@ -69,11 +69,12 @@ internal class BokehBlurProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The defining the processor parameters.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public BokehBlurProcessor(BokehBlurProcessor definition, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ public BokehBlurProcessor(Configuration configuration, BokehBlurProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.radius = definition.Radius;
this.kernelSize = (this.radius * 2) + 1;
diff --git a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs
index a5368c4639..94ecce9d1a 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs
@@ -7,7 +7,7 @@
namespace SixLabors.ImageSharp.Processing.Processors.Convolution
{
///
- /// Defines a box blur processor of a given Radius.
+ /// Defines a box blur processor of a given radius.
///
public sealed class BoxBlurProcessor : IImageProcessor
{
@@ -41,10 +41,8 @@ public BoxBlurProcessor()
public int Radius { get; }
///
- public IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel
- {
- return new BoxBlurProcessor(this, source, sourceRectangle);
- }
+ => new BoxBlurProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs
index 77110e642d..f127fc1a8a 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs
@@ -14,18 +14,16 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
internal class BoxBlurProcessor : ImageProcessor
where TPixel : struct, IPixel
{
- private readonly BoxBlurProcessor definition;
-
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The defining the processor parameters.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public BoxBlurProcessor(BoxBlurProcessor definition, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ public BoxBlurProcessor(Configuration configuration, BoxBlurProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
- this.definition = definition;
int kernelSize = (definition.Radius * 2) + 1;
this.KernelX = CreateBoxKernel(kernelSize);
this.KernelY = this.KernelX.Transpose();
@@ -44,7 +42,7 @@ public BoxBlurProcessor(BoxBlurProcessor definition, Image source, Recta
///
protected override void OnFrameApply(ImageFrame source)
{
- using (var processor = new Convolution2PassProcessor(this.KernelX, this.KernelY, false, this.Source, this.SourceRectangle))
+ using (var processor = new Convolution2PassProcessor(this.Configuration, this.KernelX, this.KernelY, false, this.Source, this.SourceRectangle))
{
processor.Apply(source);
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs
index 4419f064e5..44faf3eb1b 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs
@@ -23,18 +23,20 @@ internal class Convolution2DProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The horizontal gradient operator.
/// The vertical gradient operator.
/// Whether the convolution filter is applied to alpha as well as the color channels.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
public Convolution2DProcessor(
+ Configuration configuration,
in DenseMatrix kernelX,
in DenseMatrix kernelY,
bool preserveAlpha,
Image source,
Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
Guard.IsTrue(kernelX.Size.Equals(kernelY.Size), $"{nameof(kernelX)} {nameof(kernelY)}", "Kernel sizes must be the same.");
this.KernelX = kernelX;
diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs
index 9fad8b5b73..5182d90b16 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs
@@ -23,18 +23,20 @@ internal class Convolution2PassProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The horizontal gradient operator.
/// The vertical gradient operator.
/// Whether the convolution filter is applied to alpha as well as the color channels.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
public Convolution2PassProcessor(
+ Configuration configuration,
in DenseMatrix kernelX,
in DenseMatrix kernelY,
bool preserveAlpha,
Image source,
Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.KernelX = kernelX;
this.KernelY = kernelY;
diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs
index f657e131dd..6f0e7914b0 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs
@@ -23,16 +23,18 @@ internal class ConvolutionProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The 2d gradient operator.
/// Whether the convolution filter is applied to alpha as well as the color channels.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
public ConvolutionProcessor(
+ Configuration configuration,
in DenseMatrix kernelXY,
bool preserveAlpha,
Image source,
Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.KernelXY = kernelXY;
this.PreserveAlpha = preserveAlpha;
diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs
index 8358abe7df..dbd82191c4 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs
@@ -18,18 +18,20 @@ internal class EdgeDetector2DProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The horizontal gradient operator.
/// The vertical gradient operator.
/// Whether to convert the image to grayscale before performing edge detection.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
internal EdgeDetector2DProcessor(
+ Configuration configuration,
in DenseMatrix kernelX,
in DenseMatrix kernelY,
bool grayscale,
Image source,
Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
Guard.IsTrue(kernelX.Size.Equals(kernelY.Size), $"{nameof(kernelX)} {nameof(kernelY)}", "Kernel sizes must be the same.");
this.KernelX = kernelX;
@@ -54,7 +56,7 @@ protected override void BeforeImageApply()
{
if (this.Grayscale)
{
- new GrayscaleBt709Processor(1F).Execute(this.Source, this.SourceRectangle);
+ new GrayscaleBt709Processor(1F).Execute(this.Configuration, this.Source, this.SourceRectangle);
}
base.BeforeImageApply();
@@ -63,7 +65,7 @@ protected override void BeforeImageApply()
///
protected override void OnFrameApply(ImageFrame source)
{
- using (var processor = new Convolution2DProcessor(this.KernelX, this.KernelY, true, this.Source, this.SourceRectangle))
+ using (var processor = new Convolution2DProcessor(this.Configuration, this.KernelX, this.KernelY, true, this.Source, this.SourceRectangle))
{
processor.Apply(source);
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs
index 4fa87bc98e..f3940bb730 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs
@@ -25,12 +25,13 @@ internal class EdgeDetectorCompassProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// Gets the kernels to use.
/// Whether to convert the image to grayscale before performing edge detection.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- internal EdgeDetectorCompassProcessor(CompassKernels kernels, bool grayscale, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ internal EdgeDetectorCompassProcessor(Configuration configuration, CompassKernels kernels, bool grayscale, Image source, Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.Grayscale = grayscale;
this.Kernels = kernels;
@@ -45,7 +46,7 @@ protected override void BeforeImageApply()
{
if (this.Grayscale)
{
- new GrayscaleBt709Processor(1F).Execute(this.Source, this.SourceRectangle);
+ new GrayscaleBt709Processor(1F).Execute(this.Configuration, this.Source, this.SourceRectangle);
}
base.BeforeImageApply();
@@ -70,7 +71,7 @@ protected override void OnFrameApply(ImageFrame source)
// we need a clean copy for each pass to start from
using (ImageFrame cleanCopy = source.Clone())
{
- using (var processor = new ConvolutionProcessor(kernels[0], true, this.Source, this.SourceRectangle))
+ using (var processor = new ConvolutionProcessor(this.Configuration, kernels[0], true, this.Source, this.SourceRectangle))
{
processor.Apply(source);
}
@@ -102,7 +103,7 @@ protected override void OnFrameApply(ImageFrame source)
{
using (ImageFrame pass = cleanCopy.Clone())
{
- using (var processor = new ConvolutionProcessor(kernels[i], true, this.Source, this.SourceRectangle))
+ using (var processor = new ConvolutionProcessor(this.Configuration, kernels[i], true, this.Source, this.SourceRectangle))
{
processor.Apply(pass);
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs
index 24b95da696..f369d60ddc 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs
@@ -26,7 +26,7 @@ protected EdgeDetectorProcessor(bool grayscale)
public bool Grayscale { get; }
///
- public abstract IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public abstract IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel;
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs
index 5246dc3b72..e6411f8cb6 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs
@@ -18,12 +18,18 @@ internal class EdgeDetectorProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The 2d gradient operator.
/// Whether to convert the image to grayscale before performing edge detection.
/// The source for the current processor instance.
/// The target area to process for the current processor instance.
- public EdgeDetectorProcessor(in DenseMatrix kernelXY, bool grayscale, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ public EdgeDetectorProcessor(
+ Configuration configuration,
+ in DenseMatrix kernelXY,
+ bool grayscale,
+ Image source,
+ Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.KernelXY = kernelXY;
this.Grayscale = grayscale;
@@ -41,7 +47,7 @@ protected override void BeforeImageApply()
{
if (this.Grayscale)
{
- new GrayscaleBt709Processor(1F).Execute(this.Source, this.SourceRectangle);
+ new GrayscaleBt709Processor(1F).Execute(this.Configuration, this.Source, this.SourceRectangle);
}
base.BeforeImageApply();
@@ -50,7 +56,7 @@ protected override void BeforeImageApply()
///
protected override void OnFrameApply(ImageFrame source)
{
- using (var processor = new ConvolutionProcessor(this.KernelXY, true, this.Source, this.SourceRectangle))
+ using (var processor = new ConvolutionProcessor(this.Configuration, this.KernelXY, true, this.Source, this.SourceRectangle))
{
processor.Apply(source);
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs
index aabc8041d9..bdba8f4caf 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs
@@ -71,10 +71,8 @@ public GaussianBlurProcessor(float sigma, int radius)
public int Radius { get; }
///
- public IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel
- {
- return new GaussianBlurProcessor(this, source, sourceRectangle);
- }
+ => new GaussianBlurProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor{TPixel}.cs
index bbf36ea5e8..2ccd8d577a 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor{TPixel}.cs
@@ -17,11 +17,16 @@ internal class GaussianBlurProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The defining the processor parameters.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public GaussianBlurProcessor(GaussianBlurProcessor definition, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ public GaussianBlurProcessor(
+ Configuration configuration,
+ GaussianBlurProcessor definition,
+ Image source,
+ Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
int kernelSize = (definition.Radius * 2) + 1;
this.KernelX = ConvolutionProcessorHelpers.CreateGaussianBlurKernel(kernelSize, definition.Sigma);
@@ -41,7 +46,7 @@ public GaussianBlurProcessor(GaussianBlurProcessor definition, Image sou
///
protected override void OnFrameApply(ImageFrame source)
{
- using (var processor = new Convolution2PassProcessor(this.KernelX, this.KernelY, false, this.Source, this.SourceRectangle))
+ using (var processor = new Convolution2PassProcessor(this.Configuration, this.KernelX, this.KernelY, false, this.Source, this.SourceRectangle))
{
processor.Apply(source);
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs
index 0262ec8e44..d1b2b3072c 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs
@@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
///
public sealed class GaussianSharpenProcessor : IImageProcessor
{
- ///
+ ///
/// The default value for .
///
public const float DefaultSigma = 3f;
@@ -71,10 +71,8 @@ public GaussianSharpenProcessor(float sigma, int radius)
public int Radius { get; }
///
- public IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel
- {
- return new GaussianSharpenProcessor(this, source, sourceRectangle);
- }
+ => new GaussianSharpenProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor{TPixel}.cs
index dab55b2328..d61d8e6c59 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor{TPixel}.cs
@@ -17,11 +17,16 @@ internal class GaussianSharpenProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The defining the processor parameters.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public GaussianSharpenProcessor(GaussianSharpenProcessor definition, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ public GaussianSharpenProcessor(
+ Configuration configuration,
+ GaussianSharpenProcessor definition,
+ Image source,
+ Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
int kernelSize = (definition.Radius * 2) + 1;
this.KernelX = ConvolutionProcessorHelpers.CreateGaussianSharpenKernel(kernelSize, definition.Sigma);
@@ -41,7 +46,7 @@ public GaussianSharpenProcessor(GaussianSharpenProcessor definition, Image
protected override void OnFrameApply(ImageFrame source)
{
- using (var processor = new Convolution2PassProcessor(this.KernelX, this.KernelY, false, this.Source, this.SourceRectangle))
+ using (var processor = new Convolution2PassProcessor(this.Configuration, this.KernelX, this.KernelY, false, this.Source, this.SourceRectangle))
{
processor.Apply(source);
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/KayyaliProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/KayyaliProcessor.cs
index 2026512617..cc29be9837 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/KayyaliProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/KayyaliProcessor.cs
@@ -21,14 +21,13 @@ public KayyaliProcessor(bool grayscale)
}
///
- public override IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
- {
- return new EdgeDetector2DProcessor(
+ public override IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
+ => new EdgeDetector2DProcessor(
+ configuration,
KayyaliKernels.KayyaliX,
KayyaliKernels.KayyaliY,
this.Grayscale,
source,
sourceRectangle);
- }
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/KirschProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/KirschProcessor.cs
index bbbfc64d92..182a30c08b 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/KirschProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/KirschProcessor.cs
@@ -21,9 +21,7 @@ public KirschProcessor(bool grayscale)
}
///
- public override IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
- {
- return new EdgeDetectorCompassProcessor(new KirschKernels(), this.Grayscale, source, sourceRectangle);
- }
+ public override IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
+ => new EdgeDetectorCompassProcessor(configuration, new KirschKernels(), this.Grayscale, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/Laplacian3x3Processor.cs b/src/ImageSharp/Processing/Processors/Convolution/Laplacian3x3Processor.cs
index 64f99ebe61..163420f3d4 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/Laplacian3x3Processor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/Laplacian3x3Processor.cs
@@ -21,9 +21,7 @@ public Laplacian3x3Processor(bool grayscale)
}
///
- public override IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
- {
- return new EdgeDetectorProcessor(LaplacianKernels.Laplacian3x3, this.Grayscale, source, sourceRectangle);
- }
+ public override IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
+ => new EdgeDetectorProcessor(configuration, LaplacianKernels.Laplacian3x3, this.Grayscale, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/Laplacian5x5Processor.cs b/src/ImageSharp/Processing/Processors/Convolution/Laplacian5x5Processor.cs
index d1c909a941..77cfffced2 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/Laplacian5x5Processor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/Laplacian5x5Processor.cs
@@ -21,9 +21,7 @@ public Laplacian5x5Processor(bool grayscale)
}
///
- public override IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
- {
- return new EdgeDetectorProcessor(LaplacianKernels.Laplacian5x5, this.Grayscale, source, sourceRectangle);
- }
+ public override IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
+ => new EdgeDetectorProcessor(configuration, LaplacianKernels.Laplacian5x5, this.Grayscale, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/LaplacianOfGaussianProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/LaplacianOfGaussianProcessor.cs
index 0eecaefe16..a8d3ff6f1b 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/LaplacianOfGaussianProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/LaplacianOfGaussianProcessor.cs
@@ -21,9 +21,7 @@ public LaplacianOfGaussianProcessor(bool grayscale)
}
///
- public override IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
- {
- return new EdgeDetectorProcessor(LaplacianKernels.LaplacianOfGaussianXY, this.Grayscale, source, sourceRectangle);
- }
+ public override IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
+ => new EdgeDetectorProcessor(configuration, LaplacianKernels.LaplacianOfGaussianXY, this.Grayscale, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/PrewittProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/PrewittProcessor.cs
index 242e3f7b97..dcb20573a8 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/PrewittProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/PrewittProcessor.cs
@@ -21,9 +21,13 @@ public PrewittProcessor(bool grayscale)
}
///
- public override IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
- {
- return new EdgeDetector2DProcessor(PrewittKernels.PrewittX, PrewittKernels.PrewittY, this.Grayscale, source, sourceRectangle);
- }
+ public override IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
+ => new EdgeDetector2DProcessor(
+ configuration,
+ PrewittKernels.PrewittX,
+ PrewittKernels.PrewittY,
+ this.Grayscale,
+ source,
+ sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/RobertsCrossProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/RobertsCrossProcessor.cs
index 481a990ff9..84b6854676 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/RobertsCrossProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/RobertsCrossProcessor.cs
@@ -21,14 +21,13 @@ public RobertsCrossProcessor(bool grayscale)
}
///
- public override IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
- {
- return new EdgeDetector2DProcessor(
+ public override IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
+ => new EdgeDetector2DProcessor(
+ configuration,
RobertsCrossKernels.RobertsCrossX,
RobertsCrossKernels.RobertsCrossY,
this.Grayscale,
source,
sourceRectangle);
- }
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/RobinsonProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/RobinsonProcessor.cs
index 324ed31545..34c4ab35a2 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/RobinsonProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/RobinsonProcessor.cs
@@ -21,9 +21,7 @@ public RobinsonProcessor(bool grayscale)
}
///
- public override IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
- {
- return new EdgeDetectorCompassProcessor(new RobinsonKernels(), this.Grayscale, source, sourceRectangle);
- }
+ public override IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
+ => new EdgeDetectorCompassProcessor(configuration, new RobinsonKernels(), this.Grayscale, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/ScharrProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/ScharrProcessor.cs
index 6a4bf6afd5..76a4ae08d8 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/ScharrProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/ScharrProcessor.cs
@@ -21,9 +21,13 @@ public ScharrProcessor(bool grayscale)
}
///
- public override IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
- {
- return new EdgeDetector2DProcessor(ScharrKernels.ScharrX, ScharrKernels.ScharrY, this.Grayscale, source, sourceRectangle);
- }
+ public override IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
+ => new EdgeDetector2DProcessor(
+ configuration,
+ ScharrKernels.ScharrX,
+ ScharrKernels.ScharrY,
+ this.Grayscale,
+ source,
+ sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/SobelProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/SobelProcessor.cs
index 96ed3bcea5..185ac891dd 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/SobelProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/SobelProcessor.cs
@@ -21,9 +21,13 @@ public SobelProcessor(bool grayscale)
}
///
- public override IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
- {
- return new EdgeDetector2DProcessor(SobelKernels.SobelX, SobelKernels.SobelY, this.Grayscale, source, sourceRectangle);
- }
+ public override IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
+ => new EdgeDetector2DProcessor(
+ configuration,
+ SobelKernels.SobelX,
+ SobelKernels.SobelY,
+ this.Grayscale,
+ source,
+ sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Dithering/ErrorDiffusionPaletteProcessor.cs b/src/ImageSharp/Processing/Processors/Dithering/ErrorDiffusionPaletteProcessor.cs
index 4e45130cc3..48ad546f2f 100644
--- a/src/ImageSharp/Processing/Processors/Dithering/ErrorDiffusionPaletteProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Dithering/ErrorDiffusionPaletteProcessor.cs
@@ -58,9 +58,9 @@ public ErrorDiffusionPaletteProcessor(IErrorDiffuser diffuser, float threshold,
public float Threshold { get; }
///
- public override IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public override IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
{
- return new ErrorDiffusionPaletteProcessor(this, source, sourceRectangle);
+ return new ErrorDiffusionPaletteProcessor(configuration, this, source, sourceRectangle);
}
}
}
diff --git a/src/ImageSharp/Processing/Processors/Dithering/ErrorDiffusionPaletteProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Dithering/ErrorDiffusionPaletteProcessor{TPixel}.cs
index 37dcd7d5cb..ff4b6de520 100644
--- a/src/ImageSharp/Processing/Processors/Dithering/ErrorDiffusionPaletteProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Dithering/ErrorDiffusionPaletteProcessor{TPixel}.cs
@@ -19,11 +19,12 @@ internal sealed class ErrorDiffusionPaletteProcessor : PaletteDitherProc
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The defining the processor parameters.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public ErrorDiffusionPaletteProcessor(ErrorDiffusionPaletteProcessor definition, Image source, Rectangle sourceRectangle)
- : base(definition, source, sourceRectangle)
+ public ErrorDiffusionPaletteProcessor(Configuration configuration, ErrorDiffusionPaletteProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, definition, source, sourceRectangle)
{
}
diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs
index 87bb3e5171..d66ce21921 100644
--- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs
@@ -35,9 +35,7 @@ public OrderedDitherPaletteProcessor(IOrderedDither dither, ReadOnlyMemory
- public override IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
- {
- return new OrderedDitherPaletteProcessor(this, source, sourceRectangle);
- }
+ public override IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
+ => new OrderedDitherPaletteProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor{TPixel}.cs
index 8cde8943e3..6568033ea3 100644
--- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor{TPixel}.cs
@@ -19,11 +19,12 @@ internal class OrderedDitherPaletteProcessor : PaletteDitherProcessor
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The defining the processor parameters.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public OrderedDitherPaletteProcessor(OrderedDitherPaletteProcessor definition, Image source, Rectangle sourceRectangle)
- : base(definition, source, sourceRectangle)
+ public OrderedDitherPaletteProcessor(Configuration configuration, OrderedDitherPaletteProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, definition, source, sourceRectangle)
{
}
diff --git a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor.cs b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor.cs
index 0de964b526..a8f46f3adf 100644
--- a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor.cs
@@ -28,7 +28,7 @@ protected PaletteDitherProcessor(ReadOnlyMemory palette)
public ReadOnlyMemory Palette { get; }
///
- public abstract IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public abstract IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel;
}
}
diff --git a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs
index 10e9639423..10c9a421e9 100644
--- a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs
@@ -8,7 +8,6 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.Memory;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors.Dithering
@@ -29,11 +28,12 @@ internal abstract class PaletteDitherProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The defining the processor parameters.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- protected PaletteDitherProcessor(PaletteDitherProcessor definition, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ protected PaletteDitherProcessor(Configuration configuration, PaletteDitherProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.Definition = definition;
this.palette = this.Configuration.MemoryAllocator.Allocate(definition.Palette.Length);
diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs
index 6f9e1869a3..0e11020ebb 100644
--- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs
@@ -40,10 +40,8 @@ public OilPaintingProcessor(int levels, int brushSize)
public int BrushSize { get; }
///
- public IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel
- {
- return new OilPaintingProcessor(this, source, sourceRectangle);
- }
+ => new OilPaintingProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs
index 4cac6b0f66..f143e5643e 100644
--- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs
@@ -25,11 +25,12 @@ internal class OilPaintingProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The defining the processor parameters.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public OilPaintingProcessor(OilPaintingProcessor definition, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ public OilPaintingProcessor(Configuration configuration, OilPaintingProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.definition = definition;
}
diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor.cs
index 2a271bef3c..2d43fd53c1 100644
--- a/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor.cs
@@ -52,10 +52,8 @@ public PixelShaderProcessor(PixelShader pixelShader, PixelConversionModifiers mo
public PixelConversionModifiers Modifiers { get; }
///
- public IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel
- {
- return new PixelShaderProcessor(this, source, sourceRectangle);
- }
+ => new PixelShaderProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessorBase.cs b/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessorBase.cs
index d46a4cf320..9cee3779d7 100644
--- a/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessorBase.cs
+++ b/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessorBase.cs
@@ -26,11 +26,12 @@ internal abstract class PixelShaderProcessorBase : ImageProcessor
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The to apply during the pixel conversions.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- protected PixelShaderProcessorBase(PixelConversionModifiers modifiers, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ protected PixelShaderProcessorBase(Configuration configuration, PixelConversionModifiers modifiers, Image source, Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.modifiers = modifiers;
}
diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor{TPixel}.cs
index ce7b858a3e..a4338423e0 100644
--- a/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor{TPixel}.cs
@@ -24,11 +24,12 @@ internal sealed class PixelShaderProcessor : PixelShaderProcessorBase
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The defining the processor parameters.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public PixelShaderProcessor(PixelShaderProcessor definition, Image source, Rectangle sourceRectangle)
- : base(definition.Modifiers, source, sourceRectangle)
+ public PixelShaderProcessor(Configuration configuration, PixelShaderProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, definition.Modifiers, source, sourceRectangle)
{
this.pixelShader = definition.PixelShader;
}
diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs
index 2d7cef8fff..9b67545e54 100644
--- a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs
@@ -30,10 +30,8 @@ public PixelateProcessor(int size)
public int Size { get; }
///
- public IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel
- {
- return new PixelateProcessor(this, source, sourceRectangle);
- }
+ => new PixelateProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs
index 53acc351cf..d15bfc0077 100644
--- a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs
@@ -24,11 +24,12 @@ internal class PixelateProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The .
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public PixelateProcessor(PixelateProcessor definition, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ public PixelateProcessor(Configuration configuration, PixelateProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.definition = definition;
}
diff --git a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor.cs
index 908f7472b7..46d2e31cf0 100644
--- a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor.cs
@@ -52,10 +52,8 @@ public PositionAwarePixelShaderProcessor(PositionAwarePixelShader pixelShader, P
public PixelConversionModifiers Modifiers { get; }
///
- public IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel
- {
- return new PositionAwarePixelShaderProcessor(this, source, sourceRectangle);
- }
+ => new PositionAwarePixelShaderProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor{TPixel}.cs
index 549dedac15..db2d85bfcf 100644
--- a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor{TPixel}.cs
@@ -24,11 +24,12 @@ internal sealed class PositionAwarePixelShaderProcessor : PixelShaderPro
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The defining the processor parameters.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public PositionAwarePixelShaderProcessor(PositionAwarePixelShaderProcessor definition, Image source, Rectangle sourceRectangle)
- : base(definition.Modifiers, source, sourceRectangle)
+ public PositionAwarePixelShaderProcessor(Configuration configuration, PositionAwarePixelShaderProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, definition.Modifiers, source, sourceRectangle)
{
this.pixelShader = definition.PixelShader;
}
diff --git a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs
index 9cd4a9e460..028060f66c 100644
--- a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs
@@ -24,10 +24,8 @@ public class FilterProcessor : IImageProcessor
public ColorMatrix Matrix { get; }
///
- public virtual IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ public virtual IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel
- {
- return new FilterProcessor(this, source, sourceRectangle);
- }
+ => new FilterProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs
index 731cd2a052..86d990a387 100644
--- a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs
@@ -23,11 +23,12 @@ internal class FilterProcessor : ImageProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The .
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public FilterProcessor(FilterProcessor definition, Image source, Rectangle sourceRectangle)
- : base(source, sourceRectangle)
+ public FilterProcessor(Configuration configuration, FilterProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, source, sourceRectangle)
{
this.definition = definition;
}
diff --git a/src/ImageSharp/Processing/Processors/Filters/LomographProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/LomographProcessor.cs
index fdfaa9cb07..8836bd62cf 100644
--- a/src/ImageSharp/Processing/Processors/Filters/LomographProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/LomographProcessor.cs
@@ -19,7 +19,7 @@ public LomographProcessor()
}
///
- public override IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle) =>
- new LomographProcessor(this, source, sourceRectangle);
+ public override IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) =>
+ new LomographProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Filters/LomographProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Filters/LomographProcessor{TPixel}.cs
index 7d3a5bbc0a..30731fcbf4 100644
--- a/src/ImageSharp/Processing/Processors/Filters/LomographProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/LomographProcessor{TPixel}.cs
@@ -18,18 +18,19 @@ internal class LomographProcessor : FilterProcessor
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The defining the parameters.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public LomographProcessor(LomographProcessor definition, Image source, Rectangle sourceRectangle)
- : base(definition, source, sourceRectangle)
+ public LomographProcessor(Configuration configuration, LomographProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, definition, source, sourceRectangle)
{
}
///
protected override void AfterImageApply()
{
- new VignetteProcessor(VeryDarkGreen).Execute(this.Source, this.SourceRectangle);
+ new VignetteProcessor(VeryDarkGreen).Execute(this.Configuration, this.Source, this.SourceRectangle);
base.AfterImageApply();
}
}
diff --git a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs
index c8527a29cf..9a8c2b518e 100644
--- a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs
@@ -19,7 +19,7 @@ public PolaroidProcessor()
}
///
- public override IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle) =>
- new PolaroidProcessor(this, source, sourceRectangle);
+ public override IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) =>
+ new PolaroidProcessor(configuration, this, source, sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor{TPixel}.cs
index f7ab1a1ec2..08235e1bf0 100644
--- a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor{TPixel}.cs
@@ -14,25 +14,25 @@ internal class PolaroidProcessor : FilterProcessor
where TPixel : struct, IPixel
{
private static readonly Color LightOrange = Color.FromRgba(255, 153, 102, 128);
-
private static readonly Color VeryDarkOrange = Color.FromRgb(102, 34, 0);
///
/// Initializes a new instance of the class.
///
+ /// The configuration which allows altering default behaviour or extending the library.
/// The defining the parameters.
/// The source for the current processor instance.
/// The source area to process for the current processor instance.
- public PolaroidProcessor(PolaroidProcessor definition, Image source, Rectangle sourceRectangle)
- : base(definition, source, sourceRectangle)
+ public PolaroidProcessor(Configuration configuration, PolaroidProcessor definition, Image source, Rectangle sourceRectangle)
+ : base(configuration, definition, source, sourceRectangle)
{
}
///
protected override void AfterImageApply()
{
- new VignetteProcessor(VeryDarkOrange).Execute(this.Source, this.SourceRectangle);
- new GlowProcessor(LightOrange, this.Source.Width / 4F).Execute(this.Source, this.SourceRectangle);
+ new VignetteProcessor(VeryDarkOrange).Execute(this.Configuration, this.Source, this.SourceRectangle);
+ new GlowProcessor(LightOrange, this.Source.Width / 4F).Execute(this.Configuration, this.Source, this.SourceRectangle);
base.AfterImageApply();
}
}
diff --git a/src/ImageSharp/Processing/Processors/ICloningImageProcessor.cs b/src/ImageSharp/Processing/Processors/ICloningImageProcessor.cs
index 554a4b8860..7ffa5bcc0c 100644
--- a/src/ImageSharp/Processing/Processors/ICloningImageProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/ICloningImageProcessor.cs
@@ -16,12 +16,13 @@ public interface ICloningImageProcessor : IImageProcessor
/// the processing algorithm on an .
///
/// The pixel type.
+ /// The configuration which allows altering default behaviour or extending the library.
/// The source image. Cannot be null.
///
/// The structure that specifies the portion of the image object to draw.
///
/// The
- ICloningImageProcessor CreatePixelSpecificCloningProcessor(Image source, Rectangle sourceRectangle)
+ ICloningImageProcessor CreatePixelSpecificCloningProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel;
}
}
diff --git a/src/ImageSharp/Processing/Processors/IImageProcessor.cs b/src/ImageSharp/Processing/Processors/IImageProcessor.cs
index fb7a6a4d9d..6b9b82b10d 100644
--- a/src/ImageSharp/Processing/Processors/IImageProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/IImageProcessor.cs
@@ -19,12 +19,13 @@ public interface IImageProcessor
/// the processing algorithm on an .
///
/// The pixel type.
+ /// The configuration which allows altering default behaviour or extending the library.
/// The source image. Cannot be null.
///
/// The structure that specifies the portion of the image object to draw.
///
/// The
- IImageProcessor CreatePixelSpecificProcessor(Image source, Rectangle sourceRectangle)
+ IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle)
where TPixel : struct, IPixel;
}
}
diff --git a/src/ImageSharp/Processing/Processors/ImageProcessorExtensions.cs b/src/ImageSharp/Processing/Processors/ImageProcessorExtensions.cs
index ce8ed813b5..7956ecd9a4 100644
--- a/src/ImageSharp/Processing/Processors/ImageProcessorExtensions.cs
+++ b/src/ImageSharp/Processing/Processors/ImageProcessorExtensions.cs
@@ -13,18 +13,21 @@ internal static class ImageProcessorExtensions
/// Executes the processor against the given source image and rectangle bounds.
///
/// The processor.
+ /// The configuration which allows altering default behaviour or extending the library.
/// The source image.
/// The source bounds.
- public static void Execute(this IImageProcessor processor, Image source, Rectangle sourceRectangle)
- => source.AcceptVisitor(new ExecuteVisitor(processor, sourceRectangle));
+ public static void Execute(this IImageProcessor processor, Configuration configuration, Image source, Rectangle sourceRectangle)
+ => source.AcceptVisitor(new ExecuteVisitor(configuration, processor, sourceRectangle));
private class ExecuteVisitor : IImageVisitor
{
+ private readonly Configuration configuration;
private readonly IImageProcessor processor;
private readonly Rectangle sourceRectangle;
- public ExecuteVisitor(IImageProcessor processor, Rectangle sourceRectangle)
+ public ExecuteVisitor(Configuration configuration, IImageProcessor processor, Rectangle sourceRectangle)
{
+ this.configuration = configuration;
this.processor = processor;
this.sourceRectangle = sourceRectangle;
}
@@ -32,7 +35,7 @@ public ExecuteVisitor(IImageProcessor processor, Rectangle sourceRectangle)
public void Visit(Image image)
where TPixel : struct, IPixel
{
- using (IImageProcessor processorImpl = this.processor.CreatePixelSpecificProcessor(image, this.sourceRectangle))
+ using (IImageProcessor processorImpl = this.processor.CreatePixelSpecificProcessor(this.configuration, image, this.sourceRectangle))
{
processorImpl.Execute();
}
diff --git a/src/ImageSharp/Processing/Processors/ImageProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/ImageProcessor{TPixel}.cs
index b8bbe1e031..21d245a113 100644
--- a/src/ImageSharp/Processing/Processors/ImageProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/ImageProcessor{TPixel}.cs
@@ -19,13 +19,14 @@ public abstract class ImageProcessor : IImageProcessor
///
/// Initializes a new instance of the