diff --git a/src/ImageSharp/Processing/Processors/Transforms/KernelMap.cs b/src/ImageSharp/Processing/Processors/Transforms/KernelMap.cs
index b0fd0e2cde..278fd93d82 100644
--- a/src/ImageSharp/Processing/Processors/Transforms/KernelMap.cs
+++ b/src/ImageSharp/Processing/Processors/Transforms/KernelMap.cs
@@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
/// The to use for allocations.
/// The size of the destination window
/// The radius of the kernel
- public KernelMap(MemoryAllocator memoryAllocator, int destinationSize, float kernelRadius)
+ private KernelMap(MemoryAllocator memoryAllocator, int destinationSize, float kernelRadius)
{
this.DestinationSize = destinationSize;
int width = (int)Math.Ceiling(kernelRadius * 2);
@@ -125,13 +125,12 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
///
/// Slices a weights value at the given positions.
///
- /// The index in destination buffer
- /// The local left index value
- /// The local right index value
- /// The weights
- private ResizeKernel CreateKernel(int destIdx, int leftIdx, int rightIdx)
+ private ResizeKernel CreateKernel(int destIdx, int left, int rightIdx)
{
- return new ResizeKernel(destIdx, leftIdx, this.data, rightIdx - leftIdx + 1);
+ int flatStartIndex = destIdx * this.data.Width;
+ int length = rightIdx - left + 1;
+ Memory bufferSlice = this.data.Memory.Slice(flatStartIndex, length);
+ return new ResizeKernel(left, bufferSlice);
}
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Transforms/ResizeKernel.cs b/src/ImageSharp/Processing/Processors/Transforms/ResizeKernel.cs
index 707f1467b0..1ce9c9c91e 100644
--- a/src/ImageSharp/Processing/Processors/Transforms/ResizeKernel.cs
+++ b/src/ImageSharp/Processing/Processors/Transforms/ResizeKernel.cs
@@ -16,42 +16,36 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
internal struct ResizeKernel
{
///
- /// The left index for the destination row
+ /// Initializes a new instance of the struct.
///
- public int Left;
+ [MethodImpl(InliningOptions.ShortMethod)]
+ internal ResizeKernel(int left, Memory bufferSlice)
+ {
+ this.Left = left;
+ this.BufferSlice = bufferSlice;
+ }
///
- /// The length of the kernel
+ /// Gets the left index for the destination row
///
- public int Length;
+ public int Left { get; }
///
- /// The buffer containing the weights values.
+ /// Gets the slice of the buffer containing the weights values.
///
- private readonly Memory buffer;
+ public Memory BufferSlice { get; }
///
- /// Initializes a new instance of the struct.
+ /// Gets the the length of the kernel
///
- /// The destination index in the buffer
- /// The local left index
- /// The span
- /// The length of the window
- [MethodImpl(InliningOptions.ShortMethod)]
- internal ResizeKernel(int index, int left, Buffer2D buffer, int length)
- {
- int flatStartIndex = index * buffer.Width;
- this.Left = left;
- this.buffer = buffer.MemorySource.Memory.Slice(flatStartIndex, length);
- this.Length = length;
- }
+ public int Length => this.BufferSlice.Length;
///
/// Gets the span representing the portion of the that this window covers
///
/// The
[MethodImpl(InliningOptions.ShortMethod)]
- public Span GetValues() => this.buffer.Span;
+ public Span GetValues() => this.BufferSlice.Span;
///
/// Computes the sum of vectors in 'rowSpan' weighted by weight values, pointed by this instance.