From 6d8cd15f3278adc01cc59758d5d70ecb77598cda Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 26 Dec 2019 11:29:21 +0100 Subject: [PATCH] Added overloads with custom pixel modifiers in pixel shading extensions --- .../Extensions/PixelShaderExtensions.cs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/ImageSharp/Processing/Extensions/PixelShaderExtensions.cs b/src/ImageSharp/Processing/Extensions/PixelShaderExtensions.cs index 30848e346..b866e7fb1 100644 --- a/src/ImageSharp/Processing/Extensions/PixelShaderExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/PixelShaderExtensions.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors.Effects; using SixLabors.Primitives; @@ -20,6 +21,16 @@ namespace SixLabors.ImageSharp.Processing public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader) => source.ApplyProcessor(new PixelShaderProcessor(pixelShader)); + /// + /// Applies a user defined pixel shader to the image. + /// + /// The image this method extends. + /// The user defined pixel shader to use to modify images. + /// The to apply during the pixel conversions. + /// The to allow chaining of operations. + public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader, PixelConversionModifiers modifiers) + => source.ApplyProcessor(new PixelShaderProcessor(pixelShader, modifiers)); + /// /// Applies a user defined pixel shader to the image. /// @@ -32,6 +43,19 @@ namespace SixLabors.ImageSharp.Processing public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader, Rectangle rectangle) => source.ApplyProcessor(new PixelShaderProcessor(pixelShader), rectangle); + /// + /// Applies a user defined pixel shader to the image. + /// + /// The image this method extends. + /// The user defined pixel shader to use to modify images. + /// + /// The structure that specifies the portion of the image object to alter. + /// + /// The to apply during the pixel conversions. + /// The to allow chaining of operations. + public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader, Rectangle rectangle, PixelConversionModifiers modifiers) + => source.ApplyProcessor(new PixelShaderProcessor(pixelShader, modifiers), rectangle); + /// /// Applies a user defined pixel shader to the image. /// @@ -41,6 +65,16 @@ namespace SixLabors.ImageSharp.Processing public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader) => source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader)); + /// + /// Applies a user defined pixel shader to the image. + /// + /// The image this method extends. + /// The user defined pixel shader to use to modify images. + /// The to apply during the pixel conversions. + /// The to allow chaining of operations. + public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader, PixelConversionModifiers modifiers) + => source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader, modifiers)); + /// /// Applies a user defined pixel shader to the image. /// @@ -52,5 +86,18 @@ namespace SixLabors.ImageSharp.Processing /// The to allow chaining of operations. public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader, Rectangle rectangle) => source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader), rectangle); + + /// + /// Applies a user defined pixel shader to the image. + /// + /// The image this method extends. + /// The user defined pixel shader to use to modify images. + /// + /// The structure that specifies the portion of the image object to alter. + /// + /// The to apply during the pixel conversions. + /// The to allow chaining of operations. + public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader, Rectangle rectangle, PixelConversionModifiers modifiers) + => source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader, modifiers), rectangle); } }