Browse Source

fix wrong Slice() usages

af/merge-core
Anton Firszov 8 years ago
parent
commit
3d4ae63da5
  1. 18
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs
  2. 2
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt
  3. 2
      src/ImageSharp/Processing/Processors/Quantization/FrameQuantizerBase{TPixel}.cs
  4. 2
      tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs

18
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs

@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToArgb32Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count) internal void ToArgb32Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{ {
this.ToArgb32(sourcePixels.Slice(count), MemoryMarshal.Cast<byte, Argb32>(destBytes)); this.ToArgb32(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Argb32>(destBytes));
} }
/// <summary> /// <summary>
@ -143,7 +143,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToBgr24Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count) internal void ToBgr24Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{ {
this.ToBgr24(sourcePixels.Slice(count), MemoryMarshal.Cast<byte, Bgr24>(destBytes)); this.ToBgr24(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Bgr24>(destBytes));
} }
/// <summary> /// <summary>
@ -211,7 +211,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToBgra32Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count) internal void ToBgra32Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{ {
this.ToBgra32(sourcePixels.Slice(count), MemoryMarshal.Cast<byte, Bgra32>(destBytes)); this.ToBgra32(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Bgra32>(destBytes));
} }
/// <summary> /// <summary>
@ -279,7 +279,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToGray8Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count) internal void ToGray8Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{ {
this.ToGray8(sourcePixels.Slice(count), MemoryMarshal.Cast<byte, Gray8>(destBytes)); this.ToGray8(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Gray8>(destBytes));
} }
/// <summary> /// <summary>
@ -347,7 +347,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToGray16Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count) internal void ToGray16Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{ {
this.ToGray16(sourcePixels.Slice(count), MemoryMarshal.Cast<byte, Gray16>(destBytes)); this.ToGray16(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Gray16>(destBytes));
} }
/// <summary> /// <summary>
@ -415,7 +415,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgb24Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count) internal void ToRgb24Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{ {
this.ToRgb24(sourcePixels.Slice(count), MemoryMarshal.Cast<byte, Rgb24>(destBytes)); this.ToRgb24(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgb24>(destBytes));
} }
/// <summary> /// <summary>
@ -483,7 +483,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgba32Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count) internal void ToRgba32Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{ {
this.ToRgba32(sourcePixels.Slice(count), MemoryMarshal.Cast<byte, Rgba32>(destBytes)); this.ToRgba32(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgba32>(destBytes));
} }
/// <summary> /// <summary>
@ -551,7 +551,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgb48Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count) internal void ToRgb48Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{ {
this.ToRgb48(sourcePixels.Slice(count), MemoryMarshal.Cast<byte, Rgb48>(destBytes)); this.ToRgb48(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgb48>(destBytes));
} }
/// <summary> /// <summary>
@ -619,7 +619,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgba64Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count) internal void ToRgba64Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{ {
this.ToRgba64(sourcePixels.Slice(count), MemoryMarshal.Cast<byte, Rgba64>(destBytes)); this.ToRgba64(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Rgba64>(destBytes));
} }
} }
} }

2
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt

@ -86,7 +86,7 @@
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void To<#=pixelType#>Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count) internal void To<#=pixelType#>Bytes(ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{ {
this.To<#=pixelType#>(sourcePixels.Slice(count), MemoryMarshal.Cast<byte, <#=pixelType#>>(destBytes)); this.To<#=pixelType#>(sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, <#=pixelType#>>(destBytes));
} }
<# <#
} }

2
src/ImageSharp/Processing/Processors/Quantization/FrameQuantizerBase{TPixel}.cs

@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
public virtual QuantizedFrame<TPixel> QuantizeFrame(ImageFrame<TPixel> image) public virtual QuantizedFrame<TPixel> QuantizeFrame(ImageFrame<TPixel> image)
{ {
Guard.NotNull(image, nameof(image)); Guard.NotNull(image, nameof(image));
// Get the size of the source image // Get the size of the source image
int height = image.Height; int height = image.Height;
int width = image.Width; int width = image.Width;

2
tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs

@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
byte* sourcePtr = sourcePtrBase + (data.Stride * y); byte* sourcePtr = sourcePtrBase + (data.Stride * y);
Buffer.MemoryCopy(sourcePtr, destPtr, destRowByteCount, sourceRowByteCount); Buffer.MemoryCopy(sourcePtr, destPtr, destRowByteCount, sourceRowByteCount);
PixelOperations<TPixel>.Instance.FromBgr24(workBuffer.GetSpan().Slice(w), row); PixelOperations<TPixel>.Instance.FromBgr24(workBuffer.GetSpan().Slice(0, w), row);
} }
} }
} }

Loading…
Cancel
Save