]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fix a ArrayIndexOutOfBoundsException when loading indexed PNGs.
authorFinn Bock <bckfnn@apache.org>
Wed, 13 Oct 2004 06:56:49 +0000 (06:56 +0000)
committerFinn Bock <bckfnn@apache.org>
Wed, 13 Oct 2004 06:56:49 +0000 (06:56 +0000)
PR: 31675
Submitted by: Thomas Deweese

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198044 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/image/BatikImage.java

index 96a79ecd93936aac0d83025997a0a128a07b7867..b0987906ee25118e0b2ec594c9a99f5d932f40a8 100644 (file)
@@ -118,14 +118,15 @@ public abstract class BatikImage extends AbstractFopImage {
 
             this.height = cr.getHeight();
             this.width  = cr.getWidth();
-
-            cr = new Any2sRGBRed(cr);
-
             this.isTransparent = false;
             this.softMask = null;
+            this.bitmapsSize = this.width * this.height * 3;
+            this.bitmaps = new byte[this.bitmapsSize];
+            this.bitsPerPixel = 8;
+
             int transparencyType = cm.getTransparency();
-            if ((transparencyType == Transparency.BITMASK) 
-                    && (cm instanceof IndexColorModel)) {
+            if (cm instanceof IndexColorModel)  {
+                if (transparencyType == Transparency.BITMASK) {
                 // Use 'transparent color'.
                 IndexColorModel icm = (IndexColorModel)cm;
                 int numColor = icm.getMapSize();
@@ -142,20 +143,18 @@ public abstract class BatikImage extends AbstractFopImage {
                     }
                 }
             }
+            } else {
+                cr = new Any2sRGBRed(cr);
+            }
 
             // Get our current ColorModel
             cm = cr.getColorModel();
 
             // It has an alpha channel so generate a soft mask.
-            if ((!this.isTransparent) && cm.hasAlpha()) {
+            if (!this.isTransparent && cm.hasAlpha())
                 this.softMask = new byte[this.width * this.height];
-            }
 
-            this.bitsPerPixel = 8;
-            this.bitmapsSize = this.width * this.height * 3;
-            this.bitmaps = new byte[this.bitmapsSize];
             this.colorSpace = cm.getColorSpace();
-
             WritableRaster wr = (WritableRaster)cr.getData();
             BufferedImage bi = new BufferedImage
                 (cm, wr.createWritableTranslatedChild(0, 0),