ImageGear for C and C++ on Linux v20.0 - Updated
API Reference Guide > Core Component API Reference > Core Component Functions Reference > FX Functions > IG_FX_posterize

Posterize reduces the number of actual colors in the image by creating a "stair case" in the palette.


Copy Code
        HIGEAR hIGear, 
        const LPAT_RECT lpRect, 
        const WORD nLevels, 
        const AT_MODE nColorChannel 


Name Type Description
hIGear HIGEAR HIGEAR handle of image.
lpRect const LPAT_RECT Far pointer to an AT_RECT struct specifying a rectangular portion of the image to be processed. NULL for whole image. Before ImageGear performs this operation, it will check to see if an internal flag has been set to TRUE to make a mask active for this HIGEAR image. If a mask is active, and a valid pointer to a mask can be found, ImageGear will override the settings passed to this structure in favor of the non-rectangular ROI defined by the mask.
nLevels const WORD Number of unique colors or levels wanted in the resulting image. Valid range: 1-255.
nColorChannel const AT_MODE IG_COLOR_COMP_RGB, or use IG_COLOR_COMP_R, _B, or _G to affect only one color channel.

Return Value:

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

Supported Raster Image Formats:

All pixel formats supported by ImageGear for C and C++, except:
Indexed RGB with non-grayscale palette.
Images that have a Grayscale LUT attached to them.

The function does not have any effect on 1 bpp images.


Copy Code
HIGEAR hIGear;       /* HIGEAR handle of image  */
/* Use only 50 colors, regardless of how many unique pixel values:  */
IG_FX_posterize ( hIGear, NULL, 50, IG_COLOR_COMP_RGB );


The number of steps wanted is specified by nLevels, in the range 1 to 255. nLevels = 255 would cause no effect while nLevels = 20 would cause 20 equally spaced steps to be created.

This function, like other ImageGear Image Processing and Clipboard API calls, takes an AT_RECT structure as an argument, so that you can process a rectangular sub-region of an image. However, before ImageGear performs the operation specified by this function, it will check to see if an internal flag has been set to TRUE, indicating that a mask HIGEAR should be used with the image. If the flag is set to TRUE, and a valid pointer to a mask image has been assigned, ImageGear will override the settings passed to the AT_RECT structure and use the non-rectangular ROI defined by the mask HIGEAR. To create a non-rectangular region of interest, call IG_IP_NR_ROI_to_HIGEAR_mask().

Please see the descriptions of IG_IP_NR_ROI_mask_associate() and IG_IP_NR_ROI_to_HIGEAR_mask() for more details.
Is this page helpful?
Yes No
Thanks for your feedback.