]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fixed problem with jpegs with icc profile and acrobat reader 5 (Bug #11301)
authorKeiron Liddle <keiron@apache.org>
Wed, 13 Nov 2002 08:25:59 +0000 (08:25 +0000)
committerKeiron Liddle <keiron@apache.org>
Wed, 13 Nov 2002 08:25:59 +0000 (08:25 +0000)
Submitted by: Stephan Neuhaus <stephan.neuhaus@myview.de>
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

index 62b64bac1798c08579dbfbe096133a3ac9c66bf7..5673b0015456597ac9d5ddd548820b7912ffedbc 100644 (file)
@@ -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;
     }