📷 A modern, cross-platform, 2D Graphics library for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

50 lines
1.2 KiB

using System;
using System.Buffers;
namespace SixLabors.ImageSharp.Tests
{
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
class TestMemoryManager<T> : MemoryManager<T>
where T : struct, IPixel<T>
{
public TestMemoryManager(T[] pixelArray)
{
this.PixelArray = pixelArray;
}
public T[] PixelArray { get; }
protected override void Dispose(bool disposing)
{
}
public override Span<T> GetSpan()
{
return this.PixelArray;
}
public override MemoryHandle Pin(int elementIndex = 0)
{
throw new NotImplementedException();
}
public override void Unpin()
{
throw new NotImplementedException();
}
public static TestMemoryManager<T> CreateAsCopyOfPixelData(Span<T> pixelData)
{
var pixelArray = new T[pixelData.Length];
pixelData.CopyTo(pixelArray);
return new TestMemoryManager<T>(pixelArray);
}
public static TestMemoryManager<T> CreateAsCopyOfPixelData(Image<T> image)
{
return CreateAsCopyOfPixelData(image.GetPixelSpan());
}
}
}