getPixel
Top  Previous  Next

val = getPixel ( integer Image, integer X, integer Y[ , floating& R, floating& G =R, floating& B =R ] )

Use this function to retrieve the value of a pixel in an image.

Parameters
 
Image  
 
An integer between 1 and 116 specifying the image frame number. A value of 0 represents the DMA memory buffer of the video device. Values in the range of 100-116 correspond to hidden frames.  
 
X, Y  
 
Positive integers specifying the coordinates of the pixel in the image (the column and row numbers starting from zero).  
 
R  
 
An optional floating variable that returns the value of the pixel or its first component. Depending on the type of the image, the value must be interpreted differently:  
 
Grayscale (8, 16, 32 bpp) or floating image
the intensity of the pixel
Palettized or multiphase image
the index in the image palette
RGB (16, 24, 32, 48 bpp) image
the red component of the pixel
Complex image
the first component of the pixel
 
 
G  
 
An optional floating that returns the green component of the pixel for an image of an RGB type, or a second component of the pixel for an image of the complex type. For any other image type this argument will return zero.  
 
B  
 
An optional integer specifying the blue component of the pixel for an image of an RGB type. For any other image type this argument will return zero.  
 
Return value

The value of the pixel or its first component. Depending on the type of the image, the value must be interpreted differently. See the table above for details.  
 
Error flags

ERR_OK  
 
The flag set if successful.  
 
ERR_FAILED  
 
The flag set if failed.  
 
Example

The following set of statements retrieves a pixel value from two sample images of the RGB and 16-bit grayscale type.  
 
setCurDir("samples")  
loadIm (1,"sample10.iwd")  
loadIm (2,"sample26.iwd")  
getPixel(1,100,100,r,g,b)  
v=getPixel(2,300,300)  
print "pixel 1: (",r,",",g,",",b,")"  
print "pixel 2: ",v