This function blends two images together using their alpha channels.
Declaration:
![]() |
|
---|---|
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:
- Grayscale - 2..16 bpp;
- RGB - 6..48 bpp;
- GyA - 4..32 bpp;
- GyPA - 4..32 bpp;
- RGBA - 8..64 bpp;
- RGBPA - 8..64 bpc.
hAlpha:
- GyA - 4..32 bpp;
- GyPA - 4..32 bpp;
- RGBA - 8..64 bpp;
- RGBPA - 8..64 bpc.
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 Page2 is not pre-multiplied,
- I1 = I2 * A2 + I1 (1-A2)
- If Page2 is pre-multiplied,
- I1 = I2 + I1 (1-A2)
- IG_image_blend_with_alpha(hImage1, hImage2, NULL);
- IG_image_blend_with_alpha(hBackground, hImage1, NULL);
- IG_image_blend_with_alpha(hBackground, hImage1, NULL);
- IG_image_blend_with_alpha(hBackground, hImage2, NULL);
- if (A1=A2=0)
- I1 = 0; A1 = 0;
- else
- If both Page1 and Page2 are not pre-multiplied,
- I1 = (I2*A2 + I1*A1*(1-A2)) / (A1 + A2 - A1*A2)
- A1 = A1 + A2 - A1*A2
- //Result is not pre-multiplied
- If Page1 is not pre-multiplied, and Page2 is pre-multiplied:
- I1 = (I2 + I1*A1*(1-A2)) / (A1 + A2 - A1*A2)
- A1 = A1 + A2 - A1*A2
- //Result is not pre-multiplied
- If Page1 is pre-multiplied, and Page2 is not:
- I1 = I2*A2 + I1*(1-A2)
- A1 = A1 + A2 - A1*A2
- //Result is pre-multiplied
- If both Page1 and Page2 are pre-multiplied:
- I1 = I2 + I1*(1-A2)
- A1 = A1 + A2 - A1*A2
- //Result is pre-multiplied
This function does not process Extra Channels.