diff --git a/src/ImageSharp/Common/Memory/BufferSpan{T}.cs b/src/ImageSharp/Common/Memory/BufferSpan{T}.cs index 25d01631d..23b8bece7 100644 --- a/src/ImageSharp/Common/Memory/BufferSpan{T}.cs +++ b/src/ImageSharp/Common/Memory/BufferSpan{T}.cs @@ -76,7 +76,7 @@ namespace ImageSharp } /// - /// Gets the backing array + /// Gets the backing array. /// public T[] Array { get; private set; } @@ -122,6 +122,7 @@ namespace ImageSharp BufferSpan result = default(BufferSpan); result.Array = Unsafe.As(source.Array); result.Start = source.Start * Unsafe.SizeOf(); + result.Length = source.Length * Unsafe.SizeOf(); return result; } @@ -131,7 +132,11 @@ namespace ImageSharp /// /// The reference to the 0th element [MethodImpl(MethodImplOptions.AggressiveInlining)] - public ref T DangerousGetPinnableReference() => ref this.Array[this.Start]; + public ref T DangerousGetPinnableReference() + { + ref T origin = ref this.Array[0]; + return ref Unsafe.Add(ref origin, this.Start); + } /// /// Forms a slice out of the given BufferSpan, beginning at 'start'.