ImageGear for C and C++ on Windows v19.6 - Updated
IG_image_channel_depths_change
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Image Channel Functions > IG_image_channel_depths_change

This function changes the bit depths of the image channels to the specified depths.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_image_channel_depths_change(
        HIGEAR hIGear,
        const AT_INT* newDepths,
        AT_MODE scaleMode
);

Arguments:

Name Type Description
hIGear HIGEAR HIGEAR handle of image.
newDepths const AT_INT* New channel depths to set.
scaleMode AT_MODE Mode to use for scaling channel depths - must be one of the following: IG_DEPTH_CHANGE_SCALE or IG_DEPTH_CHANGE_NO_SCALE.

Return Value:

Returns the number of ImageGear errors that occurred during this function call. If there are no errors, the return value is IGE_SUCCESS.

Supported Raster Image Formats:

All pixel formats supported by ImageGear for C and C++.

Sample:

None

Example:

 
Copy Code
/* Alter a 24-bit RGB image to have full 8-bit precision 
   for green, but only 1-bit precision for red and blue */
AT_ERRCOUNT nErrcount;  /* Number of errors on stack */
HIGEAR hImage;          /* HIGEAR handle of image */
AT_INT depths[] = { 1, 8, 1 }; /* New channel depths */
nErrcount = IG_load_file("test.jpg", &hImage);
nErrcount = IG_image_channel_depths_change(hImage, depths,
    IG_DEPTH_CHANGE_SCALE);
nErrcount = IG_save_file(hImage, "test.bmp", 
    IG_SAVE_BMP_UNCOMP);
nErrcount = IG_image_delete(hImage);

Remarks:

If scaling is used, pixel data is scaled to match the new bit depths. Otherwise, pixel data will remain unchanged and will be interpreted as conforming to the new depths.