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

This function resizes the image referenced by hIGear.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_IP_resize_bkgrnd_ex(
   HIGEAR hIGear,
   AT_DIMENSION nNewWidth,
   AT_DIMENSION nNewHeight,
   AT_MODE nInterpMethod,
   LPAT_PIXEL lpBkgColor,
   DWORD dwFlags,
   INT nValue
);

Arguments:

Name Type Description
hIGear HIGEAR HIGEAR handle of image to resize.
nNewWidth AT_DIMENSION The width of the resized image.
nNewHeight AT_DIMENSION The height of the resized image.
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 is resized using padding method.
dwFlags DWORD Reserved for future use.
nValue INT The contents of this parameter depends upon the value of nInterpMethod:
  • IG_INTERPOLATION_GRAYSCALE - nValue can be from 0 to 100. It takes the proportion of pixels from entry 1 to entry 0 (white/black).
  • IG_INTERPOLATION_PRESERVE_WHITE - nValue can be from 0 to 100. It indicates the threshold value of the amount of white color to include.
  • IG_INTERPOLATION_PRESERVE_BLACK - nValue can be from 0 to 100. It indicates the threshold value of the amount of black color to include.
  • Any other values - nValue is ignored.

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_ex(hIGear, nWidth / 2, nHeight / 2, IG_INTERPOLATION_BILINEAR, lpBackground,
        0, 0);
    // ...
    // 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, (to preserve the original number of palette entries used, for example) 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.