ImageGear Professional v18.2 > API Reference Guide > Core Component API Reference > Core Component Functions Reference > Image Channel Functions > IG_image_channel_copy_create |
This function creates a new image by copying a single channel from an existing image.
Copy Code
|
|
---|---|
AT_ERRCOUNT ACCUAPI IG_image_channel_copy_create( LPCAT_CHANNEL_REF source, LPAT_CHANNEL_REF copy ); |
Name | Type | Description |
source | LPCAT_CHANNEL_REF | Location of source channel to copy. |
copy | LPAT_CHANNEL_REF | Location of new image with copied channel. |
Returns the number of ImageGear errors that occurred during this function call. If there are no errors, the return value is IGE_SUCCESS.
All pixel formats supported by ImageGear Professional.
Copy Code
|
|
---|---|
/* Extract the first alpha channel if one exists */ /* Otherwise, extract the first color channel */ AT_ERRCOUNT nErrcount; /* Number of errors on stack */ HIGEAR hImage; /* Handle of source image */ AT_CHANNEL_REF srcChan; /* Channel to copy */ AT_CHANNEL_REF dstChan; /* New image with copied channel */ enumIGColorSpaceIDs cs; /* Source image's color space */ AT_INT nColorChannels; /* Number of color channels */ nErrcount = IG_load_file("alpha.tif", &hImage); nErrcount = IG_image_colorspace_get(hImage, &cs); nColorChannels = IG_util_colorspace_color_count_get(cs); srcChan.hImage = hImage; if (IG_util_colorspace_contains_alpha(cs)) srcChan.uNumber = nColorChannels; /* First alpha channel */ else srcChan.uNumber = 0; /* First color channel */ nErrcount = IG_image_channel_copy_create(&srcChan, &dstChan); hCopy = dstChan.hImage; nErrcount = IG_save_file(dstChan.hImage, "alpha.bmp", IG_SAVE_BMP_UNCOMP); nErrcount = IG_image_delete(hImage); |
Specify in source the image and channel index to copy. If the copy is successful, copy will contain the HIGEAR handle of a newly allocated image containing the copied channel. The channel index in copy will always be set to 0. You are responsible for freeing the new image with IG_image_delete.