net-vips
net-vips copied to clipboard
Add support for ReadOnlyMemory<> and ReadOnlySpan<> objects
Hello,
When creating a new image from memory, it is not possible to pass a ReadOnlyMemory<>
or a ReadOnlySpan<>
.
We must manually pin the data and convert that to a pointer before calling the IntPtr
overload of Image.NewFromMemory
.
Can you add an overload of Image.NewFromMemory
that directly take a ReadOnlyMemory<>
?
And an overload of Image.NewFromMemoryCopy
that takes a ReadOnlySpan<>
?
Thanks! :)
ReadOnlyMemory<>
and ReadOnlySpan<>
are only compatible with .NET Standard 2.1 and later versions. Currently, NetVips targets .NET Standard 2.0 as its minimum requirement.
To use this, we either need to upgrade our minimum requirement to .NET Standard 2.1 or discontinue support for .NET Standard 2.0 and Mono (see e.g. commit 49c4a1528981afa67815ade01ffa3ff94da982b6). I'm inclined to favor the latter option, though it might be a bit premature at this time.
Commit d5243b5e409666c5970b0380aff762111d500fc2 (based on top of 49c4a1528981afa67815ade01ffa3ff94da982b6) adds support for this. If you want to test this, you can use the nightly version of NetVips. Add the https://ci.appveyor.com/nuget/net-vips
feed in the <packageSources>
section of your NuGet.config
:
<packageSources>
<add key="netvips-nightly" value="https://ci.appveyor.com/nuget/net-vips" />
</packageSources>
And update NetVips to 2.4.0 (build number 506 - prerelease).