
Contents |
Rotate
Rotates an image by a specified degree
1. imgRotate angle:=45 interpolate:=resample resize:=1 fill:=0;
2. imgRotate angle:=30 resize:=0 img:=[Mbook1]Msheet1!Mat(1) oimg:=<new>;
| Display Name | Variable Name | I/O and Type | Default Value | Description |
|---|---|---|---|---|
| Angle | angle |
Input double | |
Specifies the degree, by which the image is rotated. Valid range is from -180 to 180. A positive value will cause the image to be rotated clockwise, while a negative value will cause the image to be rotated counterclockwise. |
| Input Matrix | img |
Input Image | |
Specifies the image to be manipulated. The default input is the active image. |
| Output Image | oimg |
Output Image | |
Specifies the image to be manipulated. The default input is the active image. See the syntax here. |
| Interpolate | interpolate |
Input int | |
Specifies whether to perform interpolation during rotation. If interpolation is to be performed, user can further specify to use either bilinear or bicubic interpolation. Option list
|
| Resize | resize |
Input int | |
Specifies whether to resize the rotated image to fit the output image. If the image is not resized, it might be cropped and only part of it can be seen. |
| Fill Color | fill |
Input int | |
Specifies a color from the Origin color list to be used to fill the background of the output image. |
This function allows user to rotate an image by a chosen degree. The rotation center is the center of the image. After rotation, the rotated image is either resized or cropped to fit the size of the output image.
Degradation might occur when the image is rotated. However, you can compensate it with interpolation. Two interpolation methods are available. They are bilinear interpolation and bicubic interpolation. In general, bilinear interpolation tends to produce a smooth image while bicubic interpolation is apt to result in sharp image.
![]() |
![]() |
![]() |
![]() |
|
|
|
|
|
Rotated images usually have empty areas near each corner. User can choose a color to fill these areas.
In this example, we use the imgRotate function to rotate the input image by 30 degree:

For more examples, please refer to XF Script Dialog (press F11).
The computation uses L_RotateBitmap() function from LEADTOOLS Main API. Please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_RotateBitmap topic.
LEADTOOLS Main API Help file, Version 14