ImageGear for C and C++ on Windows v19.7 - Updated
Reading and Writing Palettes
User Guide > How to Work with... > Common Operations > Manipulating Image Data > Work with Image Utility Functions > Reading and Writing Palettes

There are six image utility functions that read and write palettes in memory, or load and save them between memory and disk. To transfer a palette between your own memory area and a HIGEAR image's DIB (that is, to get or set the DIB palette), use IG_palette_get and IG_palette_set:

 
Copy Code
AT_RGBQUAD palette[256];

IG_palette_get ( hIGear, palette );

IG_palette_set ( hIGear, palette );

In the above calls, lpPalette should point to the first of an array of AT_RGBQUAD structures, one structure per palette entry.

If instead you want to move just one entry to or from the DIB palette, use IG_palette_entry_get and IG_palette_entry_set:

 
Copy Code
AT_RGB    rgbPaletteColor;

IG_palette_entry_get ( hIGear, &rgbPaletteColor, nIndex );

IG_palette_entry_set ( hIGear, &rgbPaletteColor, nIndex );

In the single entry calls, you supply a pointer to a single structure of type AT_RGB. The third argument has a value between 0 and 255, specifying which palette entry to get or set. (Remember that an AT_RGBQUAD structure consists of 4 bytes ordered Blue-Green-Red-Unused(0), while an AT_RGB struct consists of 3 bytes ordered Blue-Green-Red.)

To load and save palettes between memory and disk, use the functions IG_palette_load and IG_palette_save:

 
Copy Code
IG_palette_load ("filename", palette, nEntries, bOrder, lpFileType);

IG_palette_save ("filename", palette, nEntries, lpFileType);

See the descriptions of the above functions in Core Component API Reference for details on specifying the arguments.