aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/image/BatikImage.java
diff options
context:
space:
mode:
authorFinn Bock <bckfnn@apache.org>2004-10-13 06:56:49 +0000
committerFinn Bock <bckfnn@apache.org>2004-10-13 06:56:49 +0000
commitf87102a847052f993280156bd70022b8d3f9f49a (patch)
tree9daddbe6d8010b0e229c33b4c601f0168d0fc5f4 /src/java/org/apache/fop/image/BatikImage.java
parenta072e9db984f51becd5e0044dd76f5e8e7163d6c (diff)
downloadxmlgraphics-fop-f87102a847052f993280156bd70022b8d3f9f49a.tar.gz
xmlgraphics-fop-f87102a847052f993280156bd70022b8d3f9f49a.zip
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
Diffstat (limited to 'src/java/org/apache/fop/image/BatikImage.java')
-rw-r--r--src/java/org/apache/fop/image/BatikImage.java21
1 files 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),