From 4544742e345977f4b1cad5cb5e29b3cc45852d35 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 16 Oct 2024 20:53:16 +1000 Subject: [PATCH] Fix identity checks --- src/ImageSharp/Common/Helpers/QuadDistortionHelper.cs | 7 ++++++- .../Processing/Processors/Transforms/TransformUtils.cs | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ImageSharp/Common/Helpers/QuadDistortionHelper.cs b/src/ImageSharp/Common/Helpers/QuadDistortionHelper.cs index 27863f773a..dcd89bafb2 100644 --- a/src/ImageSharp/Common/Helpers/QuadDistortionHelper.cs +++ b/src/ImageSharp/Common/Helpers/QuadDistortionHelper.cs @@ -23,7 +23,12 @@ internal static class QuadDistortionHelper /// This method is based on the algorithm described in the following article: /// /// - public static Matrix4x4 ComputeQuadDistortMatrix(Rectangle rectangle, PointF topLeft, PointF topRight, PointF bottomRight, PointF bottomLeft) + public static Matrix4x4 ComputeQuadDistortMatrix( + Rectangle rectangle, + PointF topLeft, + PointF topRight, + PointF bottomRight, + PointF bottomLeft) { PointF p1 = new(rectangle.X, rectangle.Y); PointF p2 = new(rectangle.X + rectangle.Width, rectangle.Y); diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs index 62ea5e830d..fa6ab137b9 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs @@ -301,7 +301,7 @@ internal static class TransformUtils { Guard.IsTrue(size.Width > 0 && size.Height > 0, nameof(size), "Source size dimensions cannot be 0!"); - if (matrix.Equals(default) || matrix.Equals(Matrix4x4.Identity)) + if (matrix.IsIdentity || matrix.Equals(default)) { return size; } @@ -376,7 +376,7 @@ internal static class TransformUtils { Guard.IsTrue(size.Width > 0 && size.Height > 0, nameof(size), "Source size dimensions cannot be 0!"); - if (matrix.Equals(default) || matrix.Equals(Matrix3x2.Identity)) + if (matrix.IsIdentity || matrix.Equals(default)) { return size; } @@ -412,7 +412,7 @@ internal static class TransformUtils /// private static bool TryGetTransformedRectangle(RectangleF rectangle, Matrix3x2 matrix, out Rectangle bounds) { - if (rectangle.Equals(default) || Matrix3x2.Identity.Equals(matrix)) + if (matrix.IsIdentity || rectangle.Equals(default)) { bounds = default; return false; @@ -439,7 +439,7 @@ internal static class TransformUtils [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryGetTransformedRectangle(RectangleF rectangle, Matrix4x4 matrix, out Rectangle bounds) { - if (rectangle.Equals(default) || Matrix4x4.Identity.Equals(matrix)) + if (matrix.IsIdentity || rectangle.Equals(default)) { bounds = default; return false;