Transforming Images (Resize, Rotate, Crop)

This section is designed to give a detailed explanation on how to perform geometrical raster transformations with Graphics Mill. The section examines such transformations as rotating, flipping, resizing, cropping, and affine/projective transformations using matrices. If you are working with JPEG format and want to apply the transformations without diminishing the image's quality, see the Applying Lossless JPEG Transforms topic.

Image transformation operations in Graphics Mill can be performed in two ways: in-place and out-of-place. The main difference is that in-place operations change the source bitmap, while out-of-place operations create a new one. All in-place transformations are realized through the TransformsProvider class and can be implemented via the Bitmap.Transforms property. To implement an out-of-place operation you should utilize the related class from the Aurigma.GraphicsMill.Transforms namespace, for example, the Transforms.Resize class.

For in-place resize transformation, note that the source bitmap is changed:

C#
using (var bitmap = new Bitmap(@"Images\in.jpg"))
{
    
    bitmap.Transforms.Resize(100, 0);
    bitmap.Save(@"Images\Output\out.jpg");
}

For out-of-place resize transformation, note that the new resized bitmap is created, while the source bitmap remains unchanged:

C#
using (var bitmap = new Bitmap(@"Images\in.jpg"))
using (var resize = new Resize(100, 0))
{
    using (var result = resize.Apply(bitmap))
    {
        result.Save(@"Images\Output\out.jpg");
    }
}

In This Section

Resizing and Cropping Images
Rotating and Flipping Images
Affine and Projective Transformations