From 423e602dc7b67152e26cb00640f3a08b35a974a2 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Wed, 25 Feb 2015 14:01:34 +0100 Subject: [PATCH] Fixes the rotation calculations Former-commit-id: a8b3a255e6f4881e02b0fcc3aa9c1e22d84fd014 Former-commit-id: 7d263535078966c8773e28278d61913aeca166d9 --- src/ImageProcessor/Processors/RotateInside.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ImageProcessor/Processors/RotateInside.cs b/src/ImageProcessor/Processors/RotateInside.cs index e0a24ea89..b715aa416 100644 --- a/src/ImageProcessor/Processors/RotateInside.cs +++ b/src/ImageProcessor/Processors/RotateInside.cs @@ -134,16 +134,16 @@ namespace ImageProcessor.Processors int diffY = (image.Height - newSize.Height) / 2; // Put the rotation point in the "center" of the old image - graphics.TranslateTransform(diffX, diffY); + graphics.TranslateTransform(rotateAtX - diffX, rotateAtY - diffY); // Rotate the image graphics.RotateTransform(rotateLayer.Angle); // Move the image back - graphics.TranslateTransform(-diffX * 2, -diffY * 2); + graphics.TranslateTransform(-(rotateAtX - diffX), -(rotateAtY - diffY)); // Draw passed in image onto graphics object - graphics.DrawImage(image, new PointF(0, 0)); + graphics.DrawImage(image, new PointF(-diffX, -diffY)); } }