From 9b0212dfcc5bbd606b41f5361b29bf1f9ca569b3 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Thu, 21 Feb 2008 08:19:53 +0000 Subject: [PATCH] Hotfix for 0.93: Avoid NPE when ICC Profile is present but can, for some reason, not be loaded. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_93@629714 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/image/JpegImage.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/java/org/apache/fop/image/JpegImage.java b/src/java/org/apache/fop/image/JpegImage.java index d67816cff..8318d0d25 100644 --- a/src/java/org/apache/fop/image/JpegImage.java +++ b/src/java/org/apache/fop/image/JpegImage.java @@ -24,6 +24,7 @@ import java.awt.color.ICC_Profile; import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.ByteArrayOutputStream; + import org.apache.fop.util.CMYKColorSpace; /** @@ -188,19 +189,19 @@ public class JpegImage extends AbstractFopImage { } try { iccProfile = ICC_Profile.getInstance(iccStream.toByteArray()); + if (iccProfile.getNumComponents() != this.colorSpace.getNumComponents()) { + log.warn("The number of components of the ICC profile (" + + iccProfile.getNumComponents() + + ") doesn't match the image (" + + this.colorSpace.getNumComponents() + + "). Ignoring the ICC color profile."); + this.iccProfile = null; + } } catch (IllegalArgumentException iae) { log.warn("An ICC profile is present but it is invalid (" + iae.getMessage() + "). The color profile will be ignored. (" + this.getOriginalURI() + ")"); } - if (iccProfile.getNumComponents() != this.colorSpace.getNumComponents()) { - log.warn("The number of components of the ICC profile (" - + iccProfile.getNumComponents() - + ") doesn't match the image (" - + this.colorSpace.getNumComponents() - + "). Ignoring the ICC color profile."); - this.iccProfile = null; - } } else if (this.colorSpace == null) { log.error("ColorSpace not specified for JPEG image"); return false; -- 2.39.5