NativeMemoryRef Class

Definition

Namespace: P1.ImageSdk

A wrapper around a temporary reference to an block of unmanaged memory More…

public class NativeMemoryRef :  Stream

Remarks

A wrapper around a temporary reference to an block of unmanaged memory

This object references memory owned by the SDK subsystem, so you must Dispose() it as soon as you are done with it. Either manually call Dispose() or use a

using

block to ensure quick disposal of the referenced memory. (Do not rely on the garbage collector to eventually free the object.

Since the lower layers of this ImageSDK are written in C/C++, (large) images can be returned to CLR contexts as a reference to unmanaged memory. This allows you to avoid extranous copies of the image data.

This class implements the Stream abstract class, so you can easily stream its content to a file or other destination stream.

The method ToArray copies the entire data buffer into a byte array (

byte[]

). This effectively transfers (copies) the data from unmanaged memory into managed.