Declaration
procedure Rotate(Angle: Double; AntiAliasMode: TIEAntialiasMode = ierFast; BackgroundColor: TColor = -1);
Description
Rotate the current image by the specified angle (negative or positive degrees counter-clockwise).
AntialiasMode specifies the algorithm used to improve rotation quality (only used when angle is NOT 90, 180 or 270):
Value | Description |
ierNone | No anti-aliasing (lowest quality) |
ierFast | Fast, but lower quality |
ierBilinear | Bilinear, high quality |
ierBicubic | Bicubic, highest quality |
BackgroundColor specifies an alternative background color to fill new regions (i.e. when not rotating at a 90 degree angle). It is not used if the image contains an alpha channel.
If -1, Rotate uses the
default background. If clNone, then an
alpha channel is applied to the image and the non-image area will become transparent.
This is a common image from a digital camera that was not held correctly causing the horizon not to be level.
After calling
ImageEnView1.Proc.Rotate( 5 ):
Note:
◼If the image has an
alpha channel then the null area is filled with transparency (so you will not see the background color). To prevent the transparent area, and force a background color fill,
remove the alpha channel
◼To crop the image caused by rotation, use
RotateAndCrop
◼To crop and rotate an ROI, use
Crop
◼To allow the user to interactively rotate the image, use
RotateTool
◼If
PdfViewer is enabled, this will redirect to
PageRotation
◼A UI for this is available to your users in the
Image Processing dialog
◼For very large images, ierFast can be memory intensive. Use ierNone or one of the other modes instead
Anti-alias Modes
| Demos\ImageEditing\CompleteEditor\PhotoEn.dpr |
| Demos\ImageEditing\EveryMethod\EveryMethod.dpr |
// Rotate the image 45° clockwise at highest quality and using the ImageEnView background color
ImageEnView1.Proc.Rotate( 315, ierBicubic, -1 );
// Rotate the image 90° clockwise (Note: AntialiasMode is irrelevant for 90 deg. rotations)
ImageEnView1.Proc.Rotate( 270 );
// Rotate the image 180° clockwise
ImageEnView1.Proc.Rotate( 180 );
// Rotate the image 90° counter-clockwise
ImageEnView1.Proc.Rotate( 90 );
// Rotate the image 45° clockwise at highest quality and make the non-image area transparent
ImageEnView1.Proc.Rotate( 315, ierBicubic, clNone );
// Which is the same as...
// Rotate the image 45° clockwise, with good quality, and the null area created by the rotation set as transparent
ImageEnView1.IEBitmap.AlphaChannel; // Create an alpha channel if one does not exist
ImageEnView1.Proc.Rotate( -45, ierBicubic );
// Rotate the image 45° clockwise, with good quality, and the null area created by the rotation set as black
ImageEnView1.IEBitmap.RemoveAlphaChannel; // Remove alpha channel if there is one
ImageEnView1.Proc.Rotate( -45, ierBicubic, clBlack );
// Load and rotate an image 90° counter-clockwise
ImageEnView1.IO.LoadFromFile( 'D:\TestImage.jpg' );
ImageEnView1.Proc.Rotate( 90 );
See Also
◼Global Image Methods
◼AngleToImageEnRotateAngle