ImageGear for C and C++ on Linux v18.10 - Updated
IG_image_channel_update
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Image Channel Functions > IG_image_channel_update

This function copies pixel data from one channel to another channel.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_image_channel_update(
        LPCAT_CHANNEL_REF channelToUpdateWith,
        LPCAT_CHANNEL_REF channelToBeUpdated
);

Arguments:

Name Type Description
channelToUpdateWith LPCAT_CHANNEL_REF Channel to use as source channel.
channelToBeUpdated LPCAT_CHANNEL_REF Channel to be replaced by source channel.

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

Example:

 
Copy Code
/* Alter a 24-bit RGB image to use the red channel data 
for both red and blue channels */
AT_ERRCOUNT nErrcount;  /* Number of errors on stack */
HIGEAR hImage;          /* Handle of source image */
AT_CHANNEL_REF chanSrc; /* Channel to update from */
AT_CHANNEL_REF chanDst; /* Channel to update */
nErrcount = IG_load_file("test.jpg", &hImage);
chanSrc.hImage = hImage;
chanSrc.uNumber = 0;
chanDst.hImage = hImage;
chanDst.uNumber = 2;
nErrcount = IG_image_channel_update(&chanSrc, &chanDst);
nErrcount = IG_save_file(hImage, "test.bmp", 
    IG_SAVE_BMP_UNCOMP);
IG_image_delete(hImage);

Remarks:

Each channel is specified by a HIGEAR image handle and the channel's index within that image. The source and destination channels can reside in different images or the same image.