setPixel
Top  Previous  Next

setPixel (integer Image, integer X, integer Y, floating R
[, integer G =R, integer B =R, integer Opacity =100 ] )  

Use this function to set the value of a pixel in an image. If you apply this function repeatedly, it is recommended to disable the screen update of the image before calling the drawing section of your script and enable the update afterwards. This will allow for significant speed increase. See updateIm for more details.

Parameters
 
Image  
 
An integer between 1 and 116 specifying the image frame number. 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  
 
A floating variable or constant specifying the value of the pixel or its first component. Depending on the type of the image, this parameter will 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 active component of the pixel
   
 
G  
 
An optional integer specifying the green component of the pixel for an image of an RGB type. For any other image type this parameter is disregarded.  
Default value: same as R  
 
B  
 
An optional integer specifying the blue component of the pixel for an image of an RGB type. For any other image type this parameter is disregarded.  
Default value: same as R  
 
Opacity  
 
An optional integer between 0 and 100 specifying the percentage of opacity at which the new value of the pixel will be blended with the old one.  
Default value: 100  
 
Error flags

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

The following set of statements creates a blank RGB image and sets the central pixel to the color yellow:  
 
createIm (1, IM_RGB, 256, 256)  
setPixel (1,128,128, 255, 255, 0)  
updateIm(TRUE)