keiron      2002/11/13 00:25:59

  Modified:    src/org/apache/fop/image JpegImage.java
  Log:
  Fixed problem with jpegs with icc profile and acrobat reader 5 (Bug #11301)
  Submitted by: Stephan Neuhaus <[EMAIL PROTECTED]>
  changed so that java ICC profile could load it
  and fixed some style errors
  
  Revision  Changes    Path
  1.10      +39 -22    xml-fop/src/org/apache/fop/image/JpegImage.java
  
  Index: JpegImage.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/JpegImage.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JpegImage.java    8 Nov 2002 10:47:59 -0000       1.9
  +++ JpegImage.java    13 Nov 2002 08:25:59 -0000      1.10
  @@ -29,14 +29,27 @@
    * @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 @@
                                                 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 @@
                   }
               }
           } 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 @@
               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;
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to