Browse Source

Fixes the zoom calculation

Former-commit-id: 631be0d9a0d36d2edcbd06578724f275d404127f
Former-commit-id: 41ac4115350de23c773d8490d3fea04650cf578d
af/merge-core
Thomas Broust 11 years ago
parent
commit
94f5496b9d
  1. 3
      src/ImageProcessor.UnitTests/Imaging/RotationUnitTests.cs
  2. 2
      src/ImageProcessor/Imaging/Rotation.cs

3
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);

2
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);
}
}
}
Loading…
Cancel
Save