Skip to content
Discussion options

You must be logged in to vote

There’s actually an example at the docs link.


Configuration customConfig = Configuration.Default.Clone();
customConfig.PreferContiguousImageBuffers = true;

using (Image<Rgba32> image = new(customConfig, 4096, 4096))
{
    if (!image.DangerousTryGetSinglePixelMemory(out Memory<Rgba32> memory))
    {
        throw new Exception(
            "This can only happen with multi-GB images or when PreferContiguousImageBuffers is not set to true.");
    }

    using (MemoryHandle pinHandle = memory.Pin())
    {
        void* ptr = pinHandle.Pointer;

        // You can now pass 'ptr' to native API-s.
        // Make sure to keep 'pinHandle', and 'image' alive while native resource work with the p…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@DrkWzrd
Comment options

@JimBobSquarePants
Comment options

Answer selected by JimBobSquarePants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants