ImageGear for C and C++ on Windows v20.5 - Updated
IG_image_create_alpha
API Reference Guide > Core Component API Reference > Core Component Functions Reference > General Image Functions > IG_image_create_alpha

This function has been deprecated and will be removed from the public API in a future release. Please use IG_image_create, IG_image_channel_add, and IG_image_colorspace_convert instead.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_image_create_alpha (
        HIGEAR hIGear, 
        HIGEAR hIBackgrnd, 
        AT_MODE nCreateMode 
);

Arguments:

Name Type Description
hIGear HIGEAR HIGEAR handle of image.
hIBackgrnd HIGEAR HIGEAR handle to a background image.
nCreateMode AT_MODE An integer value of type AT_MODE that tells ImageGear what bit depth the alpha channel should have. The possible settings for this variable, which are defined in accucnst.h are: IG_ALPHA_CREATE_1 and IG_ALPHA_CREATE_8.

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
HIGEAR hIGear,  /* HIGEAR handles of images */
HIGEAR hIBackgrnd;
AT_ERRCOUNT    nErrcount;  /* Tally of ImageGear errors on the stack*/
nErrcount = IG_load_file ("Picture1.tga", &hIGear);
nErrcount = IG_load_file( "Picture2".bmp", &hIBackgrnd);
nErrcount = IG_image_create_alpha( hIGear, hIBackgrnd, IG_ALPHA_CREATE_8);

Remarks:

This function creates an alpha channel in the image hIGear, based on the data found in hIBackgrnd.

The height and width of hIBackgrnd must not be less than the height and width of hIGear. If there is already an alpha channel in the image, it will be replaced. Here is the formula by which the alpha channel data is calculated (where I2 stands for second image):

A = (I2 - Back) / (abs(I2 - back) - back);

If hIBackgrnd is a 1-bit image, you should set nCreateMode to IG_ALPHA_CREATE_1. When hIGear is displayed, this data will act as overlay data, where the 2 possible values for each bit of overlay data will determine whether the pixel is displayed or is made transparent, so that whatever is in the background will show through.

If hIBackgrnd is an 8-bit image, you should set nCreateMode to IG_ALPHA_CREATE_8. This will add 8 bits (with 256 possible values) of alpha data for each pixel of hIGear.

The image must support the storage of alpha data. Targa (*.tga) is an example of one that does. In a 24-bit Targa image, each pixel is stored to 32 bits, where the extra 8 bits may be used for alpha data.
Is this page helpful?
Yes No
Thanks for your feedback.