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 f6293449..00000000 Binary files a/imageio/imageio-core/src/test/resources/profiles/Corbis RGB_fixed.icc and /dev/null differ