From 94f5496b9d6b4e013b35303a4274d331ac8ce144 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: 631be0d9a0d36d2edcbd06578724f275d404127f Former-commit-id: 41ac4115350de23c773d8490d3fea04650cf578d --- 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 6e71079c6..0e33eb5dc 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 b2ecd30cc..421216e00 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