byte[] buffer;
using (var image = new HeifImage("MyImage.heic"))
using (var primary = image.PrimaryImage())
{
buffer = primary.ToArray();
}
// do something with buffer
Usage - AsStream
Stream stream;
using (var image = new Heifimage("MyImage.heic"))
using (var primary = image.PrimaryImage())
{
stream = primary.AsStream();
}
// do something with stream
// don't forget to dispose of your stream
stream?.Dispose();
Usage - AsReadOnlySpan
This one is a little tricky as Span<T> gives us access to native memory. If we allow C# to operate on native memory we should ensure it happens within the IDisposable using block otherwise there will be a memory leak.
ReadOnlySpan<byte> span;
using (var image = new HeifImage("MyImage.heic"))
using (var primary = image.PrimaryImage())
{
ReadOnlySpan<byte> span = primary.AsReadOnlySpan();
// do something with span
}
Description
Add memory buffer APIs that can return an array or a stream
New APIs
Usage - ToArray()
Usage - AsStream
Usage - AsReadOnlySpan
This one is a little tricky as
Span<T>
gives us access to native memory. If we allow C# to operate on native memory we should ensure it happens within theIDisposable
using block otherwise there will be a memory leak.