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

This function rotates the image by the specified angle.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_IP_rotate_any_angle_bkgrnd(
   HIGEAR hIGear,
   DOUBLE angle,
   AT_MODE rotate_mode,
   LPAT_PIXEL lpBkgrndColor
);

Arguments:

Name Type Description
hIGear HIGEAR HIGEAR handle of image.
angle DOUBLE Angle by which to rotate the image, in degrees. Positive values result in clockwise rotation; negative values result in counter-clockwise rotation.
rotate_mode AT_MODE Rotation mode. Specifies whether the image should be clipped or expanded. See enumIGRotationModes for possible values.
lpBkgrndColor LPAT_PIXEL A far pointer to the RGB or pixel value that specifies the background color to be used in the displaced areas after the image has been rotated.

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++.

Sample:

See GUI component source code.

Example:

 
Copy Code
HIGEAR hIGear;            // HIGEAR handle of the image
AT_ERRCOUNT nErrcount;    // Count of errs on stack upon ret from func
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 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_rotate_any_angle_bkgrnd(hIGear, 45., IG_ROTATE_CLIP, lpBackground);
    // ...
    // Destroy the image
    IG_image_delete(hIGear);
}

Remarks:

The function rotates the image about its center point.

You can use IG_IP_rotate_compute_size to calculate the new dimensions of the bitmap that the image will have after rotation in IG_ROTATE_EXPAND mode.

The functionality of this API call has been upgraded and supported by the new function IG_IP_rotate_any_angle_ex. This new function allows you to specify the interpolation method for rotation. 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.

Rotating the image multiple times at angles that are not multiple of 90 degrees may degrade the quality of the image.

You can only rotate PDF/PS images in 90 degree increments.