diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj
index 54ca14e2c..1d808f963 100644
--- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj
+++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj
@@ -64,7 +64,7 @@
-
+
diff --git a/src/ImageProcessor.UnitTests/Imaging/Helpers/ImageMathsUnitTests.cs b/src/ImageProcessor.UnitTests/Imaging/Helpers/ImageMathsUnitTests.cs
index 9b42e7f85..3e1ffdfb3 100644
--- a/src/ImageProcessor.UnitTests/Imaging/Helpers/ImageMathsUnitTests.cs
+++ b/src/ImageProcessor.UnitTests/Imaging/Helpers/ImageMathsUnitTests.cs
@@ -5,20 +5,38 @@
using ImageProcessor.Imaging.Helpers;
using NUnit.Framework;
+ ///
+ /// Test harness for the image math unit tests
+ ///
public class ImageMathsUnitTests
{
+ ///
+ /// Tests that the bounding rectangle of a rotated image is calculated
+ ///
+ /// The width of the image.
+ /// The height of the image.
+ /// The rotation angle.
+ /// The expected width.
+ /// The expected height.
[Test]
[TestCase(100, 100, 45, 141, 141)]
[TestCase(100, 100, 30, 137, 137)]
[TestCase(100, 200, 50, 217, 205)]
- public void NewSizeAfterRotationIsCalculated(int width, int height, float angle, int expectedWidth, int expectedHeight)
+ public void BoundingRotatedRectangleIsCalculated(int width, int height, float angle, int expectedWidth, int expectedHeight)
{
- Size result = ImageMaths.GetBoundingRotatedRectangle(width, height, angle);
+ Rectangle result = ImageMaths.GetBoundingRotatedRectangle(width, height, angle);
result.Width.Should().Be(expectedWidth, "because the rotated width should have been calculated");
result.Height.Should().Be(expectedHeight, "because the rotated height should have been calculated");
}
+ ///
+ /// Tests that the zoom needed for an "inside" rotation is calculated
+ ///
+ /// Width of the image.
+ /// Height of the image.
+ /// The rotation angle.
+ /// The expected zoom.
[Test]
[TestCase(100, 100, 45, 1.41f)]
[TestCase(100, 100, 15, 1.22f)]
diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj
index 919f7d8fe..aeb5403ef 100644
--- a/src/ImageProcessor/ImageProcessor.csproj
+++ b/src/ImageProcessor/ImageProcessor.csproj
@@ -215,7 +215,6 @@
-
diff --git a/src/ImageProcessor/Imaging/Helpers/ImageMaths.cs b/src/ImageProcessor/Imaging/Helpers/ImageMaths.cs
index 60b35989f..76ed51d77 100644
--- a/src/ImageProcessor/Imaging/Helpers/ImageMaths.cs
+++ b/src/ImageProcessor/Imaging/Helpers/ImageMaths.cs
@@ -111,7 +111,7 @@ namespace ImageProcessor.Imaging.Helpers
/// The height of the image.
/// The angle of rotation.
/// The new size of the image
- public static Size GetBoundingRotatedRectangle(int width, int height, float angle)
+ public static Rectangle GetBoundingRotatedRectangle(int width, int height, float angle)
{
double widthAsDouble = width;
double heightAsDouble = height;
@@ -129,9 +129,11 @@ namespace ImageProcessor.Imaging.Helpers
double height2 = (widthAsDouble * radiansSin) + (heightAsDouble * radiansCos);
// Get the external vertex for the rotation
- Size result = new Size();
- result.Width = Convert.ToInt32(Math.Max(Math.Abs(width1), Math.Abs(width2)));
- result.Height = Convert.ToInt32(Math.Max(Math.Abs(height1), Math.Abs(height2)));
+ Rectangle result = new Rectangle(
+ 0,
+ 0,
+ Convert.ToInt32(Math.Max(Math.Abs(width1), Math.Abs(width2))),
+ Convert.ToInt32(Math.Max(Math.Abs(height1), Math.Abs(height2))));
return result;
}
diff --git a/src/ImageProcessor/Processors/Rotate.cs b/src/ImageProcessor/Processors/Rotate.cs
index cb8cc1733..9d51bbc8d 100644
--- a/src/ImageProcessor/Processors/Rotate.cs
+++ b/src/ImageProcessor/Processors/Rotate.cs
@@ -104,7 +104,7 @@ namespace ImageProcessor.Processors
///
private Bitmap RotateImage(Image image, float rotateAtX, float rotateAtY, float angle)
{
- Size newSize = Imaging.Helpers.ImageMaths.GetBoundingRotatedRectangle(image.Width, image.Height, angle);
+ Rectangle newSize = Imaging.Helpers.ImageMaths.GetBoundingRotatedRectangle(image.Width, image.Height, angle);
int x = (newSize.Width - image.Width) / 2;
int y = (newSize.Height - image.Height) / 2;