From f4e4abae720cd2748693c89fd6c4481b4b89a6f0 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Wed, 25 Feb 2015 10:27:00 +0100 Subject: [PATCH] Zooms the image when doing an 'inside rotation' Former-commit-id: 983fc19db77f6ddc5bdfca37b5151f891e103dfb Former-commit-id: 14453bf615233062120f7e4f2cc11889a1df7778 --- src/ImageProcessor/Processors/RotateInside.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ImageProcessor/Processors/RotateInside.cs b/src/ImageProcessor/Processors/RotateInside.cs index 05675be311..cd740a981d 100644 --- a/src/ImageProcessor/Processors/RotateInside.cs +++ b/src/ImageProcessor/Processors/RotateInside.cs @@ -83,7 +83,7 @@ namespace ImageProcessor.Processors /// The angle in degrees at which to rotate the image. /// The image rotated to the given angle at the given position. /// - /// Based on + /// Based on the Rotate effect /// private Bitmap RotateImage(Image image, float rotateAtX, float rotateAtY, float angle) { @@ -91,6 +91,8 @@ namespace ImageProcessor.Processors Bitmap newImage = new Bitmap(image.Width, image.Height); newImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); + float zoom = Imaging.Rotation.ZoomAfterRotation(image.Width, image.Height, angle); + // Make a graphics object from the empty bitmap using (Graphics graphics = Graphics.FromImage(newImage)) { @@ -106,6 +108,9 @@ namespace ImageProcessor.Processors // Rotate the image graphics.RotateTransform(angle); + // Zooms the image to fit the area + graphics.ScaleTransform(zoom, zoom); + // Move the image back graphics.TranslateTransform(-rotateAtX * 2, -rotateAtY * 2);