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

This function loads the palette pointed to by lpPalette into the DIB, replacing the prior palette that was present.


Copy Code
        HIGEAR hIGear, 
        const LPAT_RGBQUAD lpPalette


Name Type Description
HIGEAR HIGEAR HIGEAR handle of image.
LpPalette const LPAT_RGBQUAD Far pointer to the first of an array of AT_RGBQUAD structs containing the palette you wish to load into the DIB, as the image's new DIB palette.

Return Value:

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

Supported Raster Image Formats:

Indexed RGB - 1…8 bpp.


Copy Code
HIGEAR hIGear;        /* HIGEAR handle of image  */
AT_ERRCOUNT  nErrcount;     /* Returned count of errors on stack */
AT_RGBQUAD rgbqPalette[256];   /* Array of AT_RGBQUAD structs  */
INT pix;              /* Loop index, = pixel value  */
/* Create a grayscale palette, and set it into image hIGear's DIB:  */
for ( pix = 0;  pix <= 255;  pix++ )
        rgbqPalette[pix].rgbBlue  =  pix;
        rgbqPalette[pix].rgbGreen =  pix;
        rgbqPalette[pix].rgbRed   =  pix;
        rgbqPalette[pix].rgbReserved  =  0;
nErrcount = IG_palette_set ( hIGear, rgbqPalette );


Your palette pointed to by lpPalette must be in the form of AT_RGBQUAD structs: 4 bytes per entry, ordered Blue-Green-Red-Unused (0). The number of consecutive AT_RGBQUAD structs you need is determined by the number of Bits Per Pixel in the image. For example, for an 8 bit image, you would need an array of 256 AT_RGBQUAD structs.

If the image is 24 bit, this function will set an error and return.

See also function IG_palette_set().

Is this page helpful?
Yes No
Thanks for your feedback.