ImageGear for C and C++ on Windows v19.5 - Updated
IG_IP_convert_to_gray
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.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_IP_convert_to_gray( HIGEAR hIGear);

Arguments:

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

Sample:

Color, Image Processing, FlashPix, FreqIP, Color

Example:

 
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
    IG_image_delete(hIGear);
}

Remarks:

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.