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

This function converts the image referenced by hIGear to a grayscale image.


Copy Code
AT_ERRCOUNT ACCUAPI IG_IP_convert_to_gray( HIGEAR hIGear);


Name Type Description
hIGear HIGEAR HIGEAR handle of image.

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
HIGEAR hIGear;            // HIGEAR handle of the image
AT_ERRCOUNT nErrcount;    // Count of errs on stack upon ret from func

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


The function changes image color space to IG_COLOR_SPACE_ID_Gy. The bit depth of the resulting image will be equal to the maximal channel depth of the source image. If the original image has an Alpha or Pre-multiplied Alpha channel, the image will be blended over a black background to produce the resulting image. If the original image has Extra channels, they will be removed.

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