From: Luis Bernardo Date: Fri, 12 Jul 2013 21:19:06 +0000 (+0000) Subject: FOP-2259: 1 bit TIFF error; patch submitted by Simon Steiner X-Git-Tag: fop-2_0~197 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=51780a5d213bd8c8abcd50db30a48bcabd447309;p=xmlgraphics-fop.git FOP-2259: 1 bit TIFF error; patch submitted by Simon Steiner git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1502694 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/xmlgraphics-commons-svn-trunk.jar b/lib/xmlgraphics-commons-svn-trunk.jar index fda692989..c7ff1d6a4 100644 Binary files a/lib/xmlgraphics-commons-svn-trunk.jar and b/lib/xmlgraphics-commons-svn-trunk.jar differ diff --git a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java index 40e5225d2..58299c528 100644 --- a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java +++ b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java @@ -20,13 +20,16 @@ package org.apache.fop.render.pdf; import java.awt.color.ColorSpace; import java.awt.color.ICC_Profile; +import java.awt.image.DataBufferByte; import java.awt.image.IndexColorModel; +import java.awt.image.Raster; import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.xmlgraphics.image.loader.Image; +import org.apache.xmlgraphics.image.loader.impl.ImageRendered; import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil; import org.apache.fop.pdf.PDFArray; @@ -257,7 +260,13 @@ public abstract class AbstractImageAdapter implements PDFImage { indexed.add(baout.toByteArray()); dict.put("ColorSpace", indexed); - dict.put("BitsPerComponent", icm.getPixelSize()); + + Raster raster = ((ImageRendered)image).getRenderedImage().getTile(0, 0); + if (raster.getDataBuffer() instanceof DataBufferByte) { + dict.put("BitsPerComponent", icm.getPixelSize()); + } else { + dict.put("BitsPerComponent", 8); + } Integer index = getIndexOfFirstTransparentColorInPalette(icm); if (index != null) { diff --git a/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java b/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java index b0b7b79d1..1b87958c2 100644 --- a/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java +++ b/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java @@ -63,7 +63,7 @@ public class ImageRenderedAdapter extends AbstractImageAdapter { */ public ImageRenderedAdapter(ImageRendered image, String key) { super(image, key); - this.encodingHelper = new ImageEncodingHelper(image.getRenderedImage(), true); + this.encodingHelper = new ImageEncodingHelper(image.getRenderedImage()); } /** @@ -195,6 +195,7 @@ public class ImageRenderedAdapter extends AbstractImageAdapter { /** {@inheritDoc} */ public void outputContents(OutputStream out) throws IOException { long start = System.currentTimeMillis(); + encodingHelper.setBWInvert(true); encodingHelper.encode(out); long duration = System.currentTimeMillis() - start; if (log.isDebugEnabled()) { diff --git a/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java index 46597e46d..d943f1ce8 100644 --- a/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java +++ b/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java @@ -69,7 +69,7 @@ public class PSImageHandlerRenderedImage implements PSImageHandler { ImageEncodingHelper helper = new ImageEncodingHelper(ri); ColorModel cm = helper.getEncodedColorModel(); - PSImageUtils.writeImage(encoder, imgDim, imgDescription, targetRect, cm, gen); + PSImageUtils.writeImage(encoder, imgDim, imgDescription, targetRect, cm, gen, ri); } /** {@inheritDoc} */