diff --git a/src/ImageSharp/Processing/BrightnessExtensions.cs b/src/ImageSharp/Processing/BrightnessExtensions.cs
index 2f252ad305..4de4dc897b 100644
--- a/src/ImageSharp/Processing/BrightnessExtensions.cs
+++ b/src/ImageSharp/Processing/BrightnessExtensions.cs
@@ -19,13 +19,11 @@ namespace SixLabors.ImageSharp.Processing
/// A value of 0 will create an image that is completely black. A value of 1 leaves the input unchanged.
/// Other values are linear multipliers on the effect. Values of an amount over 1 are allowed, providing brighter results.
///
- /// The pixel format.
/// The image this method extends.
/// The proportion of the conversion. Must be greater than or equal to 0.
/// The .
- public static IImageProcessingContext Brightness(this IImageProcessingContext source, float amount)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new BrightnessProcessor(amount));
+ public static IImageProcessingContext Brightness(this IImageProcessingContext source, float amount)
+ => source.ApplyProcessor(new BrightnessProcessor(amount));
///
/// Alters the brightness component of the image.
@@ -34,15 +32,13 @@ namespace SixLabors.ImageSharp.Processing
/// A value of 0 will create an image that is completely black. A value of 1 leaves the input unchanged.
/// Other values are linear multipliers on the effect. Values of an amount over 1 are allowed, providing brighter results.
///
- /// The pixel format.
/// The image this method extends.
/// The proportion of the conversion. Must be greater than or equal to 0.
///
/// The structure that specifies the portion of the image object to alter.
///
/// The .
- public static IImageProcessingContext Brightness(this IImageProcessingContext source, float amount, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new BrightnessProcessor(amount), rectangle);
+ public static IImageProcessingContext Brightness(this IImageProcessingContext source, float amount, Rectangle rectangle)
+ => source.ApplyProcessor(new BrightnessProcessor(amount), rectangle);
}
}
diff --git a/src/ImageSharp/Processing/ColorBlindnessExtensions.cs b/src/ImageSharp/Processing/ColorBlindnessExtensions.cs
index 3316358954..000d47bd3e 100644
--- a/src/ImageSharp/Processing/ColorBlindnessExtensions.cs
+++ b/src/ImageSharp/Processing/ColorBlindnessExtensions.cs
@@ -16,49 +16,44 @@ namespace SixLabors.ImageSharp.Processing
///
/// Applies the given colorblindness simulator to the image.
///
- /// The pixel format.
/// The image this method extends.
/// The type of color blindness simulator to apply.
/// The .
- public static IImageProcessingContext ColorBlindness(this IImageProcessingContext source, ColorBlindnessMode colorBlindness)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(GetProcessor(colorBlindness));
+ public static IImageProcessingContext ColorBlindness(this IImageProcessingContext source, ColorBlindnessMode colorBlindness)
+ => source.ApplyProcessor(GetProcessor(colorBlindness));
///
/// Applies the given colorblindness simulator to the image.
///
- /// The pixel format.
/// The image this method extends.
/// The type of color blindness simulator to apply.
///
/// The structure that specifies the portion of the image object to alter.
///
/// The .
- public static IImageProcessingContext ColorBlindness(this IImageProcessingContext source, ColorBlindnessMode colorBlindnessMode, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(GetProcessor(colorBlindnessMode), rectangle);
+ public static IImageProcessingContext ColorBlindness(this IImageProcessingContext source, ColorBlindnessMode colorBlindnessMode, Rectangle rectangle)
+ => source.ApplyProcessor(GetProcessor(colorBlindnessMode), rectangle);
- private static IImageProcessor GetProcessor(ColorBlindnessMode colorBlindness)
- where TPixel : struct, IPixel
+ private static IImageProcessor GetProcessor(ColorBlindnessMode colorBlindness)
{
switch (colorBlindness)
{
case ColorBlindnessMode.Achromatomaly:
- return new AchromatomalyProcessor();
+ return new AchromatomalyProcessor();
case ColorBlindnessMode.Achromatopsia:
- return new AchromatopsiaProcessor();
+ return new AchromatopsiaProcessor();
case ColorBlindnessMode.Deuteranomaly:
- return new DeuteranomalyProcessor();
+ return new DeuteranomalyProcessor();
case ColorBlindnessMode.Deuteranopia:
- return new DeuteranopiaProcessor();
+ return new DeuteranopiaProcessor();
case ColorBlindnessMode.Protanomaly:
- return new ProtanomalyProcessor();
+ return new ProtanomalyProcessor();
case ColorBlindnessMode.Protanopia:
- return new ProtanopiaProcessor();
+ return new ProtanopiaProcessor();
case ColorBlindnessMode.Tritanomaly:
- return new TritanomalyProcessor();
+ return new TritanomalyProcessor();
default:
- return new TritanopiaProcessor();
+ return new TritanopiaProcessor();
}
}
}
diff --git a/src/ImageSharp/Processing/ContrastExtensions.cs b/src/ImageSharp/Processing/ContrastExtensions.cs
index 776aa67518..b03844d93b 100644
--- a/src/ImageSharp/Processing/ContrastExtensions.cs
+++ b/src/ImageSharp/Processing/ContrastExtensions.cs
@@ -8,7 +8,7 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
{
///
- /// Adds extensions that allow the alteration of the contrast component to the type.
+ /// Adds extensions that allow the alteration of the contrast component to the type.
///
public static class ContrastExtensions
{
@@ -19,13 +19,11 @@ namespace SixLabors.ImageSharp.Processing
/// A value of 0 will create an image that is completely gray. A value of 1 leaves the input unchanged.
/// Other values are linear multipliers on the effect. Values of an amount over 1 are allowed, providing results with more contrast.
///
- /// The pixel format.
/// The image this method extends.
/// The proportion of the conversion. Must be greater than or equal to 0.
/// The .
- public static IImageProcessingContext Contrast(this IImageProcessingContext source, float amount)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new ContrastProcessor(amount));
+ public static IImageProcessingContext Contrast(this IImageProcessingContext source, float amount)
+ => source.ApplyProcessor(new ContrastProcessor(amount));
///
/// Alters the contrast component of the image.
@@ -34,15 +32,13 @@ namespace SixLabors.ImageSharp.Processing
/// A value of 0 will create an image that is completely gray. A value of 1 leaves the input unchanged.
/// Other values are linear multipliers on the effect. Values of an amount over 1 are allowed, providing results with more contrast.
///
- /// The pixel format.
/// The image this method extends.
/// The proportion of the conversion. Must be greater than or equal to 0.
///
/// The structure that specifies the portion of the image object to alter.
///
/// The .
- public static IImageProcessingContext Contrast(this IImageProcessingContext source, float amount, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new ContrastProcessor(amount), rectangle);
+ public static IImageProcessingContext Contrast(this IImageProcessingContext source, float amount, Rectangle rectangle)
+ => source.ApplyProcessor(new ContrastProcessor(amount), rectangle);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/GrayscaleExtensions.cs b/src/ImageSharp/Processing/GrayscaleExtensions.cs
index 9ab664056b..d68a385e47 100644
--- a/src/ImageSharp/Processing/GrayscaleExtensions.cs
+++ b/src/ImageSharp/Processing/GrayscaleExtensions.cs
@@ -9,56 +9,48 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
{
///
- /// Adds extensions that allow the application of grayscale toning to the type.
+ /// Adds extensions that allow the application of grayscale toning to the type.
///
public static class GrayscaleExtensions
{
///
/// Applies grayscale toning to the image.
///
- /// The pixel format.
/// The image this method extends.
- /// The .
- public static IImageProcessingContext Grayscale(this IImageProcessingContext source)
- where TPixel : struct, IPixel
+ /// The .
+ public static IImageProcessingContext Grayscale(this IImageProcessingContext source)
=> Grayscale(source, GrayscaleMode.Bt709);
///
/// Applies grayscale toning to the image using the given amount.
///
- /// The pixel format.
/// The image this method extends.
/// The proportion of the conversion. Must be between 0 and 1.
- /// The .
- public static IImageProcessingContext Grayscale(this IImageProcessingContext source, float amount)
- where TPixel : struct, IPixel
+ /// The .
+ public static IImageProcessingContext Grayscale(this IImageProcessingContext source, float amount)
=> Grayscale(source, GrayscaleMode.Bt709, amount);
///
/// Applies grayscale toning to the image with the given .
///
- /// The pixel format.
/// The image this method extends.
/// The formula to apply to perform the operation.
- /// The .
- public static IImageProcessingContext Grayscale(this IImageProcessingContext source, GrayscaleMode mode)
- where TPixel : struct, IPixel
+ /// The .
+ public static IImageProcessingContext Grayscale(this IImageProcessingContext source, GrayscaleMode mode)
=> Grayscale(source, mode, 1F);
///
/// Applies grayscale toning to the image with the given using the given amount.
///
- /// The pixel format.
/// The image this method extends.
/// The formula to apply to perform the operation.
/// The proportion of the conversion. Must be between 0 and 1.
- /// The .
- public static IImageProcessingContext Grayscale(this IImageProcessingContext source, GrayscaleMode mode, float amount)
- where TPixel : struct, IPixel
+ /// The .
+ public static IImageProcessingContext Grayscale(this IImageProcessingContext source, GrayscaleMode mode, float amount)
{
- IImageProcessor processor = mode == GrayscaleMode.Bt709
- ? (IImageProcessor)new GrayscaleBt709Processor(amount)
- : new GrayscaleBt601Processor(1F);
+ IImageProcessor processor = mode == GrayscaleMode.Bt709
+ ? (IImageProcessor)new GrayscaleBt709Processor(amount)
+ : new GrayscaleBt601Processor(1F);
source.ApplyProcessor(processor);
return source;
@@ -67,61 +59,53 @@ namespace SixLabors.ImageSharp.Processing
///
/// Applies grayscale toning to the image.
///
- /// The pixel format.
/// The image this method extends.
///
/// The structure that specifies the portion of the image object to alter.
///
- /// The .
- public static IImageProcessingContext Grayscale(this IImageProcessingContext source, Rectangle rectangle)
- where TPixel : struct, IPixel
+ /// The .
+ public static IImageProcessingContext Grayscale(this IImageProcessingContext source, Rectangle rectangle)
=> Grayscale(source, 1F, rectangle);
///
/// Applies grayscale toning to the image using the given amount.
///
- /// The pixel format.
/// The image this method extends.
/// The proportion of the conversion. Must be between 0 and 1.
///
/// The structure that specifies the portion of the image object to alter.
///
- /// The .
- public static IImageProcessingContext Grayscale(this IImageProcessingContext source, float amount, Rectangle rectangle)
- where TPixel : struct, IPixel
+ /// The .
+ public static IImageProcessingContext Grayscale(this IImageProcessingContext source, float amount, Rectangle rectangle)
=> Grayscale(source, GrayscaleMode.Bt709, amount, rectangle);
///
/// Applies grayscale toning to the image.
///
- /// The pixel format.
/// The image this method extends.
/// The formula to apply to perform the operation.
///
/// The structure that specifies the portion of the image object to alter.
///
- /// The .
- public static IImageProcessingContext Grayscale(this IImageProcessingContext source, GrayscaleMode mode, Rectangle rectangle)
- where TPixel : struct, IPixel
+ /// The .
+ public static IImageProcessingContext Grayscale(this IImageProcessingContext source, GrayscaleMode mode, Rectangle rectangle)
=> Grayscale(source, mode, 1F, rectangle);
///
/// Applies grayscale toning to the image using the given amount.
///
- /// The pixel format.
/// The image this method extends.
/// The formula to apply to perform the operation.
/// The proportion of the conversion. Must be between 0 and 1.
///
/// The structure that specifies the portion of the image object to alter.
///
- /// The .
- public static IImageProcessingContext Grayscale(this IImageProcessingContext source, GrayscaleMode mode, float amount, Rectangle rectangle)
- where TPixel : struct, IPixel
+ /// The .
+ public static IImageProcessingContext Grayscale(this IImageProcessingContext source, GrayscaleMode mode, float amount, Rectangle rectangle)
{
- IImageProcessor processor = mode == GrayscaleMode.Bt709
- ? (IImageProcessor)new GrayscaleBt709Processor(amount)
- : new GrayscaleBt601Processor(amount);
+ IImageProcessor processor = mode == GrayscaleMode.Bt709
+ ? (IImageProcessor)new GrayscaleBt709Processor(amount)
+ : new GrayscaleBt601Processor(amount);
source.ApplyProcessor(processor, rectangle);
return source;
diff --git a/src/ImageSharp/Processing/HueExtensions.cs b/src/ImageSharp/Processing/HueExtensions.cs
index 246d4bf2bd..17296e1db5 100644
--- a/src/ImageSharp/Processing/HueExtensions.cs
+++ b/src/ImageSharp/Processing/HueExtensions.cs
@@ -8,33 +8,29 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
{
///
- /// Adds extensions that allow the alteration of the hue component to the type.
+ /// Adds extensions that allow the alteration of the hue component to the type.
///
public static class HueExtensions
{
///
/// Alters the hue component of the image.
///
- /// The pixel format.
/// The image this method extends.
/// The rotation angle in degrees to adjust the hue.
/// The .
- public static IImageProcessingContext Hue(this IImageProcessingContext source, float degrees)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new HueProcessor(degrees));
+ public static IImageProcessingContext Hue(this IImageProcessingContext source, float degrees)
+ => source.ApplyProcessor(new HueProcessor(degrees));
///
/// Alters the hue component of the image.
///
- /// The pixel format.
/// The image this method extends.
/// The rotation angle in degrees to adjust the hue.
///
/// The structure that specifies the portion of the image object to alter.
///
/// The .
- public static IImageProcessingContext Hue(this IImageProcessingContext source, float degrees, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new HueProcessor(degrees), rectangle);
+ public static IImageProcessingContext Hue(this IImageProcessingContext source, float degrees, Rectangle rectangle)
+ => source.ApplyProcessor(new HueProcessor(degrees), rectangle);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/InvertExtensions.cs b/src/ImageSharp/Processing/InvertExtensions.cs
index 9e031bc95a..828aaa1bbc 100644
--- a/src/ImageSharp/Processing/InvertExtensions.cs
+++ b/src/ImageSharp/Processing/InvertExtensions.cs
@@ -8,31 +8,27 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
{
///
- /// Adds extensions that allow the inversion of colors to the type.
+ /// Adds extensions that allow the inversion of colors to the type.
///
public static class InvertExtensions
{
///
/// Inverts the colors of the image.
///
- /// The pixel format.
/// The image this method extends.
/// The .
- public static IImageProcessingContext Invert(this IImageProcessingContext source)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new InvertProcessor(1F));
+ public static IImageProcessingContext Invert(this IImageProcessingContext source)
+ => source.ApplyProcessor(new InvertProcessor(1F));
///
/// Inverts the colors of the image.
///
- /// The pixel format.
/// The image this method extends.
///
/// The structure that specifies the portion of the image object to alter.
///
/// The .
- public static IImageProcessingContext Invert(this IImageProcessingContext source, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new InvertProcessor(1F), rectangle);
+ public static IImageProcessingContext Invert(this IImageProcessingContext source, Rectangle rectangle)
+ => source.ApplyProcessor(new InvertProcessor(1F), rectangle);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/KodachromeExtensions.cs b/src/ImageSharp/Processing/KodachromeExtensions.cs
index e438b131ed..24bd51e016 100644
--- a/src/ImageSharp/Processing/KodachromeExtensions.cs
+++ b/src/ImageSharp/Processing/KodachromeExtensions.cs
@@ -8,31 +8,27 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
{
///
- /// Adds extensions that allow the recreation of an old Kodachrome camera effect to the type.
+ /// Adds extensions that allow the recreation of an old Kodachrome camera effect to the type.
///
public static class KodachromeExtensions
{
///
/// Alters the colors of the image recreating an old Kodachrome camera effect.
///
- /// The pixel format.
/// The image this method extends.
/// The .
- public static IImageProcessingContext Kodachrome(this IImageProcessingContext source)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new KodachromeProcessor());
+ public static IImageProcessingContext Kodachrome(this IImageProcessingContext source)
+ => source.ApplyProcessor(new KodachromeProcessor());
///
/// Alters the colors of the image recreating an old Kodachrome camera effect.
///
- /// The pixel format.
/// The image this method extends.
///
/// The structure that specifies the portion of the image object to alter.
///
/// The .
- public static IImageProcessingContext Kodachrome(this IImageProcessingContext source, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new KodachromeProcessor(), rectangle);
+ public static IImageProcessingContext Kodachrome(this IImageProcessingContext source, Rectangle rectangle)
+ => source.ApplyProcessor(new KodachromeProcessor(), rectangle);
}
}
diff --git a/src/ImageSharp/Processing/LomographExtensions.cs b/src/ImageSharp/Processing/LomographExtensions.cs
index 7dff164026..a3fd3d3b50 100644
--- a/src/ImageSharp/Processing/LomographExtensions.cs
+++ b/src/ImageSharp/Processing/LomographExtensions.cs
@@ -8,31 +8,27 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
{
///
- /// Adds extensions that allow the recreation of an old Lomograph camera effect to the type.
+ /// Adds extensions that allow the recreation of an old Lomograph camera effect to the type.
///
public static class LomographExtensions
{
///
/// Alters the colors of the image recreating an old Lomograph camera effect.
///
- /// The pixel format.
/// The image this method extends.
/// The .
- public static IImageProcessingContext Lomograph(this IImageProcessingContext source)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new LomographProcessor());
+ public static IImageProcessingContext Lomograph(this IImageProcessingContext source)
+ => source.ApplyProcessor(new LomographProcessor());
///
/// Alters the colors of the image recreating an old Lomograph camera effect.
///
- /// The pixel format.
/// The image this method extends.
///
/// The structure that specifies the portion of the image object to alter.
///
/// The .
- public static IImageProcessingContext Lomograph(this IImageProcessingContext source, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new LomographProcessor(), rectangle);
+ public static IImageProcessingContext Lomograph(this IImageProcessingContext source, Rectangle rectangle)
+ => source.ApplyProcessor(new LomographProcessor(), rectangle);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/PolaroidExtensions.cs b/src/ImageSharp/Processing/PolaroidExtensions.cs
index 5d4beee221..4172c1d615 100644
--- a/src/ImageSharp/Processing/PolaroidExtensions.cs
+++ b/src/ImageSharp/Processing/PolaroidExtensions.cs
@@ -8,19 +8,17 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
{
///
- /// Adds extensions that allow the recreation of an old Polaroid camera effect to the type.
+ /// Adds extensions that allow the recreation of an old Polaroid camera effect to the type.
///
public static class PolaroidExtensions
{
///
/// Alters the colors of the image recreating an old Polaroid camera effect.
///
- /// The pixel format.
/// The image this method extends.
/// The .
- public static IImageProcessingContext Polaroid(this IImageProcessingContext source)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new PolaroidProcessor());
+ public static IImageProcessingContext Polaroid(this IImageProcessingContext source)
+ => source.ApplyProcessor(new PolaroidProcessor());
///
/// Alters the colors of the image recreating an old Polaroid camera effect.
@@ -31,8 +29,7 @@ namespace SixLabors.ImageSharp.Processing
/// The structure that specifies the portion of the image object to alter.
///
/// The .
- public static IImageProcessingContext Polaroid(this IImageProcessingContext source, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new PolaroidProcessor(), rectangle);
+ public static IImageProcessingContext Polaroid(this IImageProcessingContext source, Rectangle rectangle)
+ => source.ApplyProcessor(new PolaroidProcessor(), rectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor.cs
index d2e9630dc0..c08a176618 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor.cs
@@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
{
if (this.Grayscale)
{
- new GrayscaleBt709Processor(1F).Apply(source, sourceRectangle, configuration);
+ new GrayscaleBt709Processor(1F).ApplyToFrame(source, sourceRectangle, configuration);
}
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor.cs
index 73f92fae38..aa33699f5d 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor.cs
@@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
{
if (this.Grayscale)
{
- new GrayscaleBt709Processor(1F).Apply(source, sourceRectangle, configuration);
+ new GrayscaleBt709Processor(1F).ApplyToFrame(source, sourceRectangle, configuration);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs
index edc7ec4ccd..9ec79da9eb 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs
@@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
{
if (this.Grayscale)
{
- new GrayscaleBt709Processor(1F).Apply(source, sourceRectangle, configuration);
+ new GrayscaleBt709Processor(1F).ApplyToFrame(source, sourceRectangle, configuration);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Filters/AchromatomalyProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/AchromatomalyProcessor.cs
index 57c1bad39b..2dac6b827d 100644
--- a/src/ImageSharp/Processing/Processors/Filters/AchromatomalyProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/AchromatomalyProcessor.cs
@@ -8,12 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Converts the colors of the image recreating Achromatomaly (Color desensitivity) color blindness.
///
- /// The pixel format.
- internal class AchromatomalyProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class AchromatomalyProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public AchromatomalyProcessor()
: base(KnownFilterMatrices.AchromatomalyFilter)
diff --git a/src/ImageSharp/Processing/Processors/Filters/AchromatopsiaProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/AchromatopsiaProcessor.cs
index 696a854ab8..4df94a7603 100644
--- a/src/ImageSharp/Processing/Processors/Filters/AchromatopsiaProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/AchromatopsiaProcessor.cs
@@ -8,12 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Converts the colors of the image recreating Achromatopsia (Monochrome) color blindness.
///
- /// The pixel format.
- internal class AchromatopsiaProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class AchromatopsiaProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public AchromatopsiaProcessor()
: base(KnownFilterMatrices.AchromatopsiaFilter)
diff --git a/src/ImageSharp/Processing/Processors/Filters/BrightnessProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/BrightnessProcessor.cs
index b1b8ad7478..6a1f3869ae 100644
--- a/src/ImageSharp/Processing/Processors/Filters/BrightnessProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/BrightnessProcessor.cs
@@ -8,12 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Applies a brightness filter matrix using the given amount.
///
- /// The pixel format.
- internal class BrightnessProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class BrightnessProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
///
/// A value of 0 will create an image that is completely black. A value of 1 leaves the input unchanged.
diff --git a/src/ImageSharp/Processing/Processors/Filters/ContrastProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/ContrastProcessor.cs
index ebec464d5c..3bea695b99 100644
--- a/src/ImageSharp/Processing/Processors/Filters/ContrastProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/ContrastProcessor.cs
@@ -8,12 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Applies a contrast filter matrix using the given amount.
///
- /// The pixel format.
- internal class ContrastProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class ContrastProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
///
/// A value of 0 will create an image that is completely gray. A value of 1 leaves the input unchanged.
diff --git a/src/ImageSharp/Processing/Processors/Filters/DeuteranomalyProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/DeuteranomalyProcessor.cs
index 0d1b1da902..395489d563 100644
--- a/src/ImageSharp/Processing/Processors/Filters/DeuteranomalyProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/DeuteranomalyProcessor.cs
@@ -8,12 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Converts the colors of the image recreating Deuteranomaly (Green-Weak) color blindness.
///
- /// The pixel format.
- internal class DeuteranomalyProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class DeuteranomalyProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public DeuteranomalyProcessor()
: base(KnownFilterMatrices.DeuteranomalyFilter)
diff --git a/src/ImageSharp/Processing/Processors/Filters/DeuteranopiaProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/DeuteranopiaProcessor.cs
index ae0727048e..51f8361e6c 100644
--- a/src/ImageSharp/Processing/Processors/Filters/DeuteranopiaProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/DeuteranopiaProcessor.cs
@@ -8,12 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Converts the colors of the image recreating Deuteranopia (Green-Blind) color blindness.
///
- /// The pixel format.
- internal class DeuteranopiaProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class DeuteranopiaProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public DeuteranopiaProcessor()
: base(KnownFilterMatrices.DeuteranopiaFilter)
diff --git a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs
index 3f9f586877..5637e97700 100644
--- a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs
@@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
public ColorMatrix Matrix { get; }
- public IImageProcessor CreatePixelSpecificProcessor()
+ public virtual IImageProcessor CreatePixelSpecificProcessor()
where TPixel : struct, IPixel
{
return new FilterProcessorImplementation(this);
diff --git a/src/ImageSharp/Processing/Processors/Filters/FilterProcessorImplementation.cs b/src/ImageSharp/Processing/Processors/Filters/FilterProcessorImplementation.cs
index 1eaaf1ea5b..8fea81564c 100644
--- a/src/ImageSharp/Processing/Processors/Filters/FilterProcessorImplementation.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/FilterProcessorImplementation.cs
@@ -18,11 +18,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
internal class FilterProcessorImplementation : ImageProcessor
where TPixel : struct, IPixel
{
- private readonly FilterProcessor paramterSource;
+ private readonly FilterProcessor definition;
- public FilterProcessorImplementation(FilterProcessor paramterSource)
+ public FilterProcessorImplementation(FilterProcessor definition)
{
- this.paramterSource = paramterSource;
+ this.definition = definition;
}
///
@@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
var interest = Rectangle.Intersect(sourceRectangle, source.Bounds());
int startX = interest.X;
- ColorMatrix matrix = this.paramterSource.Matrix;
+ ColorMatrix matrix = this.definition.Matrix;
ParallelHelper.IterateRowsWithTempBuffer(
interest,
diff --git a/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt601Processor.cs b/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt601Processor.cs
index c933d4858f..b39e01b9a8 100644
--- a/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt601Processor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt601Processor.cs
@@ -8,12 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Applies a grayscale filter matrix using the given amount and the formula as specified by ITU-R Recommendation BT.601
///
- /// The pixel format.
- internal class GrayscaleBt601Processor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class GrayscaleBt601Processor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The proportion of the conversion. Must be between 0 and 1.
public GrayscaleBt601Processor(float amount)
diff --git a/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt709Processor.cs b/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt709Processor.cs
index 1716773b4c..038a2885bc 100644
--- a/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt709Processor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt709Processor.cs
@@ -2,18 +2,17 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors.Filters
{
///
/// Applies a grayscale filter matrix using the given amount and the formula as specified by ITU-R Recommendation BT.709
///
- /// The pixel format.
- internal class GrayscaleBt709Processor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class GrayscaleBt709Processor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The proportion of the conversion. Must be between 0 and 1.
public GrayscaleBt709Processor(float amount)
@@ -23,8 +22,16 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
}
///
- /// Gets the proportion of the conversion
+ /// Gets the proportion of the conversion.
///
public float Amount { get; }
+
+ // TODO: Move this to an appropriate extension method if possible.
+ internal void ApplyToFrame(ImageFrame frame, Rectangle sourceRectangle, Configuration configuration)
+ where TPixel : struct, IPixel
+ {
+ var processorImpl = new FilterProcessorImplementation(new GrayscaleBt709Processor(1F));
+ processorImpl.Apply(frame, sourceRectangle, configuration);
+ }
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Filters/HueProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/HueProcessor.cs
index 4c3a0c73ed..a69fd50757 100644
--- a/src/ImageSharp/Processing/Processors/Filters/HueProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/HueProcessor.cs
@@ -8,11 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Applies a hue filter matrix using the given angle of rotation in degrees
///
- internal class HueProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class HueProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The angle of rotation in degrees
public HueProcessor(float degrees)
diff --git a/src/ImageSharp/Processing/Processors/Filters/InvertProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/InvertProcessor.cs
index 462c420707..d7631970db 100644
--- a/src/ImageSharp/Processing/Processors/Filters/InvertProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/InvertProcessor.cs
@@ -8,12 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Applies a filter matrix that inverts the colors of an image
///
- /// The pixel format.
- internal class InvertProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class InvertProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The proportion of the conversion. Must be between 0 and 1.
public InvertProcessor(float amount)
diff --git a/src/ImageSharp/Processing/Processors/Filters/KodachromeProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/KodachromeProcessor.cs
index 003766e8ab..5570f23d7d 100644
--- a/src/ImageSharp/Processing/Processors/Filters/KodachromeProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/KodachromeProcessor.cs
@@ -8,12 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Applies a filter matrix recreating an old Kodachrome camera effect matrix to the image
///
- /// The pixel format.
- internal class KodachromeProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class KodachromeProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public KodachromeProcessor()
: base(KnownFilterMatrices.KodachromeFilter)
diff --git a/src/ImageSharp/Processing/Processors/Filters/LomographProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/LomographProcessor.cs
index 737ebf6188..345d829ac6 100644
--- a/src/ImageSharp/Processing/Processors/Filters/LomographProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/LomographProcessor.cs
@@ -1,33 +1,22 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Processors.Overlays;
-using SixLabors.Primitives;
-
namespace SixLabors.ImageSharp.Processing.Processors.Filters
{
///
/// Converts the colors of the image recreating an old Lomograph effect.
///
- /// The pixel format.
- internal class LomographProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class LomographProcessor : FilterProcessor
{
- private static readonly TPixel VeryDarkGreen = ColorBuilder.FromRGBA(0, 10, 0, 255);
-
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public LomographProcessor()
: base(KnownFilterMatrices.LomographFilter)
{
}
- ///
- protected override void AfterFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration)
- {
- new VignetteProcessor(VeryDarkGreen).Apply(source, sourceRectangle, configuration);
- }
+ public override IImageProcessor CreatePixelSpecificProcessor() =>
+ new LomographProcessorImplementation(this);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Filters/LomographProcessorImplementation.cs b/src/ImageSharp/Processing/Processors/Filters/LomographProcessorImplementation.cs
new file mode 100644
index 0000000000..d851b98e06
--- /dev/null
+++ b/src/ImageSharp/Processing/Processors/Filters/LomographProcessorImplementation.cs
@@ -0,0 +1,26 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Processors.Overlays;
+using SixLabors.Primitives;
+
+namespace SixLabors.ImageSharp.Processing.Processors.Filters
+{
+ internal class LomographProcessorImplementation : FilterProcessorImplementation
+ where TPixel : struct, IPixel
+ {
+ private static readonly TPixel VeryDarkGreen = ColorBuilder.FromRGBA(0, 10, 0, 255);
+
+ ///
+ protected override void AfterFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration)
+ {
+ new VignetteProcessor(VeryDarkGreen).Apply(source, sourceRectangle, configuration);
+ }
+
+ public LomographProcessorImplementation(FilterProcessor definition)
+ : base(definition)
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs
index fb065ac176..af16d9eab2 100644
--- a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs
@@ -10,13 +10,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Converts the colors of the image recreating an old Polaroid effect.
///
- /// The pixel format.
- internal class PolaroidProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ public class PolaroidProcessor : FilterProcessor
{
- private static readonly TPixel VeryDarkOrange = ColorBuilder.FromRGB(102, 34, 0);
- private static readonly TPixel LightOrange = ColorBuilder.FromRGBA(255, 153, 102, 128);
-
///
/// Initializes a new instance of the class.
///
@@ -25,11 +20,26 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
{
}
+ public override IImageProcessor CreatePixelSpecificProcessor() =>
+ new PolaroidProcessorImplementation(this);
+ }
+
+ internal class PolaroidProcessorImplementation : FilterProcessorImplementation
+ where TPixel : struct, IPixel
+ {
+ private static readonly TPixel VeryDarkOrange = ColorBuilder.FromRGB(102, 34, 0);
+ private static readonly TPixel LightOrange = ColorBuilder.FromRGBA(255, 153, 102, 128);
+
///
protected override void AfterFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration)
{
new VignetteProcessor(VeryDarkOrange).Apply(source, sourceRectangle, configuration);
new GlowProcessor(LightOrange, source.Width / 4F).Apply(source, sourceRectangle, configuration);
}
+
+ public PolaroidProcessorImplementation(FilterProcessor definition)
+ : base(definition)
+ {
+ }
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Filters/ProtanomalyProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/ProtanomalyProcessor.cs
index 79eb708518..95e369b371 100644
--- a/src/ImageSharp/Processing/Processors/Filters/ProtanomalyProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/ProtanomalyProcessor.cs
@@ -8,12 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Converts the colors of the image recreating Protanomaly (Red-Weak) color blindness.
///
- /// The pixel format.
- internal class ProtanomalyProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class ProtanomalyProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public ProtanomalyProcessor()
: base(KnownFilterMatrices.ProtanomalyFilter)
diff --git a/src/ImageSharp/Processing/Processors/Filters/ProtanopiaProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/ProtanopiaProcessor.cs
index c6a01439a2..94eeaae475 100644
--- a/src/ImageSharp/Processing/Processors/Filters/ProtanopiaProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/ProtanopiaProcessor.cs
@@ -9,11 +9,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
/// Converts the colors of the image recreating Protanopia (Red-Blind) color blindness.
///
/// The pixel format.
- internal class ProtanopiaProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class ProtanopiaProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public ProtanopiaProcessor()
: base(KnownFilterMatrices.ProtanopiaFilter)
diff --git a/src/ImageSharp/Processing/Processors/Filters/SaturateProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/SaturateProcessor.cs
index 75e956071e..424eeb461c 100644
--- a/src/ImageSharp/Processing/Processors/Filters/SaturateProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/SaturateProcessor.cs
@@ -8,12 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Applies a saturation filter matrix using the given amount.
///
- /// The pixel format.
- internal class SaturateProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class SaturateProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
///
/// A value of 0 is completely un-saturated. A value of 1 leaves the input unchanged.
diff --git a/src/ImageSharp/Processing/Processors/Filters/SepiaProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/SepiaProcessor.cs
index 2009dccd56..538db4b52c 100644
--- a/src/ImageSharp/Processing/Processors/Filters/SepiaProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/SepiaProcessor.cs
@@ -8,12 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Applies a sepia filter matrix using the given amount.
///
- /// The pixel format.
- internal class SepiaProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class SepiaProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The proportion of the conversion. Must be between 0 and 1.
public SepiaProcessor(float amount)
diff --git a/src/ImageSharp/Processing/Processors/Filters/TritanomalyProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/TritanomalyProcessor.cs
index 593f7f5b01..3eda05a115 100644
--- a/src/ImageSharp/Processing/Processors/Filters/TritanomalyProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/TritanomalyProcessor.cs
@@ -8,12 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Converts the colors of the image recreating Tritanomaly (Blue-Weak) color blindness.
///
- /// The pixel format.
- internal class TritanomalyProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class TritanomalyProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public TritanomalyProcessor()
: base(KnownFilterMatrices.TritanomalyFilter)
diff --git a/src/ImageSharp/Processing/Processors/Filters/TritanopiaProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/TritanopiaProcessor.cs
index 153ad5559a..f5ed26c833 100644
--- a/src/ImageSharp/Processing/Processors/Filters/TritanopiaProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/TritanopiaProcessor.cs
@@ -8,12 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Converts the colors of the image recreating Tritanopia (Blue-Blind) color blindness.
///
- /// The pixel format.
- internal class TritanopiaProcessor : FilterProcessor
- where TPixel : struct, IPixel
+ internal class TritanopiaProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public TritanopiaProcessor()
: base(KnownFilterMatrices.TritanopiaFilter)
diff --git a/src/ImageSharp/Processing/Processors/IImageProcessor.cs b/src/ImageSharp/Processing/Processors/IImageProcessor.cs
index 78800affbc..68db453806 100644
--- a/src/ImageSharp/Processing/Processors/IImageProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/IImageProcessor.cs
@@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
IImageProcessor CreatePixelSpecificProcessor()
where TPixel : struct, IPixel;
}
-
+
///
/// Encapsulates methods to alter the pixels of an image.
///
@@ -34,4 +34,33 @@ namespace SixLabors.ImageSharp.Processing.Processors
///
void Apply(Image source, Rectangle sourceRectangle);
}
+
+ internal static class ImageProcessorExtensions
+ {
+ public static void Apply(this IImageProcessor processor, Image source, Rectangle sourceRectangle)
+ {
+ var visitor = new ApplyVisitor(processor, sourceRectangle);
+ source.AcceptVisitor(visitor);
+ }
+
+ private class ApplyVisitor : IImageVisitor
+ {
+ private readonly IImageProcessor processor;
+
+ private readonly Rectangle sourceRectangle;
+
+ public ApplyVisitor(IImageProcessor processor, Rectangle sourceRectangle)
+ {
+ this.processor = processor;
+ this.sourceRectangle = sourceRectangle;
+ }
+
+ public void Visit(Image image)
+ where TPixel : struct, IPixel
+ {
+ var processorImpl = processor.CreatePixelSpecificProcessor();
+ processorImpl.Apply(image, this.sourceRectangle);
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/SaturateExtensions.cs b/src/ImageSharp/Processing/SaturateExtensions.cs
index ba45ae12c9..fe2cf5f348 100644
--- a/src/ImageSharp/Processing/SaturateExtensions.cs
+++ b/src/ImageSharp/Processing/SaturateExtensions.cs
@@ -8,7 +8,7 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
{
///
- /// Adds extensions that allow the alteration of the saturation component to the type.
+ /// Adds extensions that allow the alteration of the saturation component to the type.
///
public static class SaturateExtensions
{
@@ -19,13 +19,11 @@ namespace SixLabors.ImageSharp.Processing
/// A value of 0 is completely un-saturated. A value of 1 leaves the input unchanged.
/// Other values are linear multipliers on the effect. Values of amount over 1 are allowed, providing super-saturated results
///
- /// The pixel format.
/// The image this method extends.
/// The proportion of the conversion. Must be greater than or equal to 0.
/// The .
- public static IImageProcessingContext Saturate(this IImageProcessingContext source, float amount)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new SaturateProcessor(amount));
+ public static IImageProcessingContext Saturate(this IImageProcessingContext source, float amount)
+ => source.ApplyProcessor(new SaturateProcessor(amount));
///
/// Alters the saturation component of the image.
@@ -34,15 +32,13 @@ namespace SixLabors.ImageSharp.Processing
/// A value of 0 is completely un-saturated. A value of 1 leaves the input unchanged.
/// Other values are linear multipliers on the effect. Values of amount over 1 are allowed, providing super-saturated results
///
- /// The pixel format.
/// The image this method extends.
/// The proportion of the conversion. Must be greater than or equal to 0.
///
/// The structure that specifies the portion of the image object to alter.
///
/// The .
- public static IImageProcessingContext Saturate(this IImageProcessingContext source, float amount, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new SaturateProcessor(amount), rectangle);
+ public static IImageProcessingContext Saturate(this IImageProcessingContext source, float amount, Rectangle rectangle)
+ => source.ApplyProcessor(new SaturateProcessor(amount), rectangle);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/SepiaExtensions.cs b/src/ImageSharp/Processing/SepiaExtensions.cs
index 08676ee62a..5b23ec11af 100644
--- a/src/ImageSharp/Processing/SepiaExtensions.cs
+++ b/src/ImageSharp/Processing/SepiaExtensions.cs
@@ -8,56 +8,48 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
{
///
- /// Adds extensions that allow the application of sepia toning to the type.
+ /// Adds extensions that allow the application of sepia toning to the type.
///
public static class SepiaExtensions
{
///
/// Applies sepia toning to the image.
///
- /// The pixel format.
/// The image this method extends.
/// The .
- public static IImageProcessingContext Sepia(this IImageProcessingContext source)
- where TPixel : struct, IPixel
+ public static IImageProcessingContext Sepia(this IImageProcessingContext source)
=> Sepia(source, 1F);
///
/// Applies sepia toning to the image using the given amount.
///
- /// The pixel format.
/// The image this method extends.
/// The proportion of the conversion. Must be between 0 and 1.
/// The .
- public static IImageProcessingContext Sepia(this IImageProcessingContext source, float amount)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new SepiaProcessor(amount));
+ public static IImageProcessingContext Sepia(this IImageProcessingContext source, float amount)
+ => source.ApplyProcessor(new SepiaProcessor(amount));
///
/// Applies sepia toning to the image.
///
- /// The pixel format.
/// The image this method extends.
///
/// The structure that specifies the portion of the image object to alter.
///
/// The .
- public static IImageProcessingContext Sepia(this IImageProcessingContext source, Rectangle rectangle)
- where TPixel : struct, IPixel
+ public static IImageProcessingContext Sepia(this IImageProcessingContext source, Rectangle rectangle)
=> Sepia(source, 1F, rectangle);
///
/// Applies sepia toning to the image.
///
- /// The pixel format.
/// The image this method extends.
/// The proportion of the conversion. Must be between 0 and 1.
///
/// The structure that specifies the portion of the image object to alter.
///
/// The .
- public static IImageProcessingContext Sepia(this IImageProcessingContext source, float amount, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new SepiaProcessor(amount), rectangle);
+ public static IImageProcessingContext Sepia(this IImageProcessingContext source, float amount, Rectangle rectangle)
+ => source.ApplyProcessor(new SepiaProcessor(amount), rectangle);
}
}
\ No newline at end of file