Skip to content

Commit f8546cb

Browse files
Yuri NesterenkoRealCLanger
authored andcommitted
8320097: Improve Image transformations
Reviewed-by: mbalao Backport-of: 1401634b21b76db90291011bcae68c461742e687
1 parent 7f9ba72 commit f8546cb

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/java.desktop/share/classes/sun/java2d/pipe/DrawImage.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -369,6 +369,13 @@ protected void renderImageXform(SunGraphics2D sg, Image img,
369369
final AffineTransform itx;
370370
try {
371371
itx = tx.createInverse();
372+
double[] mat = new double[6];
373+
itx.getMatrix(mat);
374+
for (double d : mat) {
375+
if (!Double.isFinite(d)) {
376+
return;
377+
}
378+
}
372379
} catch (final NoninvertibleTransformException ignored) {
373380
// Non-invertible transform means no output
374381
return;

src/java.desktop/share/native/libawt/java2d/loops/TransformHelper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -120,7 +120,7 @@ TransformInterpFunc *pBicubicFunc = BicubicInterp;
120120
/* We reject coordinates not less than 1<<30 so that the distance between */
121121
/* any 2 of them is less than 1<<31 which would overflow into the sign */
122122
/* bit of a signed long value used to represent fixed point coordinates. */
123-
#define TX_FIXED_UNSAFE(v) (fabs(v) >= (1<<30))
123+
#define TX_FIXED_UNSAFE(v) (isinf(v) || isnan(v) || fabs(v) >= (1<<30))
124124
static jboolean
125125
checkOverflow(jint dxoff, jint dyoff,
126126
SurfaceDataBounds *pBounds,

0 commit comments

Comments
 (0)