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

This function adds a new channel to an image at the specified position, populating the channel's image data from another channel.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_image_channel_add(
        HIGEAR hIGear,
        AT_UINT position,
        LPCAT_CHANNEL_REF channel
);

Arguments:

Name Type Description
hIGear HIGEAR HIGEAR handle of image to which to add channel.
position AT_UINT Index of where channel should be added.
channel LPCAT_CHANNEL_REF Location of channel to add.

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
/* Add an "extra" channel to an image */
AT_ERRCOUNT nErrcount;  /* Number of errors on stack */
HIGEAR hImage;          /* Handle of destination image */
HIGEAR hExtra;          /* Handle of image to use as extra */
AT_CHANNEL_REF channel; /* Channel to add */
AT_INT nChannels;       /* Number of channels in dest. image */
channel.hImage = hExtra;
channel.uNumber = 0;
nErrcount = IG_image_channel_count_get(hImage, &nChannels);
nErrcount = IG_image_channel_add(hImage, nChannels, &channel);
nErrcount = IG_image_colorspace_get(hImage, &cs);

Remarks:

The position is an index into the number of channels starting at 0. channel specifies the location of the channel to add, which consists of the HIGEAR handle of the image containing the channel and the index of the channel within that image.