From 166214c4697af1e074757f44afe693db2b1d3523 Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Wed, 13 Nov 2002 08:25:59 +0000 Subject: [PATCH] Fixed problem with jpegs with icc profile and acrobat reader 5 (Bug #11301) Submitted by: Stephan Neuhaus changed so that java ICC profile could load it and fixed some style errors git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195515 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/image/JpegImage.java | 59 ++++++++++++++++--------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/src/org/apache/fop/image/JpegImage.java b/src/org/apache/fop/image/JpegImage.java index 62b64bac1..5673b0015 100644 --- a/src/org/apache/fop/image/JpegImage.java +++ b/src/org/apache/fop/image/JpegImage.java @@ -29,14 +29,27 @@ import org.apache.fop.fo.FOUserAgent; * @see FopImage */ public class JpegImage extends AbstractFopImage { - ICC_Profile iccProfile = null; - boolean found_icc_profile = false; - boolean found_dimensions = false; - - public JpegImage(FopImage.ImageInfo imgReader) { - super(imgReader); + private ICC_Profile iccProfile = null; + private boolean found_icc_profile = false; + private boolean found_dimensions = false; + + /** + * Create a jpeg image with the info. + * + * @param imgInfo the image info for this jpeg + */ + public JpegImage(FopImage.ImageInfo imgInfo) { + super(imgInfo); } + /** + * Load the original jpeg data. + * This loads the original jpeg data and reads the color space, + * and icc profile if any. + * + * @param ua the user agent + * @return true if loaded false for any error + */ protected boolean loadOriginalData(FOUserAgent ua) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream iccStream = new ByteArrayOutputStream(); @@ -120,12 +133,8 @@ public class JpegImage extends AbstractFopImage { this.m_bitmaps[index + 2], this.m_bitmaps[index + 3]) + 2; - if (iccStream.size() == 0) - iccStream.write(this.m_bitmaps, - index + 18, chunkSize - 20); - else - iccStream.write(this.m_bitmaps, - index + 16, chunkSize - 18); + iccStream.write(this.m_bitmaps, + index + 18, chunkSize - 18); } @@ -141,9 +150,8 @@ public class JpegImage extends AbstractFopImage { } } } else { - ua.getLogger().error( "1 Error while loading image " + - "" + - " : JpegImage - Invalid JPEG Header."); + ua.getLogger().error("Error while loading " + + "JpegImage - Invalid JPEG Header."); return false; } if (iccStream.size() > 0) { @@ -151,20 +159,29 @@ public class JpegImage extends AbstractFopImage { try { iccStream.write(align); } catch (Exception e) { - ua.getLogger().error( "1 Error while loading image " + - "" + " : " + - e.getMessage(), e); + ua.getLogger().error("Error while loading image " + + " : " + + e.getMessage(), e); + return false; + } + try { + iccProfile = ICC_Profile.getInstance(iccStream.toByteArray()); + } catch (Exception e) { + ua.getLogger().error("Invalid ICC profile: " + e, e); return false; } - iccProfile = ICC_Profile.getInstance(iccStream.toByteArray()); } else if(this.m_colorSpace == null) { - ua.getLogger().error("ColorSpace not specified for image: " - + ""); + ua.getLogger().error("ColorSpace not specified for JPEG image"); return false; } return true; } + /** + * Get the ICC profile for this Jpeg image. + * + * @return the icc profile or null if not found + */ public ICC_Profile getICCProfile() { return iccProfile; } -- 2.39.5