diff options
author | Luis Bernardo <lbernardo@apache.org> | 2014-04-03 21:57:51 +0000 |
---|---|---|
committer | Luis Bernardo <lbernardo@apache.org> | 2014-04-03 21:57:51 +0000 |
commit | f8dd89a164228d28afd6080fb37e1f94b3e30a09 (patch) | |
tree | f1487ae5c23a3752be584d7ce1364cb33e1ac893 | |
parent | 78c2e0e6fdb8f8a9d213a0fa3623cf1bda0bd8d0 (diff) | |
download | xmlgraphics-fop-f8dd89a164228d28afd6080fb37e1f94b3e30a09.tar.gz xmlgraphics-fop-f8dd89a164228d28afd6080fb37e1f94b3e30a09.zip |
FOP-2339: GIF to PS transparency is black; patch by Simon Steiner
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1584420 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java index d943f1ce8..6b5745e86 100644 --- a/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java +++ b/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java @@ -19,9 +19,12 @@ package org.apache.fop.render.ps; +import java.awt.Color; import java.awt.Dimension; +import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.RenderedImage; import java.io.IOException; @@ -63,6 +66,17 @@ public class PSImageHandlerRenderedImage implements PSImageHandler { Rectangle2D targetRect = new Rectangle2D.Double(x, y, w, h); RenderedImage ri = imageRend.getRenderedImage(); + + if (ri instanceof BufferedImage && ri.getColorModel().hasAlpha()) { + BufferedImage convertedImg = new BufferedImage(ri.getWidth(), ri.getHeight(), BufferedImage.TYPE_INT_RGB); + Graphics2D g = (Graphics2D) convertedImg.getGraphics(); + g.setBackground(Color.WHITE); + g.clearRect(0, 0, ri.getWidth(), ri.getHeight()); + g.drawImage((BufferedImage)ri, 0, 0, null); + g.dispose(); + ri = convertedImg; + } + ImageEncoder encoder = ImageEncodingHelper.createRenderedImageEncoder(ri); Dimension imgDim = new Dimension(ri.getWidth(), ri.getHeight()); String imgDescription = ri.getClass().getName(); |