diff --git a/src/ImageSharp/Image/ImageFrame.LoadPixelData.cs b/src/ImageSharp/Image/ImageFrame.LoadPixelData.cs
index 153a757e1..b9341a1b2 100644
--- a/src/ImageSharp/Image/ImageFrame.LoadPixelData.cs
+++ b/src/ImageSharp/Image/ImageFrame.LoadPixelData.cs
@@ -20,30 +20,32 @@ namespace SixLabors.ImageSharp
///
/// Create a new instance of the class from the given byte array in format.
///
+ /// The memory manager to use for allocations
/// The byte array containing image data.
/// The width of the final image.
/// The height of the final image.
/// The pixel format.
/// A new .
- public static ImageFrame LoadPixelData(Span data, int width, int height)
+ public static ImageFrame LoadPixelData(MemoryManager memoryManager, Span data, int width, int height)
where TPixel : struct, IPixel
- => LoadPixelData(data.NonPortableCast(), width, height);
+ => LoadPixelData(memoryManager, data.NonPortableCast(), width, height);
///
/// Create a new instance of the class from the raw data.
///
+ /// The memory manager to use for allocations
/// The Span containing the image Pixel data.
/// The width of the final image.
/// The height of the final image.
/// The pixel format.
/// A new .
- public static ImageFrame LoadPixelData(Span data, int width, int height)
+ public static ImageFrame LoadPixelData(MemoryManager memoryManager, Span data, int width, int height)
where TPixel : struct, IPixel
{
int count = width * height;
Guard.MustBeGreaterThanOrEqualTo(data.Length, count, nameof(data));
- var image = new ImageFrame(Configuration.Default.MemoryManager, width, height);
+ var image = new ImageFrame(memoryManager, width, height);
SpanHelper.Copy(data, image.GetPixelSpan(), count);
return image;
diff --git a/src/ImageSharp/Image/ImageFrameCollection.cs b/src/ImageSharp/Image/ImageFrameCollection.cs
index bfdf1df76..aefeacce1 100644
--- a/src/ImageSharp/Image/ImageFrameCollection.cs
+++ b/src/ImageSharp/Image/ImageFrameCollection.cs
@@ -80,7 +80,11 @@ namespace SixLabors.ImageSharp
///
public ImageFrame AddFrame(TPixel[] data)
{
- var frame = ImageFrame.LoadPixelData(new Span(data), this.RootFrame.Width, this.RootFrame.Height);
+ var frame = ImageFrame.LoadPixelData(
+ this.parent.GetMemoryManager(),
+ new Span(data),
+ this.RootFrame.Width,
+ this.RootFrame.Height);
this.frames.Add(frame);
return frame;
}
diff --git a/src/ImageSharp/Memory/Buffer2D{T}.cs b/src/ImageSharp/Memory/Buffer2D{T}.cs
index d9e645845..7f9fb59c4 100644
--- a/src/ImageSharp/Memory/Buffer2D{T}.cs
+++ b/src/ImageSharp/Memory/Buffer2D{T}.cs
@@ -34,8 +34,14 @@ namespace SixLabors.ImageSharp.Memory
///
public int Height { get; private set; }
+ ///
+ /// Gets the span to the whole area.
+ ///
public Span Span => this.Buffer.Span;
+ ///
+ /// Gets the backing
+ ///
public IBuffer Buffer { get; private set; }
///
@@ -56,11 +62,20 @@ namespace SixLabors.ImageSharp.Memory
}
}
+ ///
+ /// Disposes the instance
+ ///
public void Dispose()
{
this.Buffer?.Dispose();
}
+ ///
+ /// Swap the contents (, , ) of the two buffers.
+ /// Useful to transfer the contents of a temporal to a persistent
+ ///
+ /// The first buffer
+ /// The second buffer
public static void SwapContents(Buffer2D a, Buffer2D b)
{
Size aSize = a.Size();