mirror of https://github.com/SixLabors/ImageSharp
12 changed files with 214 additions and 255 deletions
@ -0,0 +1,102 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using SixLabors.ImageSharp.Processing.Processors.Effects; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing |
|||
{ |
|||
/// <summary>
|
|||
/// Defines extension methods that allow the application of user defined processing delegate to an <see cref="Image"/>.
|
|||
/// </summary>
|
|||
public static class PixelRowDelegateExtensions |
|||
{ |
|||
/// <summary>
|
|||
/// Applies a user defined processing delegate to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation) |
|||
=> ProcessPixelRowsAsVector4(source, rowOperation, PixelConversionModifiers.None); |
|||
|
|||
/// <summary>
|
|||
/// Applies a user defined processing delegate to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
|
|||
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation, PixelConversionModifiers modifiers) |
|||
=> source.ApplyProcessor(new PixelRowDelegateProcessor(rowOperation, modifiers)); |
|||
|
|||
/// <summary>
|
|||
/// Applies a user defined processing delegate to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
|
|||
/// <param name="rectangle">
|
|||
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|||
/// </param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation, Rectangle rectangle) |
|||
=> ProcessPixelRowsAsVector4(source, rowOperation, rectangle, PixelConversionModifiers.None); |
|||
|
|||
/// <summary>
|
|||
/// Applies a user defined processing delegate to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
|
|||
/// <param name="rectangle">
|
|||
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|||
/// </param>
|
|||
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation, Rectangle rectangle, PixelConversionModifiers modifiers) |
|||
=> source.ApplyProcessor(new PixelRowDelegateProcessor(rowOperation, modifiers), rectangle); |
|||
|
|||
/// <summary>
|
|||
/// Applies a user defined processing delegate to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PositionAwarePixelRowOperation rowOperation) |
|||
=> ProcessPixelRowsAsVector4(source, rowOperation, PixelConversionModifiers.None); |
|||
|
|||
/// <summary>
|
|||
/// Applies a user defined processing delegate to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
|
|||
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PositionAwarePixelRowOperation rowOperation, PixelConversionModifiers modifiers) |
|||
=> source.ApplyProcessor(new PositionAwarePixelRowDelegateProcessor(rowOperation, modifiers)); |
|||
|
|||
/// <summary>
|
|||
/// Applies a user defined processing delegate to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
|
|||
/// <param name="rectangle">
|
|||
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|||
/// </param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PositionAwarePixelRowOperation rowOperation, Rectangle rectangle) |
|||
=> ProcessPixelRowsAsVector4(source, rowOperation, rectangle, PixelConversionModifiers.None); |
|||
|
|||
/// <summary>
|
|||
/// Applies a user defined processing delegate to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param>
|
|||
/// <param name="rectangle">
|
|||
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|||
/// </param>
|
|||
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PositionAwarePixelRowOperation rowOperation, Rectangle rectangle, PixelConversionModifiers modifiers) |
|||
=> source.ApplyProcessor(new PositionAwarePixelRowDelegateProcessor(rowOperation, modifiers), rectangle); |
|||
} |
|||
} |
|||
@ -1,102 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using SixLabors.ImageSharp.Processing.Processors.Effects; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing |
|||
{ |
|||
/// <summary>
|
|||
/// Defines extension methods that allow the application of user defined pixel shaders to an <see cref="Image"/>.
|
|||
/// </summary>
|
|||
public static class PixelShaderExtensions |
|||
{ |
|||
/// <summary>
|
|||
/// Applies a user defined pixel shader to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader) |
|||
=> source.ApplyProcessor(new PixelShaderProcessor(pixelShader)); |
|||
|
|||
/// <summary>
|
|||
/// Applies a user defined pixel shader to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
|
|||
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader, PixelConversionModifiers modifiers) |
|||
=> source.ApplyProcessor(new PixelShaderProcessor(pixelShader, modifiers)); |
|||
|
|||
/// <summary>
|
|||
/// Applies a user defined pixel shader to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
|
|||
/// <param name="rectangle">
|
|||
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|||
/// </param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader, Rectangle rectangle) |
|||
=> source.ApplyProcessor(new PixelShaderProcessor(pixelShader), rectangle); |
|||
|
|||
/// <summary>
|
|||
/// Applies a user defined pixel shader to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
|
|||
/// <param name="rectangle">
|
|||
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|||
/// </param>
|
|||
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader, Rectangle rectangle, PixelConversionModifiers modifiers) |
|||
=> source.ApplyProcessor(new PixelShaderProcessor(pixelShader, modifiers), rectangle); |
|||
|
|||
/// <summary>
|
|||
/// Applies a user defined pixel shader to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader) |
|||
=> source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader)); |
|||
|
|||
/// <summary>
|
|||
/// Applies a user defined pixel shader to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
|
|||
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader, PixelConversionModifiers modifiers) |
|||
=> source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader, modifiers)); |
|||
|
|||
/// <summary>
|
|||
/// Applies a user defined pixel shader to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
|
|||
/// <param name="rectangle">
|
|||
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|||
/// </param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader, Rectangle rectangle) |
|||
=> source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader), rectangle); |
|||
|
|||
/// <summary>
|
|||
/// Applies a user defined pixel shader to the image.
|
|||
/// </summary>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
|
|||
/// <param name="rectangle">
|
|||
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|||
/// </param>
|
|||
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
|
|||
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|||
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader, Rectangle rectangle, PixelConversionModifiers modifiers) |
|||
=> source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader, modifiers), rectangle); |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing.Processors.Effects |
|||
{ |
|||
/// <summary>
|
|||
/// Applies a user defined row processing delegate to the image.
|
|||
/// </summary>
|
|||
public sealed class PixelRowDelegateProcessor : IImageProcessor |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="PixelRowDelegateProcessor"/> class.
|
|||
/// </summary>
|
|||
/// <param name="pixelRowOperation">The user defined, row processing delegate.</param>
|
|||
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
|
|||
public PixelRowDelegateProcessor(PixelRowOperation pixelRowOperation, PixelConversionModifiers modifiers) |
|||
{ |
|||
this.PixelRowOperation = pixelRowOperation; |
|||
this.Modifiers = modifiers; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the user defined row processing delegate to the image.
|
|||
/// </summary>
|
|||
public PixelRowOperation PixelRowOperation { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.
|
|||
/// </summary>
|
|||
public PixelConversionModifiers Modifiers { get; } |
|||
|
|||
/// <inheritdoc />
|
|||
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
=> new PixelRowDelegateProcessor<TPixel>(configuration, this, source, sourceRectangle); |
|||
} |
|||
} |
|||
@ -1,58 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing.Processors.Effects |
|||
{ |
|||
/// <summary>
|
|||
/// Applies a user defined pixel shader effect through a given delegate.
|
|||
/// </summary>
|
|||
public sealed class PixelShaderProcessor : IImageProcessor |
|||
{ |
|||
/// <summary>
|
|||
/// The default <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.
|
|||
/// </summary>
|
|||
public const PixelConversionModifiers DefaultModifiers = PixelConversionModifiers.None; |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="PixelShaderProcessor"/> class.
|
|||
/// </summary>
|
|||
/// <param name="pixelShader">
|
|||
/// The user defined pixel shader to use to modify images.
|
|||
/// </param>
|
|||
public PixelShaderProcessor(PixelShader pixelShader) |
|||
{ |
|||
this.PixelShader = pixelShader; |
|||
this.Modifiers = DefaultModifiers; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="PixelShaderProcessor"/> class.
|
|||
/// </summary>
|
|||
/// <param name="pixelShader">
|
|||
/// The user defined pixel shader to use to modify images.
|
|||
/// </param>
|
|||
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
|
|||
public PixelShaderProcessor(PixelShader pixelShader, PixelConversionModifiers modifiers) |
|||
{ |
|||
this.PixelShader = pixelShader; |
|||
this.Modifiers = modifiers; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the user defined pixel shader.
|
|||
/// </summary>
|
|||
public PixelShader PixelShader { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.
|
|||
/// </summary>
|
|||
public PixelConversionModifiers Modifiers { get; } |
|||
|
|||
/// <inheritdoc />
|
|||
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
=> new PixelShaderProcessor<TPixel>(configuration, this, source, sourceRectangle); |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing.Processors.Effects |
|||
{ |
|||
/// <summary>
|
|||
/// Applies a user defined, position aware, row processing delegate to the image.
|
|||
/// </summary>
|
|||
public sealed class PositionAwarePixelRowDelegateProcessor : IImageProcessor |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="PositionAwarePixelRowDelegateProcessor"/> class.
|
|||
/// </summary>
|
|||
/// <param name="pixelRowOperation">The user defined, position aware, row processing delegate.</param>
|
|||
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
|
|||
public PositionAwarePixelRowDelegateProcessor(PositionAwarePixelRowOperation pixelRowOperation, PixelConversionModifiers modifiers) |
|||
{ |
|||
this.PixelRowOperation = pixelRowOperation; |
|||
this.Modifiers = modifiers; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the user defined, position aware, row processing delegate.
|
|||
/// </summary>
|
|||
public PositionAwarePixelRowOperation PixelRowOperation { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.
|
|||
/// </summary>
|
|||
public PixelConversionModifiers Modifiers { get; } |
|||
|
|||
/// <inheritdoc />
|
|||
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
=> new PositionAwarePixelRowDelegateProcessor<TPixel>(configuration, this, source, sourceRectangle); |
|||
} |
|||
} |
|||
@ -1,58 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing.Processors.Effects |
|||
{ |
|||
/// <summary>
|
|||
/// Applies a user defined pixel shader effect through a given delegate.
|
|||
/// </summary>
|
|||
public sealed class PositionAwarePixelShaderProcessor : IImageProcessor |
|||
{ |
|||
/// <summary>
|
|||
/// The default <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.
|
|||
/// </summary>
|
|||
public const PixelConversionModifiers DefaultModifiers = PixelConversionModifiers.None; |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="PositionAwarePixelShaderProcessor"/> class.
|
|||
/// </summary>
|
|||
/// <param name="pixelShader">
|
|||
/// The user defined pixel shader to use to modify images.
|
|||
/// </param>
|
|||
public PositionAwarePixelShaderProcessor(PositionAwarePixelShader pixelShader) |
|||
{ |
|||
this.PixelShader = pixelShader; |
|||
this.Modifiers = DefaultModifiers; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="PositionAwarePixelShaderProcessor"/> class.
|
|||
/// </summary>
|
|||
/// <param name="pixelShader">
|
|||
/// The user defined pixel shader to use to modify images.
|
|||
/// </param>
|
|||
/// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param>
|
|||
public PositionAwarePixelShaderProcessor(PositionAwarePixelShader pixelShader, PixelConversionModifiers modifiers) |
|||
{ |
|||
this.PixelShader = pixelShader; |
|||
this.Modifiers = modifiers; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the user defined pixel shader.
|
|||
/// </summary>
|
|||
public PositionAwarePixelShader PixelShader { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.
|
|||
/// </summary>
|
|||
public PixelConversionModifiers Modifiers { get; } |
|||
|
|||
/// <inheritdoc />
|
|||
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
=> new PositionAwarePixelShaderProcessor<TPixel>(configuration, this, source, sourceRectangle); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue