From f588d65565cdc85299cd7446053329f460f206f9 Mon Sep 17 00:00:00 2001 From: Harald Kuhr Date: Tue, 6 Jan 2015 12:45:54 +0100 Subject: [PATCH] TMI-41: Fix for CorbisRGB special handling testcase JDK 1.7+ --- .../twelvemonkeys/imageio/color/ColorSpaces.java | 4 ++-- .../imageio/color/ColorSpacesTest.java | 14 +++++++++++--- .../test/resources/profiles/Corbis RGB_fixed.icc | Bin 420 -> 0 bytes 3 files changed, 13 insertions(+), 5 deletions(-) delete mode 100755 imageio/imageio-core/src/test/resources/profiles/Corbis RGB_fixed.icc diff --git a/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/color/ColorSpaces.java b/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/color/ColorSpaces.java index ae0a72dd..c5fcb337 100644 --- a/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/color/ColorSpaces.java +++ b/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/color/ColorSpaces.java @@ -141,7 +141,7 @@ public final class ColorSpaces { // Special handling to detect problematic Corbis RGB ICC Profile. // This makes sure tags that are expected to be of type 'XYZ ' really have this expected type. // Should leave other ICC profiles unchanged. - if (fixProfileXYZTag(profile, ICC_Profile.icSigMediaWhitePointTag)) { + if (!JDK_HANDLES_RENDERING_INTENTS && fixProfileXYZTag(profile, ICC_Profile.icSigMediaWhitePointTag)) { fixProfileXYZTag(profile, ICC_Profile.icSigRedColorantTag); fixProfileXYZTag(profile, ICC_Profile.icSigGreenColorantTag); fixProfileXYZTag(profile, ICC_Profile.icSigBlueColorantTag); @@ -156,7 +156,7 @@ public final class ColorSpaces { * @return {@code true} if found and fixed, otherwise {@code false} for short-circuiting * to avoid unnecessary array copying. */ - private static boolean fixProfileXYZTag(ICC_Profile profile, final int tagSignature) { + private static boolean fixProfileXYZTag(final ICC_Profile profile, final int tagSignature) { // TODO: This blows up on OpenJDK... Bug? byte[] data = profile.getData(tagSignature); diff --git a/imageio/imageio-core/src/test/java/com/twelvemonkeys/imageio/color/ColorSpacesTest.java b/imageio/imageio-core/src/test/java/com/twelvemonkeys/imageio/color/ColorSpacesTest.java index 6f7cd126..e1b9fafb 100644 --- a/imageio/imageio-core/src/test/java/com/twelvemonkeys/imageio/color/ColorSpacesTest.java +++ b/imageio/imageio-core/src/test/java/com/twelvemonkeys/imageio/color/ColorSpacesTest.java @@ -34,6 +34,7 @@ import java.awt.color.ColorSpace; import java.awt.color.ICC_ColorSpace; import java.awt.color.ICC_Profile; import java.io.IOException; +import java.util.Arrays; import static org.junit.Assert.*; @@ -45,6 +46,9 @@ import static org.junit.Assert.*; * @version $Id: ColorSpacesTest.java,v 1.0 07.02.11 14.32 haraldk Exp$ */ public class ColorSpacesTest { + + private static final byte[] XYZ = new byte[] {'X', 'Y', 'Z', ' '}; + @Test public void testCreateColorSpaceFromKnownProfileReturnsInternalCS_sRGB() { ICC_Profile profile = ICC_Profile.getInstance(ColorSpace.CS_sRGB); @@ -189,11 +193,15 @@ public class ColorSpacesTest { @Test public void testCorbisRGBSpecialHandling() throws IOException { ICC_Profile corbisRGB = ICC_Profile.getInstance(getClass().getResourceAsStream("/profiles/Corbis RGB.icc")); - ICC_Profile corbisRGBFixed = ICC_Profile.getInstance(getClass().getResourceAsStream("/profiles/Corbis RGB_fixed.icc")); - ICC_ColorSpace colorSpace = ColorSpaces.createColorSpace(corbisRGB); assertNotNull(colorSpace); - assertArrayEquals(colorSpace.getProfile().getData(), corbisRGBFixed.getData()); + + // Make sure all known affected tags have type 'XYZ ' + ICC_Profile profile = colorSpace.getProfile(); + assertArrayEquals(XYZ, Arrays.copyOfRange(profile.getData(ICC_Profile.icSigMediaWhitePointTag), 0, 4)); + assertArrayEquals(XYZ, Arrays.copyOfRange(profile.getData(ICC_Profile.icSigRedColorantTag), 0, 4)); + assertArrayEquals(XYZ, Arrays.copyOfRange(profile.getData(ICC_Profile.icSigGreenColorantTag), 0, 4)); + assertArrayEquals(XYZ, Arrays.copyOfRange(profile.getData(ICC_Profile.icSigBlueColorantTag), 0, 4)); } } diff --git a/imageio/imageio-core/src/test/resources/profiles/Corbis RGB_fixed.icc b/imageio/imageio-core/src/test/resources/profiles/Corbis RGB_fixed.icc deleted file mode 100755 index f6293449d7309e0a23c9a950183c81a769e6d9cb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 420 zcmZQzU|f<|P>{pKz`&53S5g$@?xYYA8KuB}j)8|kkU@aKn1L}dxwybFAixKxgaM=$ zM5BUlR~Z;VBA0c5#0OM4f;`S5poLIKW0_kl4vQb35l3 tC1n;X0D~0FhY)C@C8-raw=pniBx@=dT3T8tKs5oWg8ZVylFa-(1_07+OsW6?