LBitmapBase::Rotate

#include "ltwrappr.h"

virtual L_INT LBitmapBase::Rotate(nAngle, uFlags=ROTATE_RESIZE, crFill=0)

L_INT nAngle;

/* hundredths of degreesto rotate (+/-) */

L_UINT uFlags;

/* resize indicator */

COLORREF crFill;

/* background fill color */

Rotates the class object's bitmap by the number of degrees specified.

Parameter

Description

nAngle

Hundredths of degrees to rotate (+/-). This can be a number from 0 to 36,000. A positive value will rotate the image in a clockwise rotation, while a negative value will rotate the image in a counter-clockwise rotation.

uFlags

Flag to keep the resulting image the same size as the original image or to resize according to the rotation direction specified. Valid values are:

 

Value

Meaning

 

ROTATE_RESIZE

[0x0001] Size resulting image as needed.

 

ROTATE_RESAMPLE

[0x0002] Perform bilinear interpolation when rotating.

 

ROTATE_BICUBIC

[0x0004] Perform bicubic interpolation when rotating.

0

Do not resize the image. Crop it.

crFill

The background fill color. You can specify a COLORREF value, such as the return value of the Windows RGB macro, or you can use the PALETTEINDEX macro to specify a palette color.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function has the following features:

image\sqrblit.gif It uses the center of the image as the center of rotation.

image\sqrblit.gif It can rotate the image clockwise or counterclockwise up to 360 degrees in 1-degree increments.

image\sqrblit.gif It can resize the image to accommodate the rotated height and width, or it can retain the original height and width, cropping the bitmap as necessary.

image\sqrblit.gif It uses black as the background color to fill any new area created by the rotation.

To update a status bar or detect a user interrupt during execution of this function, refer to LBase::EnableStatusCallBack.

ROTATE_RESAMPLE and ROTATE_BICUBIC can be combined with ROTATE_RESIZE, but they can not be combined with each other. Therefore, you can pass ROTATE_RESAMPLE|ROTATE_RESIZE, but not ROTATE_RESAMPLE|ROTATE_BICUBIC.

If ROTATE_RESIZE is set, then the image is resized. Otherwise, the image is cropped.

Interpolation can be done while rotating certain images. This produces superior output, eliminating the jaggedness occurring when rotating images at angles that are not multiple of 90. (ie when nAngle is not a multiple of 9000).

The only images that are interpolated are:

8-bit grayscale images (for best results, all gray values should be in the bitmaps palette). If the rotation doesnt give the expected results, you can call LBitmapBase::GrayScale(8) to change the bitmap into a proper grayscale bitmap.

12-bit and 16-bit grayscale bitmaps that dont have a palette. Grayscale bitmaps can have a palette if they have been loaded from certain DICOM images or if the LBitmap::WindowLevel function has been called. Call LBitmapBase::GrayScale(12) or LBitmapBase::GrayScale(16) if LBitmapBase::Rotate doesnt seem to do any interpolation during the rotation.

16-bit color images

24-bit, 32-bit, 48-bit and 64-bit color images

For the other images, LBitmapBase::Rotate ignores the resampling flags and the rotate is performed without interpolation.

Required DLLs and Libraries

LTDIS
LTFIL

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

Class Members

Topics:

Raster Image Functions: Doing Geometric Transformations

 

Resizing Considerations

 

Using Color Values in LEADTOOLS

 

Raster Image Functions: Processing an Image

Example

L_INT LBitmapBase__RotateExample()
{
   L_INT nRet;
   LBitmapBase MyBitmap;
   MyBitmap.SetFileName(TEXT("C:\\Program Files\\LEAD Technologies, Inc\\LEADTOOLS 15.0\\Images\\image1.cmp")); 
   nRet =MyBitmap.Load();
   if(nRet !=SUCCESS)
      return nRet;
   if(MyBitmap.IsAllocated())
      nRet = MyBitmap.Rotate(4500,ROTATE_RESIZE, RGB(255, 0, 0));
   return nRet;
}