ImageGear for C and C++ on Linux v20.0 - Updated
IG_IP_arithmetic
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Image Processing Functions > IG_IP_arithmetic

This function performs an arithmetic or logical operation on two images.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_IP_arithmetic(
   HIGEAR hIGear1,
   HIGEAR hIGear2,
   AT_MODE nOperation
);

Arguments:

Name Type Description
hIGear1 HIGEAR HIGEAR handle of image 1, also the destination of the operation.
hIGear2 HIGEAR HIGEAR handle of image 2.
nOperation AT_MODE Specifies the kind of arithmetic operation to perform on the images. See enumIGMergeModes for possible values.

Return Value:

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

Supported Raster Image Formats:

All pixel formats supported by ImageGear for C and C++.

Example:

 
Copy Code
HIGEAR hIGear1;            // HIGEAR handle of the first image
HIGEAR hIGear2;            // HIGEAR handle of the second image
AT_ERRCOUNT nErrcount;    // Count of errs on stack upon ret from func

// Load image file "picture.bmp" from working directory
nErrcount = IG_load_file("picture.bmp", &hIGear1);
if(nErrcount == 0)
{
    nErrcount = IG_load_file("picture.tif", &hIGear2);
    if(nErrcount == 0)
    {
        nErrcount = IG_IP_arithmetic(hIGear1, hIGear2, IG_ARITH_ADD);
        // ...
        // Destroy the second image
        IG_image_delete(hIGear2);
    }
    // Destroy the first image
    IG_image_delete(hIGear1);
}

Remarks:

IG_IP_arithmetic_rect is an extended version of IG_IP_arithmetic that allows specifying a rectangular area on the first image to be used for processing.

IG_IP_merge is an extended version of IG_IP_arithmetic that allows specifying a rectangular area on the first image to be used for processing, as well as the coordinates in the first image where to place the upper-left corner of the specified rectangle of the second image.

Is this page helpful?
Yes No
Thanks for your feedback.