Memory Allocation

You can construct an image using an internal or an external memory allocation.

Internal memory allocation

The image object dynamically allocates and deallocates a buffer:

The memory management is transparent.
When the image size changes, a reallocation occurs.
When an image object is destroyed, the buffer is deallocated.

To declare an image with an internal memory allocation:

1. Construct an image object, for instance EImageBW8, either with width and height arguments or using the SetSize function.
2. Access a given pixel using one of the multiple available functions.
For example, use GetImagePtr to retrieve a pointer to the first byte of the pixel at the given coordinates.

External memory allocation

Control the buffer allocation or link a third-party image in the memory buffer to an Open eVision image.

You must specify the image size and the buffer address.
When an image object is destroyed, the buffer is unaffected.
2 For details, see Image and Depth Map Buffer and Interfacing Third-Party Images.

To declare an image with an external memory allocation:

1. Declare an image object, for instance EImageBW8.
2. Create a suitably sized and aligned buffer.
3. Assign the buffer to the image with SetImagePtr.

If your buffer rows are not aligned on 4 bytes, use InitializeFromUnalignedBuffer instead of SetImagePtr.
Please note that this allocates the memory internally and copies the external buffer into the internal one instead of using the external one.