Browse Source

fix CopyTo***Bytes()

af/merge-core
Anton Firszov 9 years ago
parent
commit
1ba4cf54d1
  1. 8
      src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs
  2. 2
      src/ImageSharp/Common/Memory/BufferSpan.cs
  3. 1
      tests/ImageSharp.Benchmarks/General/PixelIndexing.cs

8
src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs

@ -105,7 +105,7 @@ namespace ImageSharp
for (int i = 0; i < count; i++)
{
ref TColor sp = ref Unsafe.Add(ref sourceRef, i);
sp.ToXyzBytes(dest, i * 3);
sp.ToXyzBytes(dest, destBytes.Start + (i * 3));
}
}
@ -152,7 +152,7 @@ namespace ImageSharp
for (int i = 0; i < count; i++)
{
ref TColor sp = ref Unsafe.Add(ref sourceRef, i);
sp.ToXyzwBytes(dest, i * 4);
sp.ToXyzwBytes(dest, destBytes.Start + (i * 4));
}
}
@ -196,7 +196,7 @@ namespace ImageSharp
for (int i = 0; i < count; i++)
{
ref TColor sp = ref Unsafe.Add(ref sourceRef, i);
sp.ToZyxBytes(dest, i * 3);
sp.ToZyxBytes(dest, destBytes.Start + (i * 3));
}
}
@ -243,7 +243,7 @@ namespace ImageSharp
for (int i = 0; i < count; i++)
{
ref TColor sp = ref Unsafe.Add(ref sourceRef, i);
sp.ToZyxwBytes(dest, i * 4);
sp.ToZyxwBytes(dest, destBytes.Start + (i * 4));
}
}
}

2
src/ImageSharp/Common/Memory/BufferSpan.cs

@ -35,7 +35,7 @@ namespace ImageSharp
fixed (byte* pDest = &destRef)
{
#if NETSTANDARD1_1
Unsafe.CopyBlock(pDest, pSrc, (uint) byteCount);
Unsafe.CopyBlock(pDest, pSrc, (uint)byteCount);
#else
if (byteCount > 512)
{

1
tests/ImageSharp.Benchmarks/General/PixelIndexing.cs

@ -46,6 +46,7 @@
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Vector4 GetPointersSrcsUnsafeImpl(int x, int y)
{
// This is the original solution in PixelAccessor:
return Unsafe.Read<Vector4>((byte*)this.pointer + (((y * this.width) + x) * Unsafe.SizeOf<Vector4>()));
}

Loading…
Cancel
Save