]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2259: 1 bit TIFF error; patch submitted by Simon Steiner
authorLuis Bernardo <lbernardo@apache.org>
Fri, 12 Jul 2013 21:19:06 +0000 (21:19 +0000)
committerLuis Bernardo <lbernardo@apache.org>
Fri, 12 Jul 2013 21:19:06 +0000 (21:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1502694 13f79535-47bb-0310-9956-ffa450edef68

lib/xmlgraphics-commons-svn-trunk.jar
src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java
src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java

index fda692989190e8f83c0e74dbc996cbdbcaf12a1b..c7ff1d6a4347d91d982efbdfa3aa0c1388e945a5 100644 (file)
Binary files a/lib/xmlgraphics-commons-svn-trunk.jar and b/lib/xmlgraphics-commons-svn-trunk.jar differ
index 40e5225d2b0c325196c106c5f0036abc9f1952f3..58299c5280774cc52d3cb231e250b9eb4157d829 100644 (file)
 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) {
index b0b7b79d111c27f8a217888647cb1075cab7f14a..1b87958c22aab5a8b8c5ca20719d511c64d6227f 100644 (file)
@@ -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()) {
index 46597e46d1dd478712beb918f8db1e61d9c8cc74..d943f1ce8651f60b33338d9ad8ce91b663bd3969 100644 (file)
@@ -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} */