Description

Get a pixel value.

Return Type

A Long value.  

One value returned per channel (1 for gray scale images, 3 for color images).

Syntax

object.GetPixel (pvPixel, x, y, [Frame])

The GetPixel Method syntax has these parts:

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

A pointer to a VARIANT receiving the pixel value. If the VARIANT is empty, the function will return one of a type compatible with the image type.

xRequired. A Long value.

The x-location of the pixel. 0 indicates a pixel along the edge of the image.

yRequired. A Long value.

The y-location of the pixel. 0 indicates a pixel along the first line of the image.

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 variant it is typed after the image type, which guarantees that the pixel values will fit into it. If pvPixel is already typed, 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 McImage.CreateRegionAccess and call its own version of GetPixel, which will then return long positive values (4 bytes) instead of unsigned integers (2 bytes).