Description

Read a single pixel from an image.

Return Type

A Long value.  
long

the number of

values returned in pvPixel: One value per channel in the McRegionAccess.
The number channels in the McRegionAccess is determined by the channel
argument of McImage.CreateRegionAccess as well as the McImageType.

Syntax

object.GetPixel (pvPixel, x, y)

The GetPixel Method syntax has these parts:

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

VARIANT* : 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 type passed to McImage.CreateRegionAccess. For an McRegionAccess with more than one channel, pvPixel will contain a SAFEARRAY containing one value per channels. For single channel McRegionAccess, pvPixel will contain a single numerical value.

xRequired. A Long value.

long : The x-location of the pixel.

yRequired. A Long value.

long : The y-location of the pixel.

Remarks

The x and y coordinates are relative to the McRegionAccess ROI, not the image. The pixel values returned are in the requested color model, which may differ from the image's native color model.

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 use a “long” McRegionAccess, which will then return long positive values (4 bytes) instead of unsigned integers (2 bytes).