This function is called to determine if an image is a grayscale image.
Declaration:
Copy Code | |
---|---|
AT_ERRCOUNT ACCUAPI IG_image_is_gray( HIGEAR hIGear, LPAT_BOOL lpIsImageGray ); |
Arguments:
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 Professional.
Sample:
Medical, Timing, FlashPix
Example:
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 IG_image_delete(hIGear); } |
Remarks:
The function considers the image to be grayscale, if either of the following is true:
- Image has IG_COLOR_SPACE_ID_Gy (grayscale) colorspace.
- Image has IG_COLOR_SPACE_ID_I (indexed) colorspace, has more than 1 bit per pixel, all of its palette entries are grayscale (R[i] = G[i] = B[i]), and the palette is either non-decreasing (R[i] >= R[i-1] for all i>0) or non-increasing (R[i] <= R[i-1] for all i>0).
- Image has IG_COLOR_SPACE_ID_RGB colorspace, and all image pixels are grayscale: R = G = B.
- Color channels of the image satisfy one of the requirements listed above, and the image also has Alpha, Premultiplied Alpha or Extra channels.
FALSE is returned for all 1-bit indexed images, even if the palette contains two shades of gray. |