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

This function resizes the image referenced by hIGear without scaling it.

Declaration:

 
Copy Code
AT_ERRCOUNT LACCUAPI IG_IP_resize_canvas(
   HIGEAR hIGear,
   AT_DIMENSION new_width,
   AT_DIMENSION new_height,
   AT_PIXPOS nXPos,
   AT_PIXPOS nYPos,
   LPAT_PIXEL lpBkgColor
);

Arguments:

Name Type Description
hIGear HIGEAR Image to process.
new_width AT_DIMENSION Width of the image after resizing.
new_height AT_DIMENSION Height of the image after resizing.
nXPos AT_PIXPOS X offset at which to put left top corner of the image after resizing.
nYPos AT_PIXPOS Y offset at which to put left top corner of the image after resizing.
lpBkgColor LPAT_PIXEL Pointer to a color value array to fill the empty area, where one element is for each color channel in the image. Ignored for vector images.

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 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_canvas(hIGear, nWidth / 2, nHeight / 2, 0, 0, lpBackground);
    // ...
    // Destroy the image.
    IG_image_delete(hIGear);
}

 

Remarks:

The image data in the bitmap is not stretched or compressed, but copied to the specified offset in the new image.