This documentation is for the old version. Go to the latest Graphics Mill docs

Rotating and Flipping Images

Image rotating and flipping is a basic imaging operation. Graphics Mill for .NET provides transform classes that allow applying them. There are two implementations of the image rotating algorithms: for rotating image at arbitrary angle, and special optimized algorithm for fixed angles that equal 90, 180, or 270 degrees.

You can use a transform class Rotate to rotate the image at the arbitrary angle. This angle is specified with property Angle, which is measured in degrees. Image is rotated clockwise (negative angles make image rotated counter-clockwise):

Quality and speed of the rotation depends on the InterpolationMode property. Some interpolation modes works fast, but have lower quality, some ones are working slow, but has high quality. To make resizing algorithms selection easier, you can use values such InterpolationMode enumeration members as LowQuality ( = HighSpeed), MediumQuality ( = MediumSpeed) or HighQuality (LowSpeed) . These values specifies the best algorithm according to your needs. Nevertheless if you would like to get more detailed information about interpolation modes, read topics Comparison of Interpolation Modes and Interpolation Inside.

To be able to use shorter syntax, you can use Rotate method of the TransformsProvider returned by the Bitmap. Here is a code example that demonstrates it:

Visual Basic
'Rotate at 5 degrees with medium quality
bitmap.Transforms.Rotate(5, Aurigma.GraphicsMill.RgbColor.Yellow, _
 Aurigma.GraphicsMill.Transforms.InterpolationMode.MediumQuality)
C#
//Rotate at 5 degrees with medium quality
bitmap.Transforms.Rotate(5, Aurigma.GraphicsMill.RgbColor.Yellow, 
    Aurigma.GraphicsMill.Transforms.InterpolationMode.MediumQuality);

This code rotates the image using Rotate class:

Visual Basic
'Rotate at 5 degrees with medium quality
Dim rotate As New Aurigma.GraphicsMill.Transforms.Rotate
rotate.Angle = 5
rotate.BackgroundColor = Aurigma.GraphicsMill.RgbColor.Yellow
rotate.InterpolationMode = Aurigma.GraphicsMill.Transforms.InterpolationMode.MediumQuality
rotate.ApplyTransform(bitmap)
C#
//Rotate at 5 degrees with medium quality
Aurigma.GraphicsMill.Transforms.Rotate rotate =
    new Aurigma.GraphicsMill.Transforms.Rotate();
rotate.Angle = 5;
rotate.BackgroundColor = Aurigma.GraphicsMill.RgbColor.Yellow;
rotate.InterpolationMode = Aurigma.GraphicsMill.Transforms.InterpolationMode.MediumQuality;
rotate.ApplyTransform(bitmap);

To flip image or rotate it at 90, 180, or 270, you should use RotateAndFlip class. It has the single parameter Mode, which specifies one of 8 combinations of flip and rotate, e.g. flip horizontally and rotate at 90 degrees, flip vertically only, do not flip and rotate at 180 degrees, etc.

Note

If you rotate the image at 90, 180, or 270, this transform works much faster than Rotate. That's why we recommend using this class for these three angles.

This class also duplicated by RotateAndFlip method of the TransformsProvider returned by the Bitmap. Here is a code example that demonstrates how to use it:

Visual Basic
bitmap.Transforms.RotateAndFlip(System.Drawing.RotateFlipType.Rotate90FlipNone)
C#
bitmap.Transforms.RotateAndFlip(System.Drawing.RotateFlipType.Rotate90FlipNone);

This code rotates the image using RotateAndFlip class:

Visual Basic
Dim rotateAndFlip As New Aurigma.GraphicsMill.Transforms.RotateAndFlip
rotateAndFlip.Mode = System.Drawing.RotateFlipType.Rotate90FlipNone
rotateAndFlip.ApplyTransform(bitmap)
C#
Aurigma.GraphicsMill.Transforms.RotateAndFlip rotateAndFlip =
    new Aurigma.GraphicsMill.Transforms.RotateAndFlip();
rotateAndFlip.Mode = System.Drawing.RotateFlipType.Rotate90FlipNone;
rotateAndFlip.ApplyTransform(bitmap);