|
|
|
@ -1,31 +1,31 @@ |
|
|
|
// Copyright (c) Six Labors and contributors.
|
|
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
|
|
|
|
using System; |
|
|
|
// Copyright (c) Six Labors and contributors.
|
|
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System.Buffers; |
|
|
|
using System.Numerics; |
|
|
|
using SixLabors.ImageSharp.Memory; |
|
|
|
using SixLabors.Memory; |
|
|
|
|
|
|
|
namespace SixLabors.ImageSharp.PixelFormats |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Abstract base class for calling pixel composition functions
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="TPixel">The type of the pixel</typeparam>
|
|
|
|
internal abstract class PixelBlender<TPixel> |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Blend 2 pixels together.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="background">The background color.</param>
|
|
|
|
/// <param name="source">The source color.</param>
|
|
|
|
/// <param name="amount">
|
|
|
|
/// A value between 0 and 1 indicating the weight of the second source vector.
|
|
|
|
/// At amount = 0, "from" is returned, at amount = 1, "to" is returned.
|
|
|
|
/// </param>
|
|
|
|
/// <returns>The final pixel value after composition</returns>
|
|
|
|
using SixLabors.Memory; |
|
|
|
|
|
|
|
namespace SixLabors.ImageSharp.PixelFormats |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Abstract base class for calling pixel composition functions
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="TPixel">The type of the pixel</typeparam>
|
|
|
|
internal abstract class PixelBlender<TPixel> |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Blend 2 pixels together.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="background">The background color.</param>
|
|
|
|
/// <param name="source">The source color.</param>
|
|
|
|
/// <param name="amount">
|
|
|
|
/// A value between 0 and 1 indicating the weight of the second source vector.
|
|
|
|
/// At amount = 0, "from" is returned, at amount = 1, "to" is returned.
|
|
|
|
/// </param>
|
|
|
|
/// <returns>The final pixel value after composition</returns>
|
|
|
|
public abstract TPixel Blend(TPixel background, TPixel source, float amount); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -34,9 +34,9 @@ namespace SixLabors.ImageSharp.PixelFormats |
|
|
|
/// <param name="destination">destination span</param>
|
|
|
|
/// <param name="background">the background span</param>
|
|
|
|
/// <param name="source">the source span</param>
|
|
|
|
/// <param name="amount">
|
|
|
|
/// A value between 0 and 1 indicating the weight of the second source vector.
|
|
|
|
/// At amount = 0, "from" is returned, at amount = 1, "to" is returned.
|
|
|
|
/// <param name="amount">
|
|
|
|
/// A value between 0 and 1 indicating the weight of the second source vector.
|
|
|
|
/// At amount = 0, "from" is returned, at amount = 1, "to" is returned.
|
|
|
|
/// </param>
|
|
|
|
protected abstract void BlendFunction(Span<Vector4> destination, ReadOnlySpan<Vector4> background, ReadOnlySpan<Vector4> source, float amount); |
|
|
|
|
|
|
|
@ -46,9 +46,9 @@ namespace SixLabors.ImageSharp.PixelFormats |
|
|
|
/// <param name="destination">destination span</param>
|
|
|
|
/// <param name="background">the background span</param>
|
|
|
|
/// <param name="source">the source span</param>
|
|
|
|
/// <param name="amount">
|
|
|
|
/// A span with values between 0 and 1 indicating the weight of the second source vector.
|
|
|
|
/// At amount = 0, "from" is returned, at amount = 1, "to" is returned.
|
|
|
|
/// <param name="amount">
|
|
|
|
/// A span with values between 0 and 1 indicating the weight of the second source vector.
|
|
|
|
/// At amount = 0, "from" is returned, at amount = 1, "to" is returned.
|
|
|
|
/// </param>
|
|
|
|
protected abstract void BlendFunction(Span<Vector4> destination, ReadOnlySpan<Vector4> background, ReadOnlySpan<Vector4> source, ReadOnlySpan<float> amount); |
|
|
|
|
|
|
|
@ -59,9 +59,9 @@ namespace SixLabors.ImageSharp.PixelFormats |
|
|
|
/// <param name="destination">the destination span</param>
|
|
|
|
/// <param name="background">the background span</param>
|
|
|
|
/// <param name="source">the source span</param>
|
|
|
|
/// <param name="amount">
|
|
|
|
/// A span with values between 0 and 1 indicating the weight of the second source vector.
|
|
|
|
/// At amount = 0, "from" is returned, at amount = 1, "to" is returned.
|
|
|
|
/// <param name="amount">
|
|
|
|
/// A span with values between 0 and 1 indicating the weight of the second source vector.
|
|
|
|
/// At amount = 0, "from" is returned, at amount = 1, "to" is returned.
|
|
|
|
/// </param>
|
|
|
|
public void Blend(MemoryAllocator memoryManager, Span<TPixel> destination, ReadOnlySpan<TPixel> background, ReadOnlySpan<TPixel> source, ReadOnlySpan<float> amount) |
|
|
|
{ |
|
|
|
@ -76,9 +76,9 @@ namespace SixLabors.ImageSharp.PixelFormats |
|
|
|
/// <param name="destination">the destination span</param>
|
|
|
|
/// <param name="background">the background span</param>
|
|
|
|
/// <param name="source">the source span</param>
|
|
|
|
/// <param name="amount">
|
|
|
|
/// A span with values between 0 and 1 indicating the weight of the second source vector.
|
|
|
|
/// At amount = 0, "from" is returned, at amount = 1, "to" is returned.
|
|
|
|
/// <param name="amount">
|
|
|
|
/// A span with values between 0 and 1 indicating the weight of the second source vector.
|
|
|
|
/// At amount = 0, "from" is returned, at amount = 1, "to" is returned.
|
|
|
|
/// </param>
|
|
|
|
public void Blend<TPixelSrc>(MemoryAllocator memoryManager, Span<TPixel> destination, ReadOnlySpan<TPixel> background, ReadOnlySpan<TPixelSrc> source, ReadOnlySpan<float> amount) |
|
|
|
where TPixelSrc : struct, IPixel<TPixelSrc> |
|
|
|
@ -110,9 +110,9 @@ namespace SixLabors.ImageSharp.PixelFormats |
|
|
|
/// <param name="destination">the destination span</param>
|
|
|
|
/// <param name="background">the background span</param>
|
|
|
|
/// <param name="source">the source span</param>
|
|
|
|
/// <param name="amount">
|
|
|
|
/// A value between 0 and 1 indicating the weight of the second source vector.
|
|
|
|
/// At amount = 0, "from" is returned, at amount = 1, "to" is returned.
|
|
|
|
/// <param name="amount">
|
|
|
|
/// A value between 0 and 1 indicating the weight of the second source vector.
|
|
|
|
/// At amount = 0, "from" is returned, at amount = 1, "to" is returned.
|
|
|
|
/// </param>
|
|
|
|
public void Blend<TPixelSrc>(MemoryAllocator memoryManager, Span<TPixel> destination, ReadOnlySpan<TPixel> background, ReadOnlySpan<TPixelSrc> source, float amount) |
|
|
|
where TPixelSrc : struct, IPixel<TPixelSrc> |
|
|
|
@ -135,5 +135,5 @@ namespace SixLabors.ImageSharp.PixelFormats |
|
|
|
PixelOperations<TPixel>.Instance.PackFromScaledVector4(destinationSpan, destination, destination.Length); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|