Browse Source

Fix Convolution2DProcessor

Also inlined ColorMatrix cos I spotted it and couldn't ignore.
pull/195/head
James Jackson-South 9 years ago
parent
commit
1492da85d9
  1. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixProcessor.cs
  2. 9
      src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs

2
src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixProcessor.cs

@ -7,6 +7,7 @@ namespace ImageSharp.Processing.Processors
{ {
using System; using System;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using ImageSharp.PixelFormats; using ImageSharp.PixelFormats;
@ -79,6 +80,7 @@ namespace ImageSharp.Processing.Processors
/// <returns> /// <returns>
/// The <see cref="Rgba32"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private TPixel ApplyMatrix(TPixel color, Matrix4x4 matrix, bool compand) private TPixel ApplyMatrix(TPixel color, Matrix4x4 matrix, bool compand)
{ {
Vector4 vector = color.ToVector4(); Vector4 vector = color.ToVector4();

9
src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs

@ -5,7 +5,6 @@
namespace ImageSharp.Processing.Processors namespace ImageSharp.Processing.Processors
{ {
using System;
using System.Numerics; using System.Numerics;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -57,10 +56,11 @@ namespace ImageSharp.Processing.Processors
int maxX = endX - 1; int maxX = endX - 1;
using (PixelAccessor<TPixel> targetPixels = new PixelAccessor<TPixel>(source.Width, source.Height)) using (PixelAccessor<TPixel> targetPixels = new PixelAccessor<TPixel>(source.Width, source.Height))
using (PixelAccessor<TPixel> sourcePixels = source.Lock())
{ {
using (PixelAccessor<TPixel> sourcePixels = source.Lock()) sourcePixels.CopyTo(targetPixels);
{
Parallel.For( Parallel.For(
startY, startY,
endY, endY,
this.ParallelOptions, this.ParallelOptions,
@ -119,7 +119,6 @@ namespace ImageSharp.Processing.Processors
targetPixels[x, y] = packed; targetPixels[x, y] = packed;
} }
}); });
}
source.SwapPixelsBuffers(targetPixels); source.SwapPixelsBuffers(targetPixels);
} }

Loading…
Cancel
Save