Browse Source

Remove PixelAccessor and cleanup

pull/364/head
James Jackson-South 8 years ago
parent
commit
fdd68c7ea4
  1. 11
      src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs

11
src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs

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

Loading…
Cancel
Save