ImageGear for C and C++ on Windows v19.5 - Updated
IG_IP_resize_ex
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Image Processing Functions > IG_IP_resize_ex

This function resizes the image referenced by hIGear.

Declaration:

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

Arguments:

Name Type Description
hIGear HIGEAR HIGEAR handle of image to resize.
nNewWidth AT_DIMENSION Width to which the image is to be resized.
nNewHeight AT_DIMENSION Height to which the image is to be resized.
nInterpMethod AT_MODE Specifies interpolation method to use for image resizing. See enumIGInterpolations for possible values.
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.

Sample:

None

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

// 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);

    nErrcount = IG_IP_resize_ex(hIGear, nWidth / 2, nHeight / 2, IG_INTERPOLATION_BILINEAR, 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, 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.

The functionality of this API call has been upgraded and supported by the new function IG_IP_resize_bkgrnd_ex. The reason that this new function has been created is that the old function does not allow you to change the background color around the image being resized, if the interpolation is either IG_INTERPOLATION_PADDING or IG_INTERPOLATION_CANVAS. In the interest of backward compatibility, we have left the old function in its original form and have retained support for it. If you have already used the old function in your code, it is not mandatory that you modify your code, but it is recommended.