Skip to content

Commit 4544742

Browse files
Fix identity checks
1 parent 514d039 commit 4544742

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/ImageSharp/Common/Helpers/QuadDistortionHelper.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ internal static class QuadDistortionHelper
2323
/// This method is based on the algorithm described in the following article:
2424
/// <see href="https://blog.mbedded.ninja/mathematics/geometry/projective-transformations/"/>
2525
/// </remarks>
26-
public static Matrix4x4 ComputeQuadDistortMatrix(Rectangle rectangle, PointF topLeft, PointF topRight, PointF bottomRight, PointF bottomLeft)
26+
public static Matrix4x4 ComputeQuadDistortMatrix(
27+
Rectangle rectangle,
28+
PointF topLeft,
29+
PointF topRight,
30+
PointF bottomRight,
31+
PointF bottomLeft)
2732
{
2833
PointF p1 = new(rectangle.X, rectangle.Y);
2934
PointF p2 = new(rectangle.X + rectangle.Width, rectangle.Y);

src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public static Size GetTransformedSize(Matrix4x4 matrix, Size size)
301301
{
302302
Guard.IsTrue(size.Width > 0 && size.Height > 0, nameof(size), "Source size dimensions cannot be 0!");
303303

304-
if (matrix.Equals(default) || matrix.Equals(Matrix4x4.Identity))
304+
if (matrix.IsIdentity || matrix.Equals(default))
305305
{
306306
return size;
307307
}
@@ -376,7 +376,7 @@ private static Size GetTransformedSize(Matrix3x2 matrix, Size size, TransformSpa
376376
{
377377
Guard.IsTrue(size.Width > 0 && size.Height > 0, nameof(size), "Source size dimensions cannot be 0!");
378378

379-
if (matrix.Equals(default) || matrix.Equals(Matrix3x2.Identity))
379+
if (matrix.IsIdentity || matrix.Equals(default))
380380
{
381381
return size;
382382
}
@@ -412,7 +412,7 @@ private static Size GetTransformedSize(Matrix3x2 matrix, Size size, TransformSpa
412412
/// </returns>
413413
private static bool TryGetTransformedRectangle(RectangleF rectangle, Matrix3x2 matrix, out Rectangle bounds)
414414
{
415-
if (rectangle.Equals(default) || Matrix3x2.Identity.Equals(matrix))
415+
if (matrix.IsIdentity || rectangle.Equals(default))
416416
{
417417
bounds = default;
418418
return false;
@@ -439,7 +439,7 @@ private static bool TryGetTransformedRectangle(RectangleF rectangle, Matrix3x2 m
439439
[MethodImpl(MethodImplOptions.AggressiveInlining)]
440440
private static bool TryGetTransformedRectangle(RectangleF rectangle, Matrix4x4 matrix, out Rectangle bounds)
441441
{
442-
if (rectangle.Equals(default) || Matrix4x4.Identity.Equals(matrix))
442+
if (matrix.IsIdentity || rectangle.Equals(default))
443443
{
444444
bounds = default;
445445
return false;

0 commit comments

Comments
 (0)