ImageGear for C and C++ on Linux v18.8 - Updated
IG_IP_resize_bkgrnd
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Image Processing Functions > IG_IP_resize_bkgrnd

This function resizes the image referenced by hIGear.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_IP_resize_bkgrnd(
   HIGEAR hIGear,
   AT_DIMENSION nNewWidth,
   AT_DIMENSION nNewHeight,
   AT_MODE nInterpMethod,
   LPAT_PIXEL lpBkgColor
);

Arguments:

Name Type Description
hIGear HIGEAR HIGEAR handle of image to resize.
nNewWidth AT_DIMENSION Width that the image is to be after resizing.
nNewHeight AT_DIMENSION Height that the image is to be after resizing.
nInterpMethod AT_MODE Specifies interpolation method to use for image resizing. See enumIGInterpolations for possible values.
lpBkgColor LPAT_PIXEL Pointer to the RGB or pixel value that specifies the background color to be used in the displaced areas after the image has been resized when using the resize with padding or canvas method.

Return Value:

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

Supported Raster Image Formats:

If nInterpMethod is IG_INTERPOLATION_GRAYSCALE, IG_INTERPOLATION_PRESERVE_WHITE, or IG_INTERPOLATION_PRESERVE_BLACK:

If nInterpMethod is IG_INTERPOLATION_AVERAGE or IG_INTERPOLATION_BILINEAR:

All pixel formats supported by ImageGear for C and C++, except:

If nInterpMethod is IG_INTERPOLATION_BICUBIC:

All pixel formats supported by ImageGear for C and C++, except:

Otherwise, all pixel formats supported by ImageGear for C and C++.

This function does not support PDF images.

Example:

 
Copy Code
HIGEAR hIGear;            // HIGEAR handle of the image
AT_ERRCOUNT nErrcount;    // Count of errs on stack upon ret from func
AT_DIMENSION nWidth, nHeight;  // Dimensions of the image
AT_INT channelCount;    // Count of channels in the image
AT_PIXEL lpBackground[256];    // Buffer for background color
AT_INT i;

// Load image file "picture.bmp" from working directory
nErrcount = IG_load_file("picture.bmp", &hIGear);
if(nErrcount == 0)
{
    // Get dimensions of the image
    IG_image_dimensions_get(hIGear, &nWidth, &nHeight, NULL);
    // Get channel count
    IG_image_channel_count_get(hIGear, &channelCount);
    // Initialize background color with '255'
    for(i = 0; i < channelCount; i ++)
    {
        lpBackground[i] = (AT_PIXEL)255;
    }

    nErrcount = IG_IP_resize_bkgrnd(hIGear, nWidth / 2, nHeight / 2, IG_INTERPOLATION_BILINEAR, lpBackground);
    // ...
    // Destroy the image
    IG_image_delete(hIGear);
}

Remarks:

The image data in the bitmap will be stretched, compressed, or padded as necessary to fit the new dimensions.

During resizing, new pixel values that previously did not exist in the image may be introduced due to interpolation. If you want to prevent this, such as to preserve the original number of palette entries used, then specify IG_INTERPOLATION_NONE. In this case only pixel values that occur in the original image will result in the resized image.

Setting the IG_INTERPOLATION_PADDING means that if you increase the size of the image, it is padded to the new boundaries. Pixels added to the right and bottom of the original image will be filled with lpBkgColor. If you decrease the size of the image with IG_INTERPOLATION_PADDING, the image is cropped.