Memory Allocation
An image can be constructed with an internal or external memory allocation.
Internal memory allocation
The image object dynamically allocates and deallocates a buffer.
|
□
|
Memory management is transparent. |
|
□
|
When the image size changes, reallocation occurs. |
|
□
|
When an image object is destroyed, the buffer is deallocated. |
To declare an image with internal memory allocation:
|
a.
|
Construct an image object, for instance EImageBW8, either with width and height arguments, OR using the SetSize function. |
|
b.
|
Access a given pixel. There are several functions that do this. GetImagePtr returns a pointer to the first byte of the pixel at the given coordinates. |
External memory allocation
The user controls buffer allocation or links a third-party image in the memory buffer to an Open eVision image.
|
□
|
Image size and buffer address must be specified. |
|
□
|
When an image object is destroyed, the buffer is unaffected. |
To declare an image with external memory allocation:
|
a.
|
Declare an image object, for instance EImageBW8. |
|
b.
|
Create a suitably sized and aligned buffer (see Image Buffer). |
If your buffer rows are not aligned on 4 bytes, you cannot use SetImagePtr. In that case, use InitializeFromUnalignedBuffer instead.
Please note, however, that this allocates the memory internally and copies the external buffer into the internal one instead of using the external one directly.