diff --git a/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs b/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs
index d236ec35c..a8ee4d90b 100644
--- a/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs
@@ -1,137 +1,137 @@
-// Copyright (c) Six Labors and contributors.
-// Licensed under the Apache License, Version 2.0.
-
-using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Processors.Drawing;
-using SixLabors.Primitives;
-
-namespace SixLabors.ImageSharp.Processing
-{
- ///
- /// Adds extensions that allow the drawing of images to the type.
- ///
- public static class DrawImageExtensions
- {
- ///
- /// Draws the given image together with the current one by blending their pixels.
- ///
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Processors.Drawing;
+using SixLabors.Primitives;
+
+namespace SixLabors.ImageSharp.Processing
+{
+ ///
+ /// Adds extensions that allow the drawing of images to the type.
+ ///
+ public static class DrawImageExtensions
+ {
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
/// The pixel format of the destination image.
- /// The pixel format of the source image.
- /// The image this method extends.
- /// The image to blend with the currently processing image.
- /// The opacity of the image to blend. Must be between 0 and 1.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, float opacity)
+ /// The pixel format of the source image.
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
+ /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The .
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, float opacity)
where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity));
-
- ///
- /// Draws the given image together with the current one by blending their pixels.
- ///
+ where TPixelSrc : struct, IPixel
+ => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity));
+
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
/// The pixel format of the destination image.
- /// The pixel format of the source image.
- /// The image this method extends.
- /// The image to blend with the currently processing image.
- /// The blending mode.
- /// The opacity of the image to blend. Must be between 0 and 1.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode colorBlending, float opacity)
+ /// The pixel format of the source image.
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
+ /// The blending mode.
+ /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The .
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode colorBlending, float opacity)
where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
+ where TPixelSrc : struct, IPixel
=> source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity));
- ///
- /// Draws the given image together with the current one by blending their pixels.
- ///
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
/// The pixel format of the destination image.
- /// The pixel format of the source image.
- /// The image this method extends.
- /// The image to blend with the currently processing image.
+ /// The pixel format of the source image.
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
/// The color blending mode.
- /// The alpha composition mode.
- /// The opacity of the image to blend. Must be between 0 and 1.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity)
+ /// The alpha composition mode.
+ /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The .
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity)
where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
+ where TPixelSrc : struct, IPixel
=> source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, colorBlending, alphaComposition, opacity));
- ///
- /// Draws the given image together with the current one by blending their pixels.
- ///
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
/// The pixel format of the destination image.
- /// The pixel format of the source image.
+ /// The pixel format of the source image.
/// The image this method extends.
- /// The image to blend with the currently processing image.
+ /// The image to blend with the currently processing image.
/// The options, including the blending type and blending amount.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, GraphicsOptions options)
+ /// The .
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, GraphicsOptions options)
where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
+ where TPixelSrc : struct, IPixel
=> source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage));
- ///
- /// Draws the given image together with the current one by blending their pixels.
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
///
/// The pixel format of the destination image.
- /// The pixel format of the source image.
- /// The image this method extends.
+ /// The pixel format of the source image.
+ /// The image this method extends.
/// The image to blend with the currently processing image.
- /// The location to draw the blended image.
+ /// The location to draw the blended image.
/// The opacity of the image to blend. Must be between 0 and 1.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, float opacity)
+ /// The .
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, float opacity)
where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
+ where TPixelSrc : struct, IPixel
=> source.ApplyProcessor(new DrawImageProcessor(image, location, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity));
- ///
- /// Draws the given image together with the current one by blending their pixels.
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
///
/// The pixel format of the destination image.
- /// The pixel format of the source image.
- /// The image this method extends.
+ /// The pixel format of the source image.
+ /// The image this method extends.
/// The image to blend with the currently processing image.
- /// The location to draw the blended image.
- /// The color blending to apply.
+ /// The location to draw the blended image.
+ /// The color blending to apply.
/// The opacity of the image to blend. Must be between 0 and 1.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, PixelColorBlendingMode colorBlending, float opacity)
+ /// The .
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, PixelColorBlendingMode colorBlending, float opacity)
where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
+ where TPixelSrc : struct, IPixel
=> source.ApplyProcessor(new DrawImageProcessor(image, location, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity));
- ///
- /// Draws the given image together with the current one by blending their pixels.
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
///
/// The pixel format of the destination image.
- /// The pixel format of the source image.
- /// The image this method extends.
+ /// The pixel format of the source image.
+ /// The image this method extends.
/// The image to blend with the currently processing image.
- /// The location to draw the blended image.
+ /// The location to draw the blended image.
/// The color blending to apply.
- /// The alpha composition mode.
+ /// The alpha composition mode.
/// The opacity of the image to blend. Must be between 0 and 1.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity)
+ /// The .
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity)
where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
+ where TPixelSrc : struct, IPixel
=> source.ApplyProcessor(new DrawImageProcessor(image, location, colorBlending, alphaComposition, opacity));
- ///
- /// Draws the given image together with the current one by blending their pixels.
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
///
/// The pixel format of the destination image.
- /// The pixel format of the source image.
+ /// The pixel format of the source image.
/// The image this method extends.
/// The image to blend with the currently processing image.
/// The location to draw the blended image.
- /// The options containing the blend mode and opacity.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, GraphicsOptions options)
+ /// The options containing the blend mode and opacity.
+ /// The .
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, GraphicsOptions options)
where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, location, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage));
- }
+ where TPixelSrc : struct, IPixel
+ => source.ApplyProcessor(new DrawImageProcessor(image, location, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage));
+ }
}
\ No newline at end of file
diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs
index cd3b5d427..19d1c5dad 100644
--- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs
@@ -1,3818 +1,3926 @@
-
-
-
-
-
-
-
-// Copyright (c) Six Labors and contributors.
-// Licensed under the Apache License, Version 2.0.
-
-//
+
+
+
+
+
+
+
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+//
using System;
using System.Numerics;
using System.Buffers;
using SixLabors.ImageSharp.Memory;
-using SixLabors.Memory;
-
-namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
-{
- ///
- /// Collection of Porter Duff alpha blending functions applying different composition models.
- ///
- ///
- /// These functions are designed to be a general solution for all color cases,
- /// that is, they take in account the alpha value of both the backdrop
- /// and source, and there's no need to alpha-premultiply neither the backdrop
- /// nor the source.
- /// Note there are faster functions for when the backdrop color is known
- /// to be opaque
- ///
- internal static class DefaultPixelBlenders
- where TPixel : struct, IPixel
- {
-
-
- internal class NormalSrc : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static NormalSrc Instance { get; } = new NormalSrc();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.NormalSrc(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.NormalSrc(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.NormalSrc(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class MultiplySrc : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static MultiplySrc Instance { get; } = new MultiplySrc();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.MultiplySrc(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.MultiplySrc(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.MultiplySrc(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class AddSrc : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static AddSrc Instance { get; } = new AddSrc();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.AddSrc(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.AddSrc(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.AddSrc(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class SubtractSrc : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static SubtractSrc Instance { get; } = new SubtractSrc();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.SubtractSrc(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.SubtractSrc(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.SubtractSrc(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class ScreenSrc : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static ScreenSrc Instance { get; } = new ScreenSrc();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.ScreenSrc(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.ScreenSrc(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.ScreenSrc(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class DarkenSrc : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static DarkenSrc Instance { get; } = new DarkenSrc();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.DarkenSrc(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.DarkenSrc(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.DarkenSrc(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class LightenSrc : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static LightenSrc Instance { get; } = new LightenSrc();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.LightenSrc(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.LightenSrc(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.LightenSrc(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class OverlaySrc : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static OverlaySrc Instance { get; } = new OverlaySrc();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.OverlaySrc(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.OverlaySrc(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.OverlaySrc(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class HardLightSrc : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static HardLightSrc Instance { get; } = new HardLightSrc();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.HardLightSrc(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.HardLightSrc(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.HardLightSrc(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class NormalSrcAtop : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static NormalSrcAtop Instance { get; } = new NormalSrcAtop();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.NormalSrcAtop(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.NormalSrcAtop(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.NormalSrcAtop(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class MultiplySrcAtop : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static MultiplySrcAtop Instance { get; } = new MultiplySrcAtop();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.MultiplySrcAtop(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.MultiplySrcAtop(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.MultiplySrcAtop(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class AddSrcAtop : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static AddSrcAtop Instance { get; } = new AddSrcAtop();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.AddSrcAtop(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.AddSrcAtop(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.AddSrcAtop(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class SubtractSrcAtop : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static SubtractSrcAtop Instance { get; } = new SubtractSrcAtop();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.SubtractSrcAtop(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.SubtractSrcAtop(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.SubtractSrcAtop(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class ScreenSrcAtop : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static ScreenSrcAtop Instance { get; } = new ScreenSrcAtop();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.ScreenSrcAtop(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.ScreenSrcAtop(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.ScreenSrcAtop(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class DarkenSrcAtop : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static DarkenSrcAtop Instance { get; } = new DarkenSrcAtop();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.DarkenSrcAtop(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.DarkenSrcAtop(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.DarkenSrcAtop(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class LightenSrcAtop : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static LightenSrcAtop Instance { get; } = new LightenSrcAtop();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.LightenSrcAtop(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.LightenSrcAtop(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.LightenSrcAtop(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class OverlaySrcAtop : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static OverlaySrcAtop Instance { get; } = new OverlaySrcAtop();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.OverlaySrcAtop(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.OverlaySrcAtop(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.OverlaySrcAtop(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class HardLightSrcAtop : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static HardLightSrcAtop Instance { get; } = new HardLightSrcAtop();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.HardLightSrcAtop(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.HardLightSrcAtop(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.HardLightSrcAtop(background[i], source[i], amount[i]);
- }
- }
- }
-
-
- internal class NormalSrcOver : PixelBlender
- {
- ///
- /// Gets the static instance of this blender.
- ///
- public static NormalSrcOver Instance { get; } = new NormalSrcOver();
-
- ///
- public override TPixel Blend(TPixel background, TPixel source, float amount)
- {
- TPixel dest = default;
- dest.PackFromScaledVector4(PorterDuffFunctions.NormalSrcOver(background.ToScaledVector4(),source.ToScaledVector4(),amount.Clamp(0,1)));
- return dest;
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount)
- {
- for (int i = 0; i < destination.Length; i++)
- {
- destination[i] = PorterDuffFunctions.NormalSrcOver(background[i], source[i], amount);
- }
- }
-
- ///
- protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan