ImageGear for C and C++ on Windows v19.5 - Updated
IG_image_DIB_palette_pntr_get
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Image DIB Functions > IG_image_DIB_palette_pntr_get

This function returns the address of the image's DIB palette.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_image_DIB_palette_pntr_get(
   HIGEAR hIGear,
   LPAT_RGBQUAD FAR* lpRGBQ,
   LPUINT lpEntries
);

Arguments:

Name Type Description
hIGear HIGEAR HIGEAR handle of image.
lpRGBQ LPAT_RGBQUAD FAR* Pointer to a variable of type LPAT_RGBQUAD, in which this function will store the address of the start of the image's DIB palette.
lpEntries LPUINT Pointer to a variable in which will be returned the number of entries in the palette.

Return Value:

Returns 0 if successful. Otherwise, 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++.

Sample:

Image Processing, Palette Editor

Example:

 
Copy Code
AT_ERRCOUNT nErrcount;  // Number of errors on stack
HIGEAR hIGear;          // Handle of image
LPAT_RGBQUAD palette = NULL; // Palette pointer
UINT entries = 0;            // Number of entries in the palette

// Load image file "picture.bmp" from working directory
nErrcount = IG_load_file("picture.bmp", &hIGear);
if(nErrcount == 0)
{
    nErrcount = IG_image_DIB_palette_pntr_get(hIGear, &palette, &entries);
    // ...
    // Destroy the image
    IG_image_delete(hIGear);
}

Remarks:

HIGEAR DIB palette is stored as an array of AT_RGBQUAD structs. This function returns the address of the first AT_RGBQUAD struct in this array.

If the image doesn't have a palette, the function returns NULL in lpRGBQ.

When referencing a DIB palette, remember that each DIB palette entry contains 4 bytes, not 3, and that the order of the bytes is: Blue, Green, Red, Unused (not Red, Green, Blue).