ImageGear for C and C++ on Linux v20.0 - Updated
API Reference Guide > Core Component API Reference > Core Component Functions Reference > General Image Functions > IG_image_is_gray

This function is called to determine if an image is a grayscale image.


Copy Code
       HIGEAR hIGear,
       LPAT_BOOL lpIsImageGray


Name Type Description
hIGear HIGEAR HIGEAR handle of image.
lpIsImageGray LPAT_BOOL Pointer to a variable which will be overwritten with TRUE if the image is grayscale, and with FALSE if it is not grayscale.

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++.


Copy Code
AT_ERRCOUNT nErrcount;  // Number of errors on stack
HIGEAR hIGear;          // Handle of image
AT_BOOL bItsGray;        // Will be set = TRUE if grayscale

// Load image file "picture.bmp" from working directory
nErrcount = IG_load_file("picture.bmp", &hIGear);
if(nErrcount == 0)
    nErrcount = IG_image_is_gray(hIGear, &bItsGray);
    // ...
    // Destroy the image


The function considers the image to be grayscale, if either of the following is true:

FALSE is returned for all 1-bit indexed images, even if the palette contains two shades of gray.

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