#if NET6_0_OR_GREATER using System; namespace NetVips; /// /// An input connection. /// public partial class Source { /// /// Make a new source from a memory object. /// /// /// Make a new source that is attached to the memory object. For example: /// /// using var source = Source.NewFromMemory(data); /// /// You can pass this source to (for example) . /// /// The memory object. /// A new . /// If unable to create a new from . public static unsafe Source NewFromMemory(ReadOnlySpan data) { fixed (byte* dataFixed = data) { var ptr = Internal.VipsBlob.Copy(dataFixed, (nuint)data.Length); if (ptr == IntPtr.Zero) { throw new VipsException("can't create input source from memory"); } using var blob = new VipsBlob(ptr); var pointer = Internal.VipsSource.NewFromBlob(blob); if (pointer == IntPtr.Zero) { throw new VipsException("can't create input source from memory"); } return new Source(pointer); } } } #endif