to8bit
Top  Previous  Next

to8bit ( integer Input, integer Output, integer Colors, integer Mode=0 )

Use this function to convert an image or selection into a 256-color bitmap. The function uses the quantization algorithm that reduces the number of colors by mapping the original image to an 8-bit palettized color image.

Parameters
 
Input  
 
An integer between 0 and 116 specifying the input 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.  
 
Output  
 
An integer between 1 and 116 specifying the output image frame number. Values in the range of 100-116 correspond to hidden frames.  
 
Colors  
 
An integer between 1 and 255 specifying the number of colors to be included in the output image color palette.  
 
Mode  
 
An optional enumerated integer that describes the color quantization mode to use. Must be one of the following values:  
 
CQ_MEDIAN=0 - fast mode based on the median-cut method that searches for clusters of colors in the RGB coordinate space. If the input image is a pseudo-colored gray one, this mode will convert the image into an 8-bit colored image preserving the display palette. This feature can be used to export pseudo-colored images to other programs.  
CQ_OCTAL=1 - octal tree mode based on more precise method of color reduction that uses the tree of colors. The algorithms treats colors in the images as leaves on a tree and trims "smaller branches" until the number of "leaves" becomes less or equal to Colors.  
CQ_HALFTONE=2halftone mode that creates a dithered output image using 256 colors from the standard halftone palette. The colors in the halftone palette are evenly distributed throughout RGB coordinate space.  
Note that the Colors parameter has no effect in this mode as the output image palette will always contain 256 colors.  
Default value: CQ_MEDIAN  
 
Error flags

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

Example

grabIm (1)  
to8bit (1,2,256,CQ_OCTAL)  
saveIm (2,"C:\\test8.tif")