---
title: "Rotating and Flipping Images"
canonical: https://www.graphicsmill.com/docs/gm/rotating-and-flipping-images.htm
product: "Graphics Mill"
---

# Rotating and Flipping Images
 
Image rotating and flipping are basic imaging operations. As you know, Graphics Mill provides two ways to perform geometrical raster transformations: in-place and out-of-place. This article describes both approaches to performing rotating and flipping and provides code snippets.
 
Let us examine both operations in more detail.
 
## Rotating an Image
  
In Graphics Mill positive degree numbers cause a clockwise rotation (demonstrated on the picture below) and negative degree numbers cause a counter-clockwise rotation.
 
![clockwise rotation (positive degree number)](https://www.graphicsmill.com/docs/gm/ImageConcept4.png)
 
A special case is rotation by 90, 180, or 270 degrees, because it uses a special algorithm which avoids floating-point calculations yielding to higher performance. Also in this case the rotated image remains rectangular, thus you get the rotated version of a source image without additional background. In other cases the rotated image is not rectangular, so it will be padded with the background color to get a rectangular image.
 
Quality and speed of the rotation depends on the interpolation mode used. Better quality means lower speed. The [InterpolationMode](https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_InterpolationMode.htm.md) enumeration exposes the available interpolation modes, including **High**, **Medium**, and **Low**. To get more information about interpolation modes read the [Interpolation Modes Comparison](https://www.graphicsmill.com/docs/gm/interpolation-modes-comparison.htm.md) topic.
 
You can specify the background color and the interpolation mode as arguments of the [TransformsProvider.Rotate](https://www.graphicsmill.com/docs/gm/O_T_Aurigma_GraphicsMill_TransformsProvider_Rotate.htm.md) method if you use the [Bitmap.Transforms](https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Bitmap_Transforms.htm.md) property to perform rotation. If you prefer to utilize the [Transforms.Rotate](https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_Rotate.htm.md) class, then you can set the background color and the interpolation mode as [constructor](https://www.graphicsmill.com/docs/gm/O_T_Aurigma_GraphicsMill_Transforms_Rotate_ctor.htm.md) arguments or through the [Rotate.BackgroundColor](https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Transforms_Rotate_BackgroundColor.htm.md) and [Rotate.InterpolationMode](https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Transforms_Rotate_InterpolationMode.htm.md) properties.
 
If you do not specify background color and interpolation mode, the transparent white color and the high quality interpolation mode are used.
 
The following code rotates an image by 5 degrees clockwise using the **Bitmap.Transforms** property:
 
```csharp
using (var bitmap = new Bitmap(@"Images\in.jpg"))
{
    bitmap.Transforms.Rotate(5, RgbColor.Yellow, InterpolationMode.Medium);
    bitmap.Save(@"Images\Output\out.jpg");
}
```
 
The following code rotates an image by 5 degrees clockwise using the **Transforms.Rotate** class:
 
```csharp
using (var bitmap = new Bitmap(@"Images\in.jpg"))
using (var rotate = new Rotate(5, RgbColor.Yellow, InterpolationMode.Medium))
{
    using (var result = rotate.Apply(bitmap))
    {
        result.Save(@"Images\Output\out.jpg");
    }
}
```
 
## Flipping an Image
  
To flip an image you can use the [Transforms.Flip](https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_Flip.htm.md) class or the **Bitmap.Transforms** property. In both cases you have to specify the flip mode. The [Transforms.FlipType](https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_FlipType.htm.md) class exposes the available flip modes: **Horizontal**, **Vertical**, and **Both**.
 
The following code flips an image horizontally using the **Bitmap.Transforms** property:
 
```csharp
using (var bitmap = new Bitmap(@"Images\in.jpg"))
{
    bitmap.Transforms.Flip(FlipType.Horizontal);
    bitmap.Save(@"Images\Output\out.jpg");
}
```
 
The following code flips an image horizontally using the **Transforms.Flip** class:
 
```csharp
using (var bitmap = new Bitmap(@"Images\in.jpg"))
using (var flip = new Flip(FlipType.Horizontal))
{
    using (var result = flip.Apply(bitmap))
    {
        result.Save(@"Images\Output\out.jpg");
    }
}
```
 
## See Also
  
### Reference
 
- [Bitmap.Transforms Property](https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Bitmap_Transforms.htm.md)
- [Transforms.Rotate Class](https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_Rotate.htm.md)
- [Transforms.InterpolationMode Class](https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_InterpolationMode.htm.md)
- [Transforms.Flip Class](https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_Flip.htm.md)
- [Transforms.FlipType Class](https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_FlipType.htm.md)

### Manual
 
- [Resizing and Cropping Images](https://www.graphicsmill.com/docs/gm/resizing-and-cropping-images.htm.md)
- [Affine and Projective Transformations](https://www.graphicsmill.com/docs/gm/affine-and-projective-transformations.htm.md)
- [Applying Lossless JPEG Transforms](https://www.graphicsmill.com/docs/gm/applying-lossless-jpeg-transforms.htm.md)
