Browse Source

Fix identity checks

pull/2748/head
James Jackson-South 2 years ago
parent
commit
4544742e34
  1. 7
      src/ImageSharp/Common/Helpers/QuadDistortionHelper.cs
  2. 8
      src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs

7
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:
/// <see href="https://blog.mbedded.ninja/mathematics/geometry/projective-transformations/"/>
/// </remarks>
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);

8
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
/// </returns>
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;

Loading…
Cancel
Save