Browse Source

Simplify ResizeKernel

af/merge-core
Anton Firszov 8 years ago
parent
commit
915ab70853
  1. 13
      src/ImageSharp/Processing/Processors/Transforms/ResizeKernel.cs

13
src/ImageSharp/Processing/Processors/Transforms/ResizeKernel.cs

@ -27,11 +27,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
/// </summary> /// </summary>
public int Length; public int Length;
/// <summary>
/// The index in the destination buffer
/// </summary>
private readonly int flatStartIndex;
/// <summary> /// <summary>
/// The buffer containing the weights values. /// The buffer containing the weights values.
/// </summary> /// </summary>
@ -47,9 +42,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
internal ResizeKernel(int index, int left, Buffer2D<float> buffer, int length) internal ResizeKernel(int index, int left, Buffer2D<float> buffer, int length)
{ {
this.flatStartIndex = index * buffer.Width; int flatStartIndex = index * buffer.Width;
this.Left = left; this.Left = left;
this.buffer = buffer.MemorySource.Memory; this.buffer = buffer.MemorySource.Memory.Slice(flatStartIndex, length);
this.Length = length; this.Length = length;
} }
@ -61,7 +56,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
public ref float GetStartReference() public ref float GetStartReference()
{ {
Span<float> span = this.buffer.Span; Span<float> span = this.buffer.Span;
return ref span[this.flatStartIndex]; return ref span[0];
} }
/// <summary> /// <summary>
@ -69,7 +64,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
/// </summary> /// </summary>
/// <returns>The <see cref="Span{T}"/></returns> /// <returns>The <see cref="Span{T}"/></returns>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public Span<float> GetSpan() => this.buffer.Span.Slice(this.flatStartIndex, this.Length); public Span<float> GetSpan() => this.buffer.Span;
/// <summary> /// <summary>
/// Computes the sum of vectors in 'rowSpan' weighted by weight values, pointed by this <see cref="ResizeKernel"/> instance. /// Computes the sum of vectors in 'rowSpan' weighted by weight values, pointed by this <see cref="ResizeKernel"/> instance.

Loading…
Cancel
Save