ImageGear for C and C++ on Windows v20.0 - Updated
LPFNIG_GUIPALETTE
API Reference Guide > Core Component API Reference > Core Component Callback Functions Reference > LPFNIG_GUIPALETTE

This function is called any time the user has attempted to change a palette color in the palette window.

Declaration:

 
Copy Code
typedef BOOL (ACCUAPI LPFNIG_GUIPALETTE) (
        LPVOID lpPrivate, 
        UINT nPaletteIndex, 
        LPAT_RGBQUAD lpRGB 
);

Arguments:

Name Type Description
lpPrivate LPVOID Far pointer to private data area.
nPaletteIndex UINT Index of palette entry that changed.
lpRGB LPAT_RGBQUAD Far pointer to the entry.

Return Value:

Return TRUE to modify the DIB palette; FALSE to make no changes.

Supported Raster Image Formats:

Indexed RGB - 1…8 bpp.

Sample:

Palette Edit

Example:

 
Copy Code
BOOL ACCUAPI  MyPaletteCBFunc ( LPVOID lpPrivate, UINT nEntryNum, LPAT_RGBQUAD
lpRBGQ_PaletteEntry )
{
INT     r, g, b;           /* will hold the palette colors */
                                /* Don't let the user change color 0:   */
if ( nEntryNum == 0 )
        { return  FALSE; }  /* Don't store or display the new color  */
/* If the color is too dark, don't accept it: */
r  =  lpRGBQ_PaletteEntry -> rgbRed;
g  =  lpRGBQ_PaletteEntry -> rgbGreen;
b  =  lpRGBQ_PaletteEntry -> rgbBlue;
if ( (r<20) || (g<20) || (b<20) )
        { return  FALSE; }    /* Too dark, say "Don't store it"   */
return  TRUE;           /* Else OK, store and display new color  */
}

See also the example under function IG_GUI_palette_CB_register().

Remarks:

This type of callback function is registered by calling IG_GUI_palette_CB_register().

You may perform any operations you wish here, but you should also return TRUE to tell ImageGear to go ahead with the change and actually modify the DIB palette, FALSE to tell ImageGear to deny the change.

If you have not registered a palette callback function, ImageGear will make each change the user attempts.

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