aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLuis Bernardo <lbernardo@apache.org>2013-07-12 21:19:06 +0000
committerLuis Bernardo <lbernardo@apache.org>2013-07-12 21:19:06 +0000
commit51780a5d213bd8c8abcd50db30a48bcabd447309 (patch)
treee0b76ba6bd559c2f8e7bbe85f8dc6faebaf85c8b /src
parente1073af700f7ebcb4c21f80020b396274fff7393 (diff)
downloadxmlgraphics-fop-51780a5d213bd8c8abcd50db30a48bcabd447309.tar.gz
xmlgraphics-fop-51780a5d213bd8c8abcd50db30a48bcabd447309.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java11
-rw-r--r--src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java3
-rw-r--r--src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java2
3 files changed, 13 insertions, 3 deletions
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} */