keiron      2002/11/14 07:19:42

  Modified:    src/org/apache/fop/image AbstractFopImage.java BmpImage.java
                        EPSImage.java FopImage.java FopImageConsumer.java
                        GifImage.java ImageCache.java ImageFactory.java
                        JAIImage.java JimiImage.java JpegImage.java
               src/org/apache/fop/image/analyser SVGReader.java
  Log:
  some cleanup of comments and code
  
  Revision  Changes    Path
  1.15      +77 -34    xml-fop/src/org/apache/fop/image/AbstractFopImage.java
  
  Index: AbstractFopImage.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/AbstractFopImage.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AbstractFopImage.java     8 Nov 2002 10:47:58 -0000       1.14
  +++ AbstractFopImage.java     14 Nov 2002 15:19:41 -0000      1.15
  @@ -1,6 +1,6 @@
   /*
    * $Id$
  - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
    */
  @@ -8,15 +8,12 @@
   package org.apache.fop.image;
   
   // Java
  -import java.net.URL;
   import java.awt.color.ColorSpace;
   import java.awt.color.ICC_Profile;
   import java.io.InputStream;
   
   // FOP
   import org.apache.fop.pdf.PDFColor;
  -import org.apache.fop.image.analyser.ImageReaderFactory;
  -import org.apache.fop.image.analyser.ImageReader;
   import org.apache.fop.fo.FOUserAgent;
   
   /**
  @@ -26,17 +23,20 @@
    * @see FopImage
    */
   public abstract class AbstractFopImage implements FopImage {
  +    /**
  +     * Keeps track of what has been loaded.
  +     */
       protected int loaded = 0;
   
       /**
        * Image width (in pixel).
        */
  -    protected int m_width = 0;
  +    protected int width = 0;
   
       /**
        * Image height (in pixel).
        */
  -    protected int m_height = 0;
  +    protected int height = 0;
   
       /**
        * Image input stream.
  @@ -51,32 +51,32 @@
       /**
        * Image color space (java.awt.color.ColorSpace).
        */
  -    protected ColorSpace m_colorSpace = null;
  +    protected ColorSpace colorSpace = null;
   
       /**
        * Bits per pixel.
        */
  -    protected int m_bitsPerPixel = 0;
  +    protected int bitsPerPixel = 0;
   
       /**
        * Image data (uncompressed).
        */
  -    protected byte[] m_bitmaps = null;
  +    protected byte[] bitmaps = null;
   
       /**
        * Image data size.
        */
  -    protected int m_bitmapsSize = 0;
  +    protected int bitmapsSize = 0;
   
       /**
        * Image transparency.
        */
  -    protected boolean m_isTransparent = false;
  +    protected boolean isTransparent = false;
   
       /**
        * Transparent color (org.apache.fop.pdf.PDFColor).
        */
  -    protected PDFColor m_transparentColor = null;
  +    protected PDFColor transparentColor = null;
   
       /**
        * Constructor.
  @@ -86,63 +86,94 @@
        * <LI>image height
        * </UL>
        * The image data isn't kept in memory.
  -     * @param input input stream
  -     * imgReader ImageReader object
  -     * @return a new FopImage object
  +     * @param info image information
        */
       public AbstractFopImage(FopImage.ImageInfo info) {
           this.inputStream = info.inputStream;
           this.imageInfo = info;
  -        if(this.imageInfo.width != -1) {
  -            m_width = imageInfo.width;
  -            m_height = imageInfo.height;
  +        if (this.imageInfo.width != -1) {
  +            width = imageInfo.width;
  +            height = imageInfo.height;
               loaded = loaded | DIMENSIONS;
           }
       }
   
  +    /**
  +     * Get the mime type for this image.
  +     *
  +     * @return the mime type for the image
  +     */
       public String getMimeType() {
           return imageInfo.mimeType;
       }
   
       /**
        * Load image data and initialize its properties.
  +     *
  +     * @param type the type of loading to do
  +     * @param ua the user agent for handling logging etc.
  +     * @return true if the loading was successful
        */
       public synchronized boolean load(int type, FOUserAgent ua) {
  -        if((loaded & type) != 0) {
  +        if ((loaded & type) != 0) {
               return true;
           }
           boolean success = true;
  -        if(((type & DIMENSIONS) != 0) && ((loaded & DIMENSIONS) == 0)) {
  +        if (((type & DIMENSIONS) != 0) && ((loaded & DIMENSIONS) == 0)) {
               success = success && loadDimensions(ua);
   
  -            if(!success) {
  +            if (!success) {
                   return false;
               }
               loaded = loaded | DIMENSIONS;
           }
  -        if(((type & BITMAP) != 0) && ((loaded & BITMAP) == 0)) {
  +        if (((type & BITMAP) != 0) && ((loaded & BITMAP) == 0)) {
               success = success && loadBitmap(ua);
  -            if(success) {
  +            if (success) {
                   loaded = loaded | BITMAP;
               }
           }
  -        if(((type & ORIGINAL_DATA) != 0) && ((loaded & ORIGINAL_DATA) == 0)) {
  +        if (((type & ORIGINAL_DATA) != 0) && ((loaded & ORIGINAL_DATA) == 0)) {
               success = success && loadOriginalData(ua);
  -            if(success) {
  +            if (success) {
                   loaded = loaded | ORIGINAL_DATA;
               }
           }
           return success;
       }
   
  +    /**
  +     * Load the dimensions of the image.
  +     * All implementations should override this to get and
  +     * return the dimensions.
  +     *
  +     * @param ua the user agent
  +     * @return true if the loading was successful
  +     */
       protected boolean loadDimensions(FOUserAgent ua) {
           return false;
       }
   
  +    /**
  +     * Load a bitmap array of the image.
  +     * If the renderer requires a bitmap image then the
  +     * implementations should override this to load the bitmap.
  +     * 
  +     * @param ua the user agent
  +     * @return true if the loading was successful
  +     */
       protected boolean loadBitmap(FOUserAgent ua) {
           return false;
       }
   
  +    /**
  +     * Load the original image data.
  +     * In some cases the original data can be used by the renderer.
  +     * This should load the data and any other associated information. 
  +     *
  +     * @param ua the user agent
  +     * @return true if the loading was successful
  +     */
       protected boolean loadOriginalData(FOUserAgent ua) {
           return false;
       }
  @@ -152,7 +183,7 @@
        * @return the image width
        */
       public int getWidth() {
  -        return this.m_width;
  +        return this.width;
       }
   
       /**
  @@ -160,7 +191,7 @@
        * @return the image height
        */
       public int getHeight() {
  -        return this.m_height;
  +        return this.height;
       }
   
       /**
  @@ -168,11 +199,12 @@
        * @return the image color space (java.awt.color.ColorSpace)
        */
       public ColorSpace getColorSpace() {
  -        return this.m_colorSpace;
  +        return this.colorSpace;
       }
   
       /**
        * Get ICC profile for this image.
  +     * @return the icc profile or null if not applicable
        */
       public ICC_Profile getICCProfile() {
           return null;
  @@ -183,7 +215,7 @@
        * @return number of bits per pixel
        */
       public int getBitsPerPixel() {
  -        return this.m_bitsPerPixel;
  +        return this.bitsPerPixel;
       }
   
       /**
  @@ -191,13 +223,24 @@
        * @return true if the image is transparent
        */
       public boolean isTransparent() {
  -        return this.m_isTransparent;
  +        return this.isTransparent;
       }
   
  +    /**
  +     * Check if this image has a soft mask.
  +     *
  +     * @return true if the image also has a soft transparency mask
  +     */
       public boolean hasSoftMask() {
           return false;
       }
   
  +    /**
  +     * Get the soft mask.
  +     * The soft mask should have the same bitdepth as the image data.
  +     *
  +     * @return the data array of soft mask values
  +     */
       public byte[] getSoftMask() {
           return null;
       }
  @@ -207,7 +250,7 @@
        * @return the transparent color (org.apache.fop.pdf.PDFColor)
        */
       public PDFColor getTransparentColor() {
  -        return this.m_transparentColor;
  +        return this.transparentColor;
       }
   
       /**
  @@ -215,7 +258,7 @@
        * @return the image data
        */
       public byte[] getBitmaps() {
  -        return this.m_bitmaps;
  +        return this.bitmaps;
       }
   
       /**
  @@ -223,7 +266,7 @@
        * @return the image data size
        */
       public int getBitmapsSize() {
  -        return this.m_bitmapsSize;
  +        return this.bitmapsSize;
       }
   
       /**
  
  
  
  1.9       +73 -60    xml-fop/src/org/apache/fop/image/BmpImage.java
  
  Index: BmpImage.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/BmpImage.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BmpImage.java     8 Nov 2002 10:47:59 -0000       1.8
  +++ BmpImage.java     14 Nov 2002 15:19:41 -0000      1.9
  @@ -1,34 +1,44 @@
   /*
    * $Id$
  - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
    */
   
  -/**
  - * FopImage object for BMP images.
  - * @author Art WELCH
  - * @see AbstractFopImage
  - * @see FopImage
  - */
  -
   package org.apache.fop.image;
   
   // Java
  -import java.net.URL;
  -import java.io.InputStream;
   import java.io.IOException;
   import java.awt.color.ColorSpace;
   
   // FOP
  -import org.apache.fop.image.analyser.ImageReader;
   import org.apache.fop.fo.FOUserAgent;
   
  +/**
  + * Bitmap image.
  + * This supports loading a bitmap image into bitmap data.
  + *
  + * @author Art WELCH
  + * @see AbstractFopImage
  + * @see FopImage
  + */
   public class BmpImage extends AbstractFopImage {
  -    public BmpImage(FopImage.ImageInfo imgReader) {
  -        super(imgReader);
  +    /**
  +     * Create a bitmap image with the image data.
  +     *
  +     * @param imgInfo the image information
  +     */
  +    public BmpImage(FopImage.ImageInfo imgInfo) {
  +        super(imgInfo);
       }
   
  +    /**
  +     * Load the bitmap.
  +     * This laods the bitmap data from the bitmap image.
  +     *
  +     * @param ua the user agent
  +     * @return true if it was loaded successfully
  +     */
       protected boolean loadBitmap(FOUserAgent ua) {
           int wpos = 18;
           int hpos = 22; // offset positioning for w and height in  bmp files
  @@ -39,10 +49,11 @@
               boolean eof = false;
               while ((!eof) && (filepos < 54)) {
                   int input = inputStream.read();
  -                if (input == -1)
  +                if (input == -1) {
                       eof = true;
  -                else
  +                } else {
                       headermap[filepos++] = input;
  +                }
               }
   
               if (headermap[28] == 4 || headermap[28] == 8) {
  @@ -53,9 +64,9 @@
                       int count2 = 2;
                       while (!eof && count2 >= -1) {
                           int input = inputStream.read();
  -                        if (input == -1)
  +                        if (input == -1) {
                               eof = true;
  -                        else if (count2 >= 0) {
  +                        } else if (count2 >= 0) {
                               palette[countr * 3 + count2] =
                                 (byte)(input & 0xFF);
                           }
  @@ -73,27 +84,27 @@
               return false;
           }
           // gets h & w from headermap
  -        this.m_width = headermap[wpos] + headermap[wpos + 1] * 256 +
  +        this.width = headermap[wpos] + headermap[wpos + 1] * 256 +
                          headermap[wpos + 2] * 256 * 256 +
                          headermap[wpos + 3] * 256 * 256 * 256;
  -        this.m_height = headermap[hpos] + headermap[hpos + 1] * 256 +
  +        this.height = headermap[hpos] + headermap[hpos + 1] * 256 +
                           headermap[hpos + 2] * 256 * 256 +
                           headermap[hpos + 3] * 256 * 256 * 256;
   
           int imagestart = headermap[10] + headermap[11] * 256 +
                            headermap[12] * 256 * 256 + headermap[13] * 256 * 256 * 
256;
  -        this.m_bitsPerPixel = headermap[28];
  -        this.m_colorSpace = ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
  +        this.bitsPerPixel = headermap[28];
  +        this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
           int bytes = 0;
  -        if (this.m_bitsPerPixel == 1)
  -            bytes = (this.m_width + 7) / 8;
  -        else if (this.m_bitsPerPixel == 24)
  -            bytes = this.m_width * 3;
  -        else if (this.m_bitsPerPixel == 4 || this.m_bitsPerPixel == 8)
  -            bytes = this.m_width / (8 / this.m_bitsPerPixel);
  +        if (this.bitsPerPixel == 1)
  +            bytes = (this.width + 7) / 8;
  +        else if (this.bitsPerPixel == 24)
  +            bytes = this.width * 3;
  +        else if (this.bitsPerPixel == 4 || this.bitsPerPixel == 8)
  +            bytes = this.width / (8 / this.bitsPerPixel);
           else {
               ua.getLogger().error("Image (" + ""
  -                                         + ") has " + this.m_bitsPerPixel
  +                                         + ") has " + this.bitsPerPixel
                                            + " which is not a supported BMP format.");
               return false;
           }
  @@ -103,10 +114,10 @@
           }
   
           // Should take care of the ColorSpace and bitsPerPixel
  -        this.m_bitmapsSize = this.m_width * this.m_height * 3;
  -        this.m_bitmaps = new byte[this.m_bitmapsSize];
  +        this.bitmapsSize = this.width * this.height * 3;
  +        this.bitmaps = new byte[this.bitmapsSize];
   
  -        int[] temp = new int[bytes * this.m_height];
  +        int[] temp = new int[bytes * this.height];
           try {
               int input;
               int count = 0;
  @@ -123,67 +134,67 @@
               return false;
           }
   
  -        for (int i = 0; i < this.m_height; i++) {
  +        for (int i = 0; i < this.height; i++) {
               int x = 0;
               int j = 0;
               while (j < bytes) {
  -                int p = temp[(this.m_height - i - 1) * bytes + j];
  +                int p = temp[(this.height - i - 1) * bytes + j];
   
  -                if (this.m_bitsPerPixel == 24 && x < this.m_width) {
  +                if (this.bitsPerPixel == 24 && x < this.width) {
                       int countr = 2;
                       do {
  -                        this.m_bitmaps[3 * (i * this.m_width + x) +
  +                        this.bitmaps[3 * (i * this.width + x) +
                                          countr] =
  -                                         (byte)(temp[(this.m_height - i - 1) *
  +                                         (byte)(temp[(this.height - i - 1) *
                                                        bytes + j] & 0xFF);
                           j++;
                       } while (--countr >= 0)
                           ;
                       x++;
  -                } else if (this.m_bitsPerPixel == 1) {
  +                } else if (this.bitsPerPixel == 1) {
                       for (int countr = 0;
  -                            countr < 8 && x < this.m_width; countr++) {
  +                            countr < 8 && x < this.width; countr++) {
                           if ((p & 0x80) != 0) {
  -                            this.m_bitmaps[3 *
  -                                           (i * this.m_width + x)] = (byte) 0xFF;
  -                            this.m_bitmaps[3 * (i * this.m_width + x) +
  +                            this.bitmaps[3 *
  +                                           (i * this.width + x)] = (byte) 0xFF;
  +                            this.bitmaps[3 * (i * this.width + x) +
                                              1] = (byte) 0xFF;
  -                            this.m_bitmaps[3 * (i * this.m_width + x) +
  +                            this.bitmaps[3 * (i * this.width + x) +
                                              2] = (byte) 0xFF;
                           } else {
  -                            this.m_bitmaps[3 *
  -                                           (i * this.m_width + x)] = (byte) 0;
  -                            this.m_bitmaps[3 * (i * this.m_width + x) +
  +                            this.bitmaps[3 *
  +                                           (i * this.width + x)] = (byte) 0;
  +                            this.bitmaps[3 * (i * this.width + x) +
                                              1] = (byte) 0;
  -                            this.m_bitmaps[3 * (i * this.m_width + x) +
  +                            this.bitmaps[3 * (i * this.width + x) +
                                              2] = (byte) 0;
                           }
                           p <<= 1;
                           x++;
                       }
                       j++;
  -                } else if (this.m_bitsPerPixel == 4) {
  +                } else if (this.bitsPerPixel == 4) {
                       for (int countr = 0;
  -                            countr < 2 && x < this.m_width; countr++) {
  +                            countr < 2 && x < this.width; countr++) {
                           int pal = ((p & 0xF0) >> 4) * 3;
  -                        this.m_bitmaps[3 * (i * this.m_width + x)] =
  +                        this.bitmaps[3 * (i * this.width + x)] =
                             palette[pal];
  -                        this.m_bitmaps[3 * (i * this.m_width + x) +
  +                        this.bitmaps[3 * (i * this.width + x) +
                                          1] = palette[pal + 1];
  -                        this.m_bitmaps[3 * (i * this.m_width + x) +
  +                        this.bitmaps[3 * (i * this.width + x) +
                                          2] = palette[pal + 2];
                           p <<= 4;
                           x++;
                       }
                       j++;
  -                } else if (this.m_bitsPerPixel == 8) {
  -                    if (x < this.m_width) {
  +                } else if (this.bitsPerPixel == 8) {
  +                    if (x < this.width) {
                           p *= 3;
  -                        this.m_bitmaps[3 * (i * this.m_width + x)] =
  +                        this.bitmaps[3 * (i * this.width + x)] =
                             palette[p];
  -                        this.m_bitmaps[3 * (i * this.m_width + x) +
  +                        this.bitmaps[3 * (i * this.width + x) +
                                          1] = palette[p + 1];
  -                        this.m_bitmaps[3 * (i * this.m_width + x) +
  +                        this.bitmaps[3 * (i * this.width + x) +
                                          2] = palette[p + 2];
                           j++;
                           x++;
  @@ -194,12 +205,14 @@
               }
           }
   
  -        // This seems really strange to me, but I noticed that JimiImage hardcodes
  -        // m_bitsPerPixel to 8. If I do not do this Acrobat is unable to read the 
resultant PDF,
  +        // This seems really strange to me, but I noticed that
  +        // JimiImage hardcodes bitsPerPixel to 8. If I do not
  +        // do this Acrobat is unable to read the resultant PDF,
           // so we will hardcode this...
  -        this.m_bitsPerPixel = 8;
  +        this.bitsPerPixel = 8;
   
           return true;
       }
   
   }
  +
  
  
  
  1.10      +38 -32    xml-fop/src/org/apache/fop/image/EPSImage.java
  
  Index: EPSImage.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/EPSImage.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- EPSImage.java     8 Nov 2002 10:47:59 -0000       1.9
  +++ EPSImage.java     14 Nov 2002 15:19:41 -0000      1.10
  @@ -1,28 +1,18 @@
   /*
    * $Id$
  - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
    */
   
   package org.apache.fop.image;
   
  -// Java
  -import java.net.URL;
  -import java.net.URLConnection;
  -import java.io.InputStream;
  -import java.io.IOException;
  -
  -// FOP
  -import org.apache.fop.apps.Driver;
  -import org.apache.fop.image.analyser.ImageReader;
  -import org.apache.fop.image.analyser.EPSReader;
  -
  -import org.xml.sax.InputSource;
  -import org.xml.sax.XMLReader;
  -
   
   /**
  + * EPS image handler.
  + * This handles the Encapulated PostScript images.
  + * It gets the dimensions and original data from the analyser.
  + *
    * @see AbstractFopImage
    * @see FopImage
    */
  @@ -33,7 +23,28 @@
       private EPSData epsData = null;
   
       /**
  -     * Initialize docName and bounding box
  +     * Create an EPS image with the image information.
  +     *
  +     * @param imgInfo the information containing the data and bounding box
  +     */
  +    public EPSImage(FopImage.ImageInfo imgInfo) {
  +        super(imgInfo);
  +        init("");
  +        if (imgInfo.data instanceof EPSData) {
  +            epsData = (EPSData) imgInfo.data;
  +            bbox = new int[4];
  +            bbox[0] = (int) epsData.bbox[0];
  +            bbox[1] = (int) epsData.bbox[1];
  +            bbox[2] = (int) epsData.bbox[2];
  +            bbox[3] = (int) epsData.bbox[3];
  +
  +            loaded = loaded | ORIGINAL_DATA;
  +        }
  +    }
  +
  +    /**
  +     * Initialize docName and bounding box.
  +     * @param name the document name
        */
       private void init(String name) {
           bbox = new int[4];
  @@ -47,6 +58,7 @@
   
       /**
        * Return the name of the eps
  +     * @return the name of the eps
        */
       public String getDocName() {
           return docName;
  @@ -54,26 +66,17 @@
   
       /**
        * Return the bounding box
  +     * @return an int array containing the bounding box
        */
       public int[] getBBox() {
           return bbox;
       }
   
  -    public EPSImage(FopImage.ImageInfo imgInfo) {
  -        super(imgInfo);
  -        init("");
  -        if (imgInfo.data instanceof EPSData) {
  -            epsData = (EPSData) imgInfo.data;
  -            bbox = new int[4];
  -            bbox[0] = (int) epsData.bbox[0];
  -            bbox[1] = (int) epsData.bbox[1];
  -            bbox[2] = (int) epsData.bbox[2];
  -            bbox[3] = (int) epsData.bbox[3];
  -
  -            loaded = loaded | ORIGINAL_DATA;
  -        }
  -    }
  -
  +    /**
  +     * Get the eps image.
  +     *
  +     * @return the original eps image data
  +     */
       public byte[] getEPSImage() {
           if (epsData.epsFile == null) {
               //log.error("ERROR LOADING EXTERNAL EPS");
  @@ -81,6 +84,9 @@
           return epsData.epsFile;
       }
   
  +    /**
  +     * Data for EPS image.
  +     */
       public static class EPSData {
           public long[] bbox;
           public boolean isAscii; // True if plain ascii eps file
  
  
  
  1.14      +32 -5     xml-fop/src/org/apache/fop/image/FopImage.java
  
  Index: FopImage.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/FopImage.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- FopImage.java     8 Nov 2002 10:47:59 -0000       1.13
  +++ FopImage.java     14 Nov 2002 15:19:41 -0000      1.14
  @@ -1,13 +1,10 @@
   /*
    * $Id$
  - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
    */
   
  -// Author:       Eric SCHAEFFER
  -// Description:  represent an image object
  -
   package org.apache.fop.image;
   
   import java.io.InputStream;
  @@ -17,17 +14,43 @@
   import org.apache.fop.pdf.PDFColor;
   import org.apache.fop.fo.FOUserAgent;
   
  +/**
  + * Fop image interface for loading images.
  + *
  + * @author Eric SCHAEFFER
  + */
   public interface FopImage {
  +    /**
  +     * Flag for loading dimensions.
  +     */
       public static final int DIMENSIONS = 1;
  +
  +    /**
  +     * Flag for loading original data.
  +     */
       public static final int ORIGINAL_DATA = 2;
  +
  +    /**
  +     * Flag for loading bitmap data.
  +     */
       public static final int BITMAP = 4;
   
  +    /**
  +     * Get the mime type of this image.
  +     * This is used so that when reading from the image it knows
  +     * what type of image it is.
  +     *
  +     * @return the mime type string
  +     */
       public String getMimeType();
   
       /**
        * Load particular inforamtion for this image
        * This must be called before attempting to get
        * the information.
  +     *
  +     * @param type the type of loading required
  +     * @param ua the user agent
        * @return boolean true if the information could be loaded
        */
       public boolean load(int type, FOUserAgent ua);
  @@ -61,6 +84,10 @@
       public byte[] getRessourceBytes();
       public int getRessourceBytesSize();
   
  +    /**
  +     * Image info class.
  +     * Information loaded from analyser and passed to image object.
  +     */
       public static class ImageInfo {
           public InputStream inputStream;
           public int width;
  
  
  
  1.8       +2 -2      xml-fop/src/org/apache/fop/image/FopImageConsumer.java
  
  Index: FopImageConsumer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/FopImageConsumer.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FopImageConsumer.java     8 Nov 2002 10:47:59 -0000       1.7
  +++ FopImageConsumer.java     14 Nov 2002 15:19:41 -0000      1.8
  @@ -1,6 +1,6 @@
   /*
    * $Id$
  - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
    */
  
  
  
  1.6       +28 -27    xml-fop/src/org/apache/fop/image/GifImage.java
  
  Index: GifImage.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/GifImage.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- GifImage.java     8 Nov 2002 10:47:59 -0000       1.5
  +++ GifImage.java     14 Nov 2002 15:19:41 -0000      1.6
  @@ -8,12 +8,10 @@
   package org.apache.fop.image;
   
   // Java
  -import java.net.URL;
   import java.awt.image.ImageProducer;
   import java.awt.image.ColorModel;
   import java.awt.image.IndexColorModel;
   import java.awt.color.ColorSpace;
  -import java.io.InputStream;
   
   // FOP
   import org.apache.fop.pdf.PDFColor;
  @@ -41,6 +39,9 @@
               //ip = (ImageProducer) inputStream.getContent();
               inputStream.close();
               inputStream = null;
  +            if (ip == null) {
  +                return false;
  +            }
               FopImageConsumer consumer = new FopImageConsumer(ip);
               ip.startProduction(consumer);
   
  @@ -50,8 +51,8 @@
                   Thread.sleep(500);
               }
   
  -            this.m_height = consumer.getHeight();
  -            this.m_width = consumer.getWidth();
  +            this.height = consumer.getHeight();
  +            this.width = consumer.getWidth();
   
               try {
                   tmpMap = consumer.getImage();
  @@ -62,18 +63,18 @@
               }
   
               ColorModel cm = consumer.getColorModel();
  -            this.m_bitsPerPixel = 8;
  -            // this.m_bitsPerPixel = cm.getPixelSize();
  -            this.m_colorSpace = ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
  +            this.bitsPerPixel = 8;
  +            // this.bitsPerPixel = cm.getPixelSize();
  +            this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
               if (cm.hasAlpha()) {
                   int transparencyType = cm.getTransparency(); // 
java.awt.Transparency. BITMASK or OPAQUE or TRANSLUCENT
                   if (transparencyType == java.awt.Transparency.OPAQUE) {
  -                    this.m_isTransparent = false;
  +                    this.isTransparent = false;
                   } else if (transparencyType ==
                       java.awt.Transparency.BITMASK) {
                       if (cm instanceof IndexColorModel) {
                           IndexColorModel indexcm = (IndexColorModel) cm;
  -                        this.m_isTransparent = false;
  +                        this.isTransparent = false;
                           byte[] alphas = new byte[indexcm.getMapSize()];
                           byte[] reds = new byte[indexcm.getMapSize()];
                           byte[] greens = new byte[indexcm.getMapSize()];
  @@ -86,8 +87,8 @@
                                   i < indexcm.getMapSize();
                                   i++) {
                               if ((alphas[i] & 0xFF) == 0) {
  -                                this.m_isTransparent = true;
  -                                this.m_transparentColor = new PDFColor(
  +                                this.isTransparent = true;
  +                                this.transparentColor = new PDFColor(
                                                               (int)(reds[i] & 0xFF),
                                                               (int)(greens[i] & 0xFF),
                                                               (int)(blues[i] & 0xFF));
  @@ -97,23 +98,23 @@
                       } else {
                           // TRANSLUCENT
                           /*
  -                         * this.m_isTransparent = false;
  -                         * for (int i = 0; i < this.m_width * this.m_height; i++) {
  +                         * this.isTransparent = false;
  +                         * for (int i = 0; i < this.width * this.height; i++) {
                            * if (cm.getAlpha(tmpMap[i]) == 0) {
  -                         * this.m_isTransparent = true;
  -                         * this.m_transparentColor = new 
PDFColor(cm.getRed(tmpMap[i]), cm.getGreen(tmpMap[i]), cm.getBlue(tmpMap[i]));
  +                         * this.isTransparent = true;
  +                         * this.transparentColor = new 
PDFColor(cm.getRed(tmpMap[i]), cm.getGreen(tmpMap[i]), cm.getBlue(tmpMap[i]));
                            * break;
                            * }
                            * }
                            */
                           // use special API...
  -                        this.m_isTransparent = false;
  +                        this.isTransparent = false;
                       }
                   } else {
  -                    this.m_isTransparent = false;
  +                    this.isTransparent = false;
                   }
               } else {
  -                this.m_isTransparent = false;
  +                this.isTransparent = false;
               }
           } catch (Exception ex) {
               ua.getLogger().error("Error while loading image "
  @@ -124,19 +125,19 @@
           }
   
           // Should take care of the ColorSpace and bitsPerPixel
  -        this.m_bitmapsSize = this.m_width * this.m_height * 3;
  -        this.m_bitmaps = new byte[this.m_bitmapsSize];
  -        for (int i = 0; i < this.m_height; i++) {
  -            for (int j = 0; j < this.m_width; j++) {
  -                int p = tmpMap[i * this.m_width + j];
  +        this.bitmapsSize = this.width * this.height * 3;
  +        this.bitmaps = new byte[this.bitmapsSize];
  +        for (int i = 0; i < this.height; i++) {
  +            for (int j = 0; j < this.width; j++) {
  +                int p = tmpMap[i * this.width + j];
                   int r = (p >> 16) & 0xFF;
                   int g = (p >> 8) & 0xFF;
                   int b = (p) & 0xFF;
  -                this.m_bitmaps[3 * (i * this.m_width + j)] =
  +                this.bitmaps[3 * (i * this.width + j)] =
                     (byte)(r & 0xFF);
  -                this.m_bitmaps[3 * (i * this.m_width + j) + 1] =
  +                this.bitmaps[3 * (i * this.width + j) + 1] =
                     (byte)(g & 0xFF);
  -                this.m_bitmaps[3 * (i * this.m_width + j) + 2] =
  +                this.bitmaps[3 * (i * this.width + j) + 2] =
                     (byte)(b & 0xFF);
               }
           }
  
  
  
  1.3       +35 -2     xml-fop/src/org/apache/fop/image/ImageCache.java
  
  Index: ImageCache.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/ImageCache.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ImageCache.java   11 Apr 2002 09:33:31 -0000      1.2
  +++ ImageCache.java   14 Nov 2002 15:19:41 -0000      1.3
  @@ -1,6 +1,6 @@
   /*
    * $Id$
  - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
    */
  @@ -10,10 +10,43 @@
   // FOP
   import org.apache.fop.fo.FOUserAgent;
   
  +/**
  + * Image cache holder.
  + * This interface is used for caching images.
  + */
   public interface ImageCache {
  +    /**
  +     * Get an image from the cache.
  +     *
  +     * @param url the url and key for the image
  +     * @param context the user agent context
  +     */
       public FopImage getImage(String url, FOUserAgent context);
  +
  +    /**
  +     * Release an image in the current context.
  +     *
  +     * @param url the url and key for the image
  +     * @param context the user agent context
  +     */
       public void releaseImage(String url, FOUserAgent context);
  +
  +    /**
  +     * Invalidate image.
  +     * If during loading this image is found to be invalid
  +     * it will be invalidated to prevent further attempts at
  +     * loading the image.
  +     *
  +     * @param url the url and key for the image
  +     * @param context the user agent context
  +     */
       public void invalidateImage(String url, FOUserAgent context);
  +
  +    /**
  +     * Remove a context and handle all images in the context.
  +     *
  +     * @param context the user agent context
  +     */
       public void removeContext(FOUserAgent context);
   }
   
  
  
  
  1.10      +32 -6     xml-fop/src/org/apache/fop/image/ImageFactory.java
  
  Index: ImageFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/ImageFactory.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ImageFactory.java 8 Nov 2002 10:47:59 -0000       1.9
  +++ ImageFactory.java 14 Nov 2002 15:19:41 -0000      1.10
  @@ -31,11 +31,6 @@
   // Avalon
   import org.apache.avalon.framework.logger.Logger;
   
  -/*
  -handle context: base dir, logger, caching
  -
  - */
  -
   /**
    * create FopImage objects (with a configuration file - not yet implemented).
    * @author Eric SCHAEFFER
  @@ -46,10 +41,21 @@
   
       private ImageFactory() {}
   
  +    /**
  +     * Get static image factory instance.
  +     *
  +     * @return the image factory instance
  +     */
       public static ImageFactory getInstance() {
           return factory;
       }
   
  +    /**
  +     * Get the url string from a wrapped url.
  +     *
  +     * @href the input wrapped url
  +     * @return the raw url
  +     */
       public static String getURL(String href) {
           /*
            * According to section 5.11 a <uri-specification> is:
  @@ -79,6 +85,10 @@
        * If this returns null then the image could not be loaded
        * due to an error. Messages should be logged.
        * Before calling this the getURL(url) must be used.
  +     *
  +     * @param url the url for the image
  +     * @param context the user agent context
  +     * @return the fop image instance
        */
       public FopImage getImage(String url, FOUserAgent context) {
           return cache.getImage(url, context);
  @@ -89,6 +99,9 @@
        * This can be used if the renderer has its own cache of
        * the image.
        * The image should then be put into the weak cache.
  +     *
  +     * @param url the url for the image 
  +     * @param context the user agent context
        */
       public void releaseImage(String url, FOUserAgent context) {
           cache.releaseImage(url, context);
  @@ -98,6 +111,11 @@
        * create an FopImage objects.
        * @param href image URL as a String
        * @return a new FopImage object
  +     *
  +     * @param href the url for the image 
  +     * @param baseURL the base url
  +     * @param ua the user agent context
  +     * @return the fop image instance
        */
       protected static FopImage loadImage(String href, String baseURL,
                                           FOUserAgent ua) {
  @@ -105,6 +123,10 @@
   
           InputStream imgIS = openStream(href, baseURL, ua);
   
  +        if (imgIS == null) {
  +            return null;
  +        }
  +
           // If not, check image type
           FopImage.ImageInfo imgInfo = null;
           try {
  @@ -268,6 +290,10 @@
       }
   }
   
  +/**
  + * Basic image cache.
  + * This keeps track of invalid images.
  + */
   class BasicImageCache implements ImageCache {
       Set invalid = Collections.synchronizedSet(new HashSet());
       Map contextStore = Collections.synchronizedMap(new HashMap());
  
  
  
  1.9       +27 -32    xml-fop/src/org/apache/fop/image/JAIImage.java
  
  Index: JAIImage.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/JAIImage.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JAIImage.java     8 Nov 2002 10:47:59 -0000       1.8
  +++ JAIImage.java     14 Nov 2002 15:19:41 -0000      1.9
  @@ -7,11 +7,6 @@
   
   package org.apache.fop.image;
   
  -// Java
  -import java.net.URL;
  -import java.io.InputStream;
  -import java.io.InputStream;
  -
   // AWT
   import java.awt.image.ColorModel;
   import java.awt.image.IndexColorModel;
  @@ -48,26 +43,26 @@
               inputStream.close();
               inputStream = null;
   
  -            this.m_height = imageOp.getHeight();
  -            this.m_width = imageOp.getWidth();
  +            this.height = imageOp.getHeight();
  +            this.width = imageOp.getWidth();
   
               ColorModel cm = imageOp.getColorModel();
  -            this.m_bitsPerPixel = 8;
  -            // this.m_bitsPerPixel = cm.getPixelSize();
  -            this.m_colorSpace = ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
  +            this.bitsPerPixel = 8;
  +            // this.bitsPerPixel = cm.getPixelSize();
  +            this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
   
               BufferedImage imageData = imageOp.getAsBufferedImage();
  -            int[] tmpMap = imageData.getRGB(0, 0, this.m_width,
  -                                            this.m_height, null, 0, this.m_width);
  +            int[] tmpMap = imageData.getRGB(0, 0, this.width,
  +                                            this.height, null, 0, this.width);
   
               if (cm.hasAlpha()) {
                   int transparencyType = cm.getTransparency(); // 
java.awt.Transparency. BITMASK or OPAQUE or TRANSLUCENT
                   if (transparencyType == java.awt.Transparency.OPAQUE) {
  -                    this.m_isTransparent = false;
  +                    this.isTransparent = false;
                   } else if (transparencyType ==
                       java.awt.Transparency.BITMASK) {
                       if (cm instanceof IndexColorModel) {
  -                        this.m_isTransparent = false;
  +                        this.isTransparent = false;
                           byte[] alphas = new byte[
                                             ((IndexColorModel) cm).getMapSize()];
                           byte[] reds = new byte[
  @@ -84,8 +79,8 @@
                                   i < ((IndexColorModel) cm).getMapSize();
                                   i++) {
                               if ((alphas[i] & 0xFF) == 0) {
  -                                this.m_isTransparent = true;
  -                                this.m_transparentColor = new PDFColor(
  +                                this.isTransparent = true;
  +                                this.transparentColor = new PDFColor(
                                                               (int)(reds[i] & 0xFF),
                                                               (int)(greens[i] & 0xFF),
                                                               (int)(blues[i] & 0xFF));
  @@ -95,39 +90,39 @@
                       } else {
                           // TRANSLUCENT
                           /*
  -                         * this.m_isTransparent = false;
  -                         * for (int i = 0; i < this.m_width * this.m_height; i++) {
  +                         * this.isTransparent = false;
  +                         * for (int i = 0; i < this.width * this.height; i++) {
                            * if (cm.getAlpha(tmpMap[i]) == 0) {
  -                         * this.m_isTransparent = true;
  -                         * this.m_transparentColor = new 
PDFColor(cm.getRed(tmpMap[i]), cm.getGreen(tmpMap[i]), cm.getBlue(tmpMap[i]));
  +                         * this.isTransparent = true;
  +                         * this.transparentColor = new 
PDFColor(cm.getRed(tmpMap[i]), cm.getGreen(tmpMap[i]), cm.getBlue(tmpMap[i]));
                            * break;
                            * }
                            * }
                            * // or use special API...
                            */
  -                        this.m_isTransparent = false;
  +                        this.isTransparent = false;
                       }
                   } else {
  -                    this.m_isTransparent = false;
  +                    this.isTransparent = false;
                   }
               } else {
  -                this.m_isTransparent = false;
  +                this.isTransparent = false;
               }
   
               // Should take care of the ColorSpace and bitsPerPixel
  -            this.m_bitmapsSize = this.m_width * this.m_height * 3;
  -            this.m_bitmaps = new byte[this.m_bitmapsSize];
  -            for (int i = 0; i < this.m_height; i++) {
  -                for (int j = 0; j < this.m_width; j++) {
  -                    int p = tmpMap[i * this.m_width + j];
  +            this.bitmapsSize = this.width * this.height * 3;
  +            this.bitmaps = new byte[this.bitmapsSize];
  +            for (int i = 0; i < this.height; i++) {
  +                for (int j = 0; j < this.width; j++) {
  +                    int p = tmpMap[i * this.width + j];
                       int r = (p >> 16) & 0xFF;
                       int g = (p >> 8) & 0xFF;
                       int b = (p) & 0xFF;
  -                    this.m_bitmaps[3 * (i * this.m_width + j)] =
  +                    this.bitmaps[3 * (i * this.width + j)] =
                         (byte)(r & 0xFF);
  -                    this.m_bitmaps[3 * (i * this.m_width + j) + 1] =
  +                    this.bitmaps[3 * (i * this.width + j) + 1] =
                         (byte)(g & 0xFF);
  -                    this.m_bitmaps[3 * (i * this.m_width + j) + 2] =
  +                    this.bitmaps[3 * (i * this.width + j) + 2] =
                         (byte)(b & 0xFF);
                   }
               }
  
  
  
  1.17      +29 -29    xml-fop/src/org/apache/fop/image/JimiImage.java
  
  Index: JimiImage.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/JimiImage.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- JimiImage.java    8 Nov 2002 10:47:59 -0000       1.16
  +++ JimiImage.java    14 Nov 2002 15:19:42 -0000      1.17
  @@ -43,19 +43,19 @@
       }
   
       protected boolean loadDimensions(FOUserAgent ua) {
  -        if(this.m_bitmaps == null) {
  +        if(this.bitmaps == null) {
               loadImage(ua.getLogger());
           }
   
  -        return this.m_bitmaps != null;
  +        return this.bitmaps != null;
       }
   
       protected boolean loadBitmap(FOUserAgent ua) {
  -        if(this.m_bitmaps == null) {
  +        if(this.bitmaps == null) {
               loadImage(ua.getLogger());
           }
   
  -        return this.m_bitmaps != null;
  +        return this.bitmaps != null;
       }
   
       protected void loadImage(Logger log) {
  @@ -70,8 +70,8 @@
               while (!consumer.isImageReady()) {
                   Thread.sleep(500);
               }
  -            this.m_height = consumer.getHeight();
  -            this.m_width = consumer.getWidth();
  +            this.height = consumer.getHeight();
  +            this.width = consumer.getWidth();
   
               inputStream.close();
               inputStream = null;
  @@ -84,18 +84,18 @@
               }
   
               ColorModel cm = consumer.getColorModel();
  -            this.m_bitsPerPixel = 8;
  -            // this.m_bitsPerPixel = cm.getPixelSize();
  -            this.m_colorSpace = ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
  +            this.bitsPerPixel = 8;
  +            // this.bitsPerPixel = cm.getPixelSize();
  +            this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
               if (cm.hasAlpha()) {
                   // java.awt.Transparency. BITMASK or OPAQUE or TRANSLUCENT
                   int transparencyType = cm.getTransparency();
                   if (transparencyType == java.awt.Transparency.OPAQUE) {
  -                    this.m_isTransparent = false;
  +                    this.isTransparent = false;
                   } else if (transparencyType ==
                       java.awt.Transparency.BITMASK) {
                       if (cm instanceof IndexColorModel) {
  -                        this.m_isTransparent = false;
  +                        this.isTransparent = false;
                           byte[] alphas = new byte[
                                             ((IndexColorModel) cm).getMapSize()];
                           byte[] reds = new byte[
  @@ -112,8 +112,8 @@
                                   i < ((IndexColorModel) cm).getMapSize();
                                   i++) {
                               if ((alphas[i] & 0xFF) == 0) {
  -                                this.m_isTransparent = true;
  -                                this.m_transparentColor = new PDFColor(
  +                                this.isTransparent = true;
  +                                this.transparentColor = new PDFColor(
                                                               (int)(reds[i] & 0xFF),
                                                               (int)(greens[i] & 0xFF),
                                                               (int)(blues[i] & 0xFF));
  @@ -123,23 +123,23 @@
                       } else {
                           // TRANSLUCENT
                           /*
  -                         * this.m_isTransparent = false;
  -                         * for (int i = 0; i < this.m_width * this.m_height; i++) {
  +                         * this.isTransparent = false;
  +                         * for (int i = 0; i < this.width * this.height; i++) {
                            * if (cm.getAlpha(tmpMap[i]) == 0) {
  -                         * this.m_isTransparent = true;
  -                         * this.m_transparentColor = new 
PDFColor(cm.getRed(tmpMap[i]), cm.getGreen(tmpMap[i]), cm.getBlue(tmpMap[i]));
  +                         * this.isTransparent = true;
  +                         * this.transparentColor = new 
PDFColor(cm.getRed(tmpMap[i]), cm.getGreen(tmpMap[i]), cm.getBlue(tmpMap[i]));
                            * break;
                            * }
                            * }
                            */
                           // use special API...
  -                        this.m_isTransparent = false;
  +                        this.isTransparent = false;
                       }
                   } else {
  -                    this.m_isTransparent = false;
  +                    this.isTransparent = false;
                   }
               } else {
  -                this.m_isTransparent = false;
  +                this.isTransparent = false;
               }
           } catch (Throwable ex) {
               log.error("Error while loading image "
  @@ -149,19 +149,19 @@
   
   
           // Should take care of the ColorSpace and bitsPerPixel
  -        this.m_bitmapsSize = this.m_width * this.m_height * 3;
  -        this.m_bitmaps = new byte[this.m_bitmapsSize];
  -        for (int i = 0; i < this.m_height; i++) {
  -            for (int j = 0; j < this.m_width; j++) {
  -                int p = tmpMap[i * this.m_width + j];
  +        this.bitmapsSize = this.width * this.height * 3;
  +        this.bitmaps = new byte[this.bitmapsSize];
  +        for (int i = 0; i < this.height; i++) {
  +            for (int j = 0; j < this.width; j++) {
  +                int p = tmpMap[i * this.width + j];
                   int r = (p >> 16) & 0xFF;
                   int g = (p >> 8) & 0xFF;
                   int b = (p) & 0xFF;
  -                this.m_bitmaps[3 * (i * this.m_width + j)] =
  +                this.bitmaps[3 * (i * this.width + j)] =
                     (byte)(r & 0xFF);
  -                this.m_bitmaps[3 * (i * this.m_width + j) + 1] =
  +                this.bitmaps[3 * (i * this.width + j) + 1] =
                     (byte)(g & 0xFF);
  -                this.m_bitmaps[3 * (i * this.m_width + j) + 2] =
  +                this.bitmaps[3 * (i * this.width + j) + 2] =
                     (byte)(b & 0xFF);
               }
           }
  
  
  
  1.11      +54 -63    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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JpegImage.java    13 Nov 2002 08:25:59 -0000      1.10
  +++ JpegImage.java    14 Nov 2002 15:19:42 -0000      1.11
  @@ -1,6 +1,6 @@
   /*
    * $Id$
  - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
    */
  @@ -8,18 +8,11 @@
   package org.apache.fop.image;
   
   // Java
  -import java.net.URL;
  -import java.awt.image.ImageProducer;
  -import java.awt.image.ColorModel;
  -import java.awt.image.IndexColorModel;
   import java.io.ByteArrayOutputStream;
  -import java.io.InputStream;
   import java.awt.color.ColorSpace;
   import java.awt.color.ICC_Profile;
  -import java.awt.color.ICC_ColorSpace;
   
   // FOP
  -import org.apache.fop.image.analyser.ImageReader;
   import org.apache.fop.fo.FOUserAgent;
   
   /**
  @@ -30,8 +23,8 @@
    */
   public class JpegImage extends AbstractFopImage {
       private ICC_Profile iccProfile = null;
  -    private boolean found_icc_profile = false;
  -    private boolean found_dimensions = false;
  +    private boolean foundICCProfile = false;
  +    private boolean foundDimensions = false;
   
       /**
        * Create a jpeg image with the info.
  @@ -53,59 +46,57 @@
       protected boolean loadOriginalData(FOUserAgent ua) {
           ByteArrayOutputStream baos = new ByteArrayOutputStream();
           ByteArrayOutputStream iccStream = new ByteArrayOutputStream();
  -        InputStream inStream;
  -        byte[] readBuf = new byte[4096];
  -        int bytes_read;
           int index = 0;
           boolean cont = true;
   
           try {
  -            inStream = inputStream;
  -
  -            while ((bytes_read = inStream.read(readBuf)) != -1) {
  -                baos.write(readBuf, 0, bytes_read);
  +            byte[] readBuf = new byte[4096];
  +            int bytesRead;
  +            while ((bytesRead = inputStream.read(readBuf)) != -1) {
  +                baos.write(readBuf, 0, bytesRead);
               }
               inputStream.close();
               inputStream = null;
           } catch (java.io.IOException ex) {
  -            ua.getLogger().error("Error while loading image " +
  -                                         "" + " : " + ex.getClass() +
  -                                         " - " + ex.getMessage(), ex);
  +            ua.getLogger().error("Error while loading image "
  +                                         + " : " + ex.getClass()
  +                                         + " - " + ex.getMessage(), ex);
               return false;
           }
   
  -        this.m_bitmaps = baos.toByteArray();
  -        this.m_bitsPerPixel = 8;
  -        this.m_isTransparent = false;
  -
  -        if (this.m_bitmaps.length > (index + 2) &&
  -                uByte(this.m_bitmaps[index]) == 255 &&
  -                uByte(this.m_bitmaps[index + 1]) == 216) {
  +        this.bitmaps = baos.toByteArray();
  +        this.bitsPerPixel = 8;
  +        this.isTransparent = false;
  +
  +        if (this.bitmaps.length > (index + 2)
  +                && uByte(this.bitmaps[index]) == 255
  +                && uByte(this.bitmaps[index + 1]) == 216) {
               index += 2;
   
  -            while (index < this.m_bitmaps.length && cont) {
  +            while (index < this.bitmaps.length && cont) {
                   //check to be sure this is the begining of a header
  -                if (this.m_bitmaps.length > (index + 2) &&
  -                        uByte(this.m_bitmaps[index]) == 255) {
  +                if (this.bitmaps.length > (index + 2)
  +                        && uByte(this.bitmaps[index]) == 255) {
   
  -                    //192 or 194 are the header bytes that contain the jpeg width 
height and color depth.
  -                    if (uByte(this.m_bitmaps[index + 1]) == 192 ||
  -                            uByte(this.m_bitmaps[index + 1]) == 194) {
  -
  -                        this.m_height = calcBytes(this.m_bitmaps[index + 5],
  -                                                  this.m_bitmaps[index + 6]);
  -                        this.m_width = calcBytes(this.m_bitmaps[index + 7],
  -                                                 this.m_bitmaps[index + 8]);
  +                    //192 or 194 are the header bytes that contain
  +                    // the jpeg width height and color depth.
  +                    if (uByte(this.bitmaps[index + 1]) == 192
  +                            || uByte(this.bitmaps[index + 1]) == 194) {
  +
  +                        this.height = calcBytes(this.bitmaps[index + 5],
  +                                                  this.bitmaps[index + 6]);
  +                        this.width = calcBytes(this.bitmaps[index + 7],
  +                                                 this.bitmaps[index + 8]);
   
  -                        if (this.m_bitmaps[index + 9] == 1) {
  -                            this.m_colorSpace = ColorSpace.getInstance(
  +                        if (this.bitmaps[index + 9] == 1) {
  +                            this.colorSpace = ColorSpace.getInstance(
                                 ColorSpace.CS_GRAY);
  -                        } else if (this.m_bitmaps[index + 9] == 3) {
  -                            this.m_colorSpace = ColorSpace.getInstance(
  +                        } else if (this.bitmaps[index + 9] == 3) {
  +                            this.colorSpace = ColorSpace.getInstance(
                                 ColorSpace.CS_LINEAR_RGB);
  -                        } else if (this.m_bitmaps[index + 9] == 4) {
  +                        } else if (this.bitmaps[index + 9] == 4) {
                               // howto create CMYK color space
  -                            this.m_colorSpace = ColorSpace.getInstance(
  +                            this.colorSpace = ColorSpace.getInstance(
                                 ColorSpace.CS_CIEXYZ);
                           } else {
                               ua.getLogger().error("Unknown ColorSpace for image: "
  @@ -113,36 +104,36 @@
                               return false;
                           }
   
  -                        found_dimensions = true;
  -                        if (found_icc_profile) {
  +                        foundDimensions = true;
  +                        if (foundICCProfile) {
                               cont = false;
                               break;
                           }
  -                        index += calcBytes(this.m_bitmaps[index + 2],
  -                                           this.m_bitmaps[index + 3]) + 2;
  +                        index += calcBytes(this.bitmaps[index + 2],
  +                                           this.bitmaps[index + 3]) + 2;
   
  -                    } else if (uByte(this.m_bitmaps[index + 1]) ==
  -                        226 && this.m_bitmaps.length > (index + 60)) {
  +                    } else if (uByte(this.bitmaps[index + 1]) == 226
  +                                   && this.bitmaps.length > (index + 60)) {
                           // Check if ICC profile
  -                        byte[] icc_string = new byte[11];
  -                        System.arraycopy(this.m_bitmaps, index + 4,
  -                                         icc_string, 0, 11);
  +                        byte[] iccString = new byte[11];
  +                        System.arraycopy(this.bitmaps, index + 4,
  +                                         iccString, 0, 11);
   
  -                        if ("ICC_PROFILE".equals(new String(icc_string))) {
  +                        if ("ICC_PROFILE".equals(new String(iccString))) {
                               int chunkSize = calcBytes(
  -                                              this.m_bitmaps[index + 2],
  -                                              this.m_bitmaps[index + 3]) + 2;
  +                                              this.bitmaps[index + 2],
  +                                              this.bitmaps[index + 3]) + 2;
   
  -                            iccStream.write(this.m_bitmaps,
  +                            iccStream.write(this.bitmaps,
                                               index + 18, chunkSize - 18);
   
                           }
   
  -                        index += calcBytes(this.m_bitmaps[index + 2],
  -                                           this.m_bitmaps[index + 3]) + 2;
  +                        index += calcBytes(this.bitmaps[index + 2],
  +                                           this.bitmaps[index + 3]) + 2;
                       } else {
  -                        index += calcBytes(this.m_bitmaps[index + 2],
  -                                           this.m_bitmaps[index + 3]) + 2;
  +                        index += calcBytes(this.bitmaps[index + 2],
  +                                           this.bitmaps[index + 3]) + 2;
                       }
   
                   } else {
  @@ -170,7 +161,7 @@
                   ua.getLogger().error("Invalid ICC profile: " + e, e);
                   return false;
               }
  -        } else if(this.m_colorSpace == null) {
  +        } else if (this.colorSpace == null) {
               ua.getLogger().error("ColorSpace not specified for JPEG image");
               return false;
           }
  
  
  
  1.26      +2 -2      xml-fop/src/org/apache/fop/image/analyser/SVGReader.java
  
  Index: SVGReader.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/analyser/SVGReader.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- SVGReader.java    8 Nov 2002 10:48:00 -0000       1.25
  +++ SVGReader.java    14 Nov 2002 15:19:42 -0000      1.26
  @@ -155,7 +155,7 @@
                   fis.mark(length + 1);
                   SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(
                           XMLImage.getParserName());
  -                SVGDocument doc = (SVGDocument) factory.createDocument(uri, fis);
  +                SVGDocument doc = (SVGDocument) factory.createSVGDocument(uri, fis);
                   info.data = doc;
   
                   Element e = doc.getRootElement();
  
  
  

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

Reply via email to