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

This function creates a new image with the color space specified by colorSpace.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_image_channels_combine(
        LPCAT_CHANNEL_REF channels,
        AT_UINT channelsQty,
        enumIGColorSpaceIDs colorSpace,
        LPHIGEAR hIGear
);

Arguments:

Name Type Description
channels LPCAT_CHANNEL_REF Array of channel descriptors for channels to combine.
channelsQty AT_UINT Number of channels to combine.
colorSpace enumIGColorSpaceIDs Color space of new image.
hIGear LPHIGEAR Pointer to HIGEAR handle where new image is returned.

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
/* Make a copy of a 24-bit RGB image in which the 
   red and blue channels are swapped */
AT_ERRCOUNT nErrcount;  /* Number of errors on stack */
HIGEAR hImage;          /* Handle of source image */
HIGEAR hImageCombined;  /* Handle of combined image */
AT_CHANNEL_REF chan[3]; /* Channels to combine */
nErrcount = IG_load_file("test.jpg", &hImage);
chan[0].hImage = hImage;
chan[0].uNumber = 2;
chan[1].hImage = hImage;
chan[1].uNumber = 1;
chan[2].hImage = hImage;
chan[2].uNumber = 0;
nErrcount = IG_image_channels_combine(chan, 3, 
    IG_COLOR_SPACE_ID_RGB, &hImageCombined);
nErrcount = IG_save_file(hImageCombined, "test.bmp", 
    IG_SAVE_BMP_UNCOMP);
IG_image_delete(hImage);
IG_image_delete(hImageCombined);

Remarks:

The channels in the new image are copied from the channels specified by channels.

This function does not do any color space or pixel conversions, it merely merges the pixel data from different channels together.