]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Hotfix for 0.93: fop-0_93 fop-0_93
authorJeremias Maerki <jeremias@apache.org>
Thu, 21 Feb 2008 08:19:53 +0000 (08:19 +0000)
committerJeremias Maerki <jeremias@apache.org>
Thu, 21 Feb 2008 08:19:53 +0000 (08:19 +0000)
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

index d67816cffa3b5a8a3713c3c12df151968699cdf0..8318d0d25166873e4d80f469435399ccc6198f79 100644 (file)
@@ -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;