diff --git a/src/ImageSharp/Image.LoadPixelData.cs b/src/ImageSharp/Image.LoadPixelData.cs
index 5f1a1617f2..9df8b1d99a 100644
--- a/src/ImageSharp/Image.LoadPixelData.cs
+++ b/src/ImageSharp/Image.LoadPixelData.cs
@@ -2,12 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using System;
-using System.IO;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
using SixLabors.ImageSharp.Advanced;
-using SixLabors.ImageSharp.Formats;
-using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp
@@ -102,14 +97,11 @@ namespace SixLabors.ImageSharp
/// A new .
public static Image LoadPixelData(Configuration config, TPixel[] data, int width, int height)
where TPixel : struct, IPixel
- {
- int count = width * height;
- Guard.MustBeGreaterThanOrEqualTo(data.Length, count, nameof(data));
+ {
+ // There's an implict cast to Span from Array
+ // Should we remove this overload and expose Span ?
- var image = new Image(config, width, height);
- SpanHelper.Copy(data, image.GetPixelSpan(), count);
-
- return image;
+ return LoadPixelData(config, new Span(data), width, height);
}
///
@@ -128,7 +120,8 @@ namespace SixLabors.ImageSharp
Guard.MustBeGreaterThanOrEqualTo(data.Length, count, nameof(data));
var image = new Image(config, width, height);
- SpanHelper.Copy(data, image.Frames.RootFrame.GetPixelSpan(), count);
+
+ data.Slice(0, count).CopyTo(image.Frames.RootFrame.GetPixelSpan());
return image;
}
diff --git a/src/ImageSharp/ImageFrame.LoadPixelData.cs b/src/ImageSharp/ImageFrame.LoadPixelData.cs
index b9341a1b24..9a733fb536 100644
--- a/src/ImageSharp/ImageFrame.LoadPixelData.cs
+++ b/src/ImageSharp/ImageFrame.LoadPixelData.cs
@@ -2,11 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using System;
-using System.IO;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
using SixLabors.ImageSharp.Advanced;
-using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
@@ -46,7 +42,8 @@ namespace SixLabors.ImageSharp
Guard.MustBeGreaterThanOrEqualTo(data.Length, count, nameof(data));
var image = new ImageFrame(memoryManager, width, height);
- SpanHelper.Copy(data, image.GetPixelSpan(), count);
+
+ data.Slice(0, count).CopyTo(image.GetPixelSpan());
return image;
}
diff --git a/src/ImageSharp/ImageFrame{TPixel}.cs b/src/ImageSharp/ImageFrame{TPixel}.cs
index 888aff905e..338a18a403 100644
--- a/src/ImageSharp/ImageFrame{TPixel}.cs
+++ b/src/ImageSharp/ImageFrame{TPixel}.cs
@@ -181,7 +181,7 @@ namespace SixLabors.ImageSharp
throw new ArgumentException("ImageFrame.CopyTo(): target must be of the same size!", nameof(target));
}
- SpanHelper.Copy(this.GetPixelSpan(), target.Span);
+ this.GetPixelSpan().CopyTo(target.Span);
}
///
diff --git a/src/ImageSharp/PixelAccessor{TPixel}.cs b/src/ImageSharp/PixelAccessor{TPixel}.cs
index 63e4c015c1..1e789f0a68 100644
--- a/src/ImageSharp/PixelAccessor{TPixel}.cs
+++ b/src/ImageSharp/PixelAccessor{TPixel}.cs
@@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp
/// The target pixel buffer accessor.
internal void CopyTo(PixelAccessor target)
{
- SpanHelper.Copy(this.PixelBuffer.Span, target.PixelBuffer.Span);
+ this.PixelBuffer.Span.CopyTo(target.PixelBuffer.Span);
}
///
diff --git a/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs b/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs
index a7e5736b0e..7d5d632411 100644
--- a/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs
+++ b/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs
@@ -149,7 +149,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
- SpanHelper.Copy(source, destPixels, count);
+ source.Slice(0, count).CopyTo(destPixels);
}
///
@@ -157,7 +157,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
GuardSpans(sourcePixels, nameof(sourcePixels), dest, nameof(dest), count);
- SpanHelper.Copy(sourcePixels, dest, count);
+ sourcePixels.Slice(0, count).CopyTo(dest);
}
///
diff --git a/src/ImageSharp/PixelFormats/RgbaVector.PixelOperations.cs b/src/ImageSharp/PixelFormats/RgbaVector.PixelOperations.cs
index f038eaa910..0817ef5ad3 100644
--- a/src/ImageSharp/PixelFormats/RgbaVector.PixelOperations.cs
+++ b/src/ImageSharp/PixelFormats/RgbaVector.PixelOperations.cs
@@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
GuardSpans(sourceColors, nameof(sourceColors), destVectors, nameof(destVectors), count);
- SpanHelper.Copy(sourceColors.NonPortableCast(), destVectors, count);
+ sourceColors.NonPortableCast().Slice(0, count).CopyTo(destVectors);
}
}
}
diff --git a/src/ImageSharp/Processing/Transforms/Processors/CropProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/CropProcessor.cs
index 5462b34dca..bfbf349b52 100644
--- a/src/ImageSharp/Processing/Transforms/Processors/CropProcessor.cs
+++ b/src/ImageSharp/Processing/Transforms/Processors/CropProcessor.cs
@@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors
{
Span sourceRow = source.GetPixelRowSpan(y).Slice(minX);
Span targetRow = destination.GetPixelRowSpan(y - minY);
- SpanHelper.Copy(sourceRow, targetRow, maxX - minX);
+ sourceRow.Slice(0, maxX - minX).CopyTo(targetRow);
});
}
}