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

This function blends two images together using their alpha channels.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_image_blend_with_alpha(
       HIGEAR hSource,
       HIGEAR hAlpha,
       LPAT_RECT blendingArea
);

Arguments:

Name Type Description
hSource HIGEAR First image for blending. It may or may not contain an alpha channel.
hAlpha HIGEAR Second image for blending. It must contain an alpha channel.
blendingArea LPAT_RECT Rectange area of the first image for blending. NULL means the entire image.

Return Value:

Returns 0 if successful. Otherwise, returns the number of ImageGear errors that occurred during this function call.

Supported Raster Image Formats:

hSource:

hAlpha:

Sample:

Alpha

Remarks:

hAlpha is blended over hSource, and the result is stored in hSource. hAlpha should contain an Alpha channel, otherwise, an error is returned. Color channels (all channels except Extra and Alpha/Premultiplied Alpha) of both images must have the same color space and the same bit depths.

If hSource does not contain an Alpha channel, hAlpha is composited over it using hSource as the background. The resulting image does not contain an Alpha channel. The following formulas are used:

If hSource contains an Alpha channel, hSource and hAlpha are blended together. The resulting image contains an alpha channel. Blending two images, both of which contain an Alpha channel, can be interpreted as placing one semi-transparent film over another semi-transparent film. The result of applying such combined images to some background is the same as applying one image over background and then applying another image to the result. The code will produce the same result as The following pseudocode demonstrates the formulas used by the function: Alpha values are mapped to a float value between 0.0 and 1.0, where 0.0 means full transparency and 1.0 means full opaquity. Alpha value of 0 corresponds to float value of 0.0 and alpha value of 2^n-1 (where n is alpha channel's bit depth) corresponds to float value of 1.0.

This function does not process Extra Channels.