ImageGear for C and C++ on Linux v18.8 - Updated
IG_IP_color_reduce_diffuse
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Image Processing Functions > IG_IP_color_reduce_diffuse

This function reduces the image to a fewer number of Bits Per Pixel.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_IP_color_reduce_diffuse ( 
        HIGEAR hIGear, 
        UINT nToBits, 
        INT level, 
        LPAT_RGBQUAD lpPalette 
);

Arguments:

Name Type Description
hIGear HIGEAR HIGEAR handle of image of which to reduce bit depth.
nToBits UINT Number of bits per pixel after reduction, 1 or 4.
Level INT Threshold value for dithering, 0 to 255. Has effect only if nToBits = 1.
lpPalette LPAT_RGBQUAD This argument is currently not used.

Return Value:

Returns the number of ImageGear errors that occurred during this function call.

Supported Raster Image Formats:

Indexed RGB – 4, 8 bpp;
Grayscale – 4, 8 bpp;
RGB – 24 bpp.

Example:

 
Copy Code
HIGEAR hIGear;   /* HIGEAR handle of 4, 8, or 24 bit image */
/* Reduce image to 1-bit black-and-white: */
IG_IP_color_reduce_diffuse ( hIGear, 1, 128, NULL );

Remarks:

The target bit depth is specified by argument nToBits. In general, a color image will be reduced to a fewer number of colors, and a grayscale image will be reduced to a fewer number of shades of gray. Note that setting nToBits = 1 will reduce the image to monochrome or black-and-white.

When reducing the image to monochrome (black-and-white), the level parameter sets a threshold value for the target image:

The input number of Bits Per Pixel must be greater than nToBits, or an error will result.

See also section in entitled Color Reduction.