|
|
|
@ -2,7 +2,6 @@ |
|
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System.Numerics; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using SixLabors.ImageSharp.Advanced; |
|
|
|
using SixLabors.ImageSharp.Helpers; |
|
|
|
@ -42,7 +41,7 @@ namespace SixLabors.ImageSharp.Drawing.Processors |
|
|
|
/// <summary>
|
|
|
|
/// Gets the image to blend.
|
|
|
|
/// </summary>
|
|
|
|
public Image<TPixel> Image { get; private set; } |
|
|
|
public Image<TPixel> Image { get; } |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the alpha percentage value.
|
|
|
|
@ -84,9 +83,7 @@ namespace SixLabors.ImageSharp.Drawing.Processors |
|
|
|
maxY = Math.Min(this.Location.Y + this.Size.Height, maxY); |
|
|
|
|
|
|
|
int width = maxX - minX; |
|
|
|
using (Buffer<float> amount = new Buffer<float>(width)) |
|
|
|
using (PixelAccessor<TPixel> toBlendPixels = targetImage.Lock()) |
|
|
|
using (PixelAccessor<TPixel> sourcePixels = source.Lock()) |
|
|
|
using (var amount = new Buffer<float>(width)) |
|
|
|
{ |
|
|
|
for (int i = 0; i < width; i++) |
|
|
|
{ |
|
|
|
@ -99,8 +96,8 @@ namespace SixLabors.ImageSharp.Drawing.Processors |
|
|
|
configuration.ParallelOptions, |
|
|
|
y => |
|
|
|
{ |
|
|
|
Span<TPixel> background = sourcePixels.GetRowSpan(y).Slice(minX, width); |
|
|
|
Span<TPixel> foreground = toBlendPixels.GetRowSpan(y - this.Location.Y).Slice(0, width); |
|
|
|
Span<TPixel> background = source.GetPixelRowSpan(y).Slice(minX, width); |
|
|
|
Span<TPixel> foreground = targetImage.GetPixelRowSpan(y - this.Location.Y).Slice(0, width); |
|
|
|
this.blender.Blend(background, background, foreground, amount); |
|
|
|
}); |
|
|
|
} |
|
|
|
|