From 7e55d7765d25362f2c46f7f2eee4e8425e824a14 Mon Sep 17 00:00:00 2001 From: Harald Kuhr Date: Fri, 10 Jul 2020 19:29:50 +0200 Subject: [PATCH] #550 Adobe path points now constrained to a more robust [-16...16] range --- .../imageio/path/AdobePathSegment.java | 4 +-- .../imageio/path/AdobePathSegmentTest.java | 36 ++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/AdobePathSegment.java b/imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/AdobePathSegment.java index 739e219d..bad9c479 100755 --- a/imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/AdobePathSegment.java +++ b/imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/AdobePathSegment.java @@ -107,8 +107,8 @@ final class AdobePathSegment { case OPEN_SUBPATH_BEZIER_LINKED: case OPEN_SUBPATH_BEZIER_UNLINKED: isTrue( - cppx >= 0 && cppx <= 1 && cppy >= 0 && cppy <= 1, - String.format("Expected point in range [0...1]: (%f, %f)", cppx ,cppy) + cppx >= -16 && cppx <= 16 && cppy >= -16 && cppy <= 16, + String.format("Expected point in range [-16...16]: (%f, %f)", cppx ,cppy) ); break; case PATH_FILL_RULE_RECORD: diff --git a/imageio/imageio-clippath/src/test/java/com/twelvemonkeys/imageio/path/AdobePathSegmentTest.java b/imageio/imageio-clippath/src/test/java/com/twelvemonkeys/imageio/path/AdobePathSegmentTest.java index 7b4827e4..27988541 100644 --- a/imageio/imageio-clippath/src/test/java/com/twelvemonkeys/imageio/path/AdobePathSegmentTest.java +++ b/imageio/imageio-clippath/src/test/java/com/twelvemonkeys/imageio/path/AdobePathSegmentTest.java @@ -113,8 +113,13 @@ public class AdobePathSegmentTest { } @Test(expected = IllegalArgumentException.class) - public void testCreateOpenLinkedRecordNegative() { - new AdobePathSegment(AdobePathSegment.OPEN_SUBPATH_BEZIER_LINKED, -.5, -.5, 0, 0, 1, 1); + public void testCreateOpenLinkedRecordOutOfRangeNegative() { + new AdobePathSegment(AdobePathSegment.OPEN_SUBPATH_BEZIER_LINKED, -16.1, -16.1, 0, 0, 1, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void testCreateOpenLinkedRecordOutOfRangePositive() { + new AdobePathSegment(AdobePathSegment.OPEN_SUBPATH_BEZIER_LINKED, 16.1, 16.1, 0, 0, 1, 1); } @Test @@ -138,8 +143,13 @@ public class AdobePathSegmentTest { @Test(expected = IllegalArgumentException.class) - public void testCreateOpenUnlinkedRecordNegative() { - new AdobePathSegment(AdobePathSegment.OPEN_SUBPATH_BEZIER_UNLINKED, -.5, -.5, 0, 0, 1, 1); + public void testCreateOpenUnlinkedRecordOutOfRangeNegative() { + new AdobePathSegment(AdobePathSegment.OPEN_SUBPATH_BEZIER_UNLINKED, -16.5, 0, 0, 0, 1, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void testCreateOpenUnlinkedRecorOutOfRangePositive() { + new AdobePathSegment(AdobePathSegment.OPEN_SUBPATH_BEZIER_UNLINKED, 0, -17, 0, 0, 16.5, 1); } /// Closed subpath @@ -164,8 +174,13 @@ public class AdobePathSegmentTest { } @Test(expected = IllegalArgumentException.class) - public void testCreateClosedLinkedRecordNegative() { - new AdobePathSegment(AdobePathSegment.CLOSED_SUBPATH_BEZIER_LINKED, -.5, -.5, 0, 0, 1, 1); + public void testCreateClosedLinkedRecordOutOfRangeNegative() { + new AdobePathSegment(AdobePathSegment.CLOSED_SUBPATH_BEZIER_LINKED, -16.5, -.5, 0, 0, 1, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void testCreateClosedLinkedRecordOutOfRangePositive() { + new AdobePathSegment(AdobePathSegment.CLOSED_SUBPATH_BEZIER_LINKED, .5, 16.5, 0, 0, 1, 1); } @Test @@ -189,8 +204,13 @@ public class AdobePathSegmentTest { @Test(expected = IllegalArgumentException.class) - public void testCreateClosedUnlinkedRecordNegative() { - new AdobePathSegment(AdobePathSegment.CLOSED_SUBPATH_BEZIER_UNLINKED, -.5, -.5, 0, 0, 1, 1); + public void testCreateClosedUnlinkedRecordOutOfRangeNegative() { + new AdobePathSegment(AdobePathSegment.CLOSED_SUBPATH_BEZIER_UNLINKED, -.5, -16.5, 0, 0, 1, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void testCreateClosedUnlinkedRecordOutOfRangePositive() { + new AdobePathSegment(AdobePathSegment.CLOSED_SUBPATH_BEZIER_UNLINKED, 16.5, .5, 0, 0, 1, 1); } @Test