ImageGear for C and C++ on Linux v19.10 - Updated
IG_IP_blend_percent
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Image Processing Functions > IG_IP_blend_percent

This function blends the second image into the first.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_IP_blend_percent ( 
        HIGEAR hIGearDest, 
        const HIGEAR hIGear2, 
        const DOUBLE dblPctOfImage2, 
        const AT_MODE nColorChannel, 
        const LPAT_RECT lpRect
);

Arguments:

Name Type Description
hIGearDest HIGEAR HIGEAR handle of the image into which to be blended.
hIGear2 const HIGEAR HIGEAR handle of image to blend in, must be same size and bit depth.
dblPctOfImage2 const DOUBLE Percent of image 2 to be in the blend (the percent of image 1 will be 100.0 minus this). 0 means all of image 1; 50 means half and half, and 100 means all of image 2. The range of values is 0.0 to 100.0.
nColorChannel const AT_MODE A constant such as IG_COLOR_COMP_R, _G, _B, or _RGB, specifying which color(s) to blend.
lpRect const LPAT_RECT Far pointer to an AT_RECT struct specifying the rectangular portion of the image to operate on. lpRect = NULL means the entire image. Before ImageGear performs this operation, it will check to see if an internal flag has been set to TRUE to make a mask active for this HIGEAR image. If a mask is active, and a valid pointer to a mask can be found, ImageGear will override the settings passed to this structure in favor of the non- rectangular ROI defined by the mask.

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++.

Example:

 
Copy Code
HIGEAR hIGear1;      /* Handle of image1 that will change  */
HIGEAR hIGear2;     /* Handle of image2      */
AT_ERRCOUNT nErrcount;  /* Returned count of errors  */
AT_DIMENSION nWidth, nHeight;  /* Width & Height of Image1          */ 
UINT nBpp;     /* Bits per pixel    */
AT_RECT rcRectOf1;   /* selected rectangle from image1  */
/* Get dimensions of hIGear1, so can use width and height values below */
nErrcount = IG_image_dimensions_get( hIGear1, &nWidth, &nHeight, &nBpp );
/*Use the bottom ? of Image1 */
rcRectOf1.left = 0;
rcRectOf1.top = nHeight/2;
rcRectOf1.right = nWidth - 1;
rcRectOf1.bottom = nHeight - 1;
/* If 24-bit image, blend all color channels (else blend pixels) */
nErrcount = IG_IP_blend_percent ( hIGear1, hIGear2, 20.0,IG_COLOR_COMP_RGB, &rcRectOf1 );

Remarks:

Use lprect to set a rectangular portion of the first image to be processed. dblPctOfImage2 specifies the percent of each image to be used in the result. The image in hIGearDest is destroyed and is replaced with the resulting blend. The percentage ranges from 0 to 100. A zero results in 0% hIGearDest and 100% hIGear2. A value of 50% results in an image which is created ? of each image. A value of 100% creates an image that is 100% hIGear2 and 0% hIGearDest. The images must be the same width, height, and bit depth. nColorChannel lets you specify that only one color of a 24-bit image is to be blended in.

This function, like other ImageGear Image Processing and Clipboard API calls, takes an AT_RECT structure as an argument, so that you can process a rectangular sub-region of an image. However, before ImageGear performs the operation specified by this function, it will check to see if an internal flag has been set to TRUE, indicating that a mask HIGEAR should be used with the image. If the flag is set to TRUE, and a valid pointer to a mask image has been assigned, ImageGear will override the settings passed to the AT_RECT structure and use the non-rectangular ROI defined by the mask HIGEAR. To create a non-rectangular region of interest, call IG_IP_NR_ROI_to_HIGEAR_mask().

Please see the descriptions of IG_IP_NR_ROI_mask_associate() and IG_IP_NR_ROI_to_HIGEAR_mask() for more details.