From ff2a71f7ac5a35a3a9fd0fc910089fe75b94f9a9 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Wed, 25 Feb 2015 10:24:15 +0100 Subject: [PATCH] Fixes the zoom calculation Former-commit-id: 081d9d9fabd87ebf4d9643b49d5e80cd772dde48 Former-commit-id: 8f41c7f5228450698bc8e4cc3d76bc4cb902e435 --- src/ImageProcessor.UnitTests/Imaging/RotationUnitTests.cs | 3 +++ src/ImageProcessor/Imaging/Rotation.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ImageProcessor.UnitTests/Imaging/RotationUnitTests.cs b/src/ImageProcessor.UnitTests/Imaging/RotationUnitTests.cs index 6e71079c62..0e33eb5dc3 100644 --- a/src/ImageProcessor.UnitTests/Imaging/RotationUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Imaging/RotationUnitTests.cs @@ -23,6 +23,9 @@ [TestCase(100, 100, 45, 1.41f)] [TestCase(100, 100, 15, 1.22f)] [TestCase(100, 200, 45, 2.12f)] + [TestCase(200, 100, 45, 2.12f)] + [TestCase(600, 450, 20, 1.39f)] + [TestCase(600, 450, 45, 1.64f)] public void RotationZoomIsCalculated(int imageWidth, int imageHeight, float angle, float expected) { float result = Rotation.ZoomAfterRotation(imageWidth, imageHeight, angle); diff --git a/src/ImageProcessor/Imaging/Rotation.cs b/src/ImageProcessor/Imaging/Rotation.cs index b2ecd30cc8..421216e00a 100644 --- a/src/ImageProcessor/Imaging/Rotation.cs +++ b/src/ImageProcessor/Imaging/Rotation.cs @@ -56,7 +56,7 @@ double widthRotated = (imageWidth * radiansCos) + (imageHeight * radiansSin); double heightRotated = (imageWidth * radiansSin) + (imageHeight * radiansCos); - return (float)(Math.Max(widthRotated, heightRotated) / 100); + return (float)Math.Max(widthRotated / imageWidth, heightRotated / imageHeight); } } } \ No newline at end of file