diff options
author | Jeremias Maerki <jeremias@apache.org> | 2007-11-09 08:33:52 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2007-11-09 08:33:52 +0000 |
commit | 41fa630a2490ca6f39c9b6567459fb9fefbffcbc (patch) | |
tree | 5eae75642799df42a406252ea01c80a016d47ed2 /src/java/org/apache/fop/image | |
parent | 38b57688e03dabc7e72d3d547dc1dd52e2a21ac5 (diff) | |
download | xmlgraphics-fop-41fa630a2490ca6f39c9b6567459fb9fefbffcbc.tar.gz xmlgraphics-fop-41fa630a2490ca6f39c9b6567459fb9fefbffcbc.zip |
Bugfix: An invalid PDF was created if a grayscale JPEG image with an sRGB profile was embedded undecoded. I didn't find any other way than to disable the the ICC profile in this case.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@593452 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/image')
-rw-r--r-- | src/java/org/apache/fop/image/JpegImage.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/java/org/apache/fop/image/JpegImage.java b/src/java/org/apache/fop/image/JpegImage.java index 658d48286..1de6b0d48 100644 --- a/src/java/org/apache/fop/image/JpegImage.java +++ b/src/java/org/apache/fop/image/JpegImage.java @@ -19,11 +19,9 @@ package org.apache.fop.image; -// Java import java.awt.color.ColorSpace; import java.awt.color.ICC_Profile; -// FOP import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.fop.util.CMYKColorSpace; @@ -100,13 +98,14 @@ public class JpegImage extends AbstractFopImage { this.width = calcBytes(this.raw[index + 7], this.raw[index + 8]); - if (this.raw[index + 9] == 1) { + int numComponents = this.raw[index + 9]; + if (numComponents == 1) { this.colorSpace = ColorSpace.getInstance( ColorSpace.CS_GRAY); - } else if (this.raw[index + 9] == 3) { + } else if (numComponents == 3) { this.colorSpace = ColorSpace.getInstance( ColorSpace.CS_LINEAR_RGB); - } else if (this.raw[index + 9] == 4) { + } else if (numComponents == 4) { // howto create CMYK color space /* this.colorSpace = ColorSpace.getInstance( @@ -194,6 +193,14 @@ public class JpegImage extends AbstractFopImage { + 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; |