Description

Get a block of pixel values from the image

Return Type

A Long value.  

The number of values returned in the array. Should be (right - left + 1)*(bottom - top + 1)*image.NumberOfChannels.

Syntax

object.GetArea (pvArea, [lLeft], [lTop], [lRight], [lBottom], [Frame])

The GetArea Method syntax has these parts:

PartDescription
objectAn expression evaluating to an object of type McImage.
pvAreaRequired. A Variant value.

A pointer to a VARIANT receiving the pixel values. If the VARIANT is empty, the function will return one containing a two-dimensional SAFEARRAY (for one channel per pixel) or a three-dimensional SAFEARRAY (for multiple channels per pixel). If a 2-D array is created, it will be shaped as vLine(0 to lWidth-1, 0 to lHeight-1) for VB arrays and as vLine[lHeight][lWidth] for C/C++/Java arrays. If a 2-D array is created, it will be shaped as vLine(0 to nChannels-1, 0 to lWidth-1, 0 to lHeight-1) for VB arrays and as vLine[lHeight][lWidth][nChannels] for C/C++/Java arrays.

The number of values contained in the SAFEARRAY is equal to the height times the width times the number of channels (3 for color images). For

color images, red, green, and blue values are interlaced.

left

Optional. Left side of the area. Must be between 0 and image.width-1. The default value of -1 is the same as 0.

top

Optional. Top side of the area. Must be between 0 and image.height-1. The default value of -1 is the same as 0.

right

Optional. Right side of the area. Must be between 0 and image.width-1. The default value of -1 is the same as image.width-1

bottom

Optional. Bottom side of the area. Must be between 0 and image.height-1. The default value of -1 is the same as image.height-1

lLeftOptional. A Long value.
lTopOptional. A Long value.
lRightOptional. A Long value.
lBottomOptional. A Long value.
FrameOptional. A Long value.

Optional. 0-based frame number, McActiveFrame, McLastFrame. Default = McActiveFrame.

Remarks

See CreateRegionAccess for a more controlled way to get pixel values.

When the routine itself creates the array it is typed after the image type, which guarantees that the pixel values will fit into the array. If pvArea already contains an array it must be of the right data type and size.

For languages that do not support the unsigned integer type (like Visual Basic or VBA), 16 bits values bigger than 32767 will be reported as negative because their sign bit is set. The best way to work around this limitation is to create a “long” McRegionAccess using CreateRegionAccess and call its own version of GetArea, which will then return long positive values (4 bytes) instead of unsigned integers (2 bytes).

Notes

Avoid using GetArea followed by PutArea to copy large image frames. This causes the entire image frame being copied to need to reside in memory. Instead use the McRegionAccess.CopyInEntireArea method. Or set up your own per line loop and use GetLine followed by PutLine (you will need to call BeginEndUpdateBlock(TRUE/FALSE) around such a loop to avoid excessive image updating).