From f87102a847052f993280156bd70022b8d3f9f49a Mon Sep 17 00:00:00 2001 From: Finn Bock Date: Wed, 13 Oct 2004 06:56:49 +0000 Subject: [PATCH] Fix a ArrayIndexOutOfBoundsException when loading indexed PNGs. 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 | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/java/org/apache/fop/image/BatikImage.java b/src/java/org/apache/fop/image/BatikImage.java index 96a79ecd9..b0987906e 100644 --- a/src/java/org/apache/fop/image/BatikImage.java +++ b/src/java/org/apache/fop/image/BatikImage.java @@ -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), -- 2.39.5