diff options
author | Jeremias Maerki <jeremias@apache.org> | 2007-02-03 22:22:26 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2007-02-03 22:22:26 +0000 |
commit | d8c9af01d3bdf2943d226e67e987d9e140e43b58 (patch) | |
tree | 8b3607793fd785f61c4a343107a2004c371b0521 /src/java-1.4 | |
parent | 14a4ef81000e1b785cc0c38d10e724902b89624d (diff) | |
download | xmlgraphics-fop-d8c9af01d3bdf2943d226e67e987d9e140e43b58.tar.gz xmlgraphics-fop-d8c9af01d3bdf2943d226e67e987d9e140e43b58.zip |
Support for soft masks (transparency) with ImageIO image adapter. Should help with transparent PNGs.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@503323 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java-1.4')
-rw-r--r-- | src/java-1.4/org/apache/fop/image/ImageIOImage.java | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/java-1.4/org/apache/fop/image/ImageIOImage.java b/src/java-1.4/org/apache/fop/image/ImageIOImage.java index 463331530..ebb4a09eb 100644 --- a/src/java-1.4/org/apache/fop/image/ImageIOImage.java +++ b/src/java-1.4/org/apache/fop/image/ImageIOImage.java @@ -46,6 +46,8 @@ import org.w3c.dom.NodeList; */ public class ImageIOImage extends AbstractFopImage { + private byte[] softMask = null; + /** * Creates a new ImageIOImage. * @param info the image info from the ImageReader @@ -163,22 +165,14 @@ public class ImageIOImage extends AbstractFopImage { } } } else { - // TRANSLUCENT - /* - * this.isTransparent = false; - * for (int i = 0; i < this.width * this.height; i++) { - * if (cm.getAlpha(tmpMap[i]) == 0) { - * this.isTransparent = true; - * this.transparentColor = new PDFColor(cm.getRed(tmpMap[i]), - * cm.getGreen(tmpMap[i]), cm.getBlue(tmpMap[i])); - * break; - * } - * } - * // or use special API... - */ + //TODO Is there another case? this.isTransparent = false; } } else { + // TRANSLUCENT + this.softMask = new byte[width * height]; + imageData.getAlphaRaster().getDataElements( + 0, 0, width, height, this.softMask); this.isTransparent = false; } } else { @@ -217,5 +211,23 @@ public class ImageIOImage extends AbstractFopImage { return loadDefaultOriginalData(); } + /** @see org.apache.fop.image.FopImage#hasSoftMask() */ + public boolean hasSoftMask() { + if (this.bitmaps == null && this.raw == null) { + loadBitmap(); + } + + return (this.softMask != null); + } + + /** @see org.apache.fop.image.FopImage#getSoftMask() */ + public byte[] getSoftMask() { + if (this.bitmaps == null) { + loadBitmap(); + } + + return this.softMask; + } + } |