aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2011-02-07 08:28:41 +0000
committerJeremias Maerki <jeremias@apache.org>2011-02-07 08:28:41 +0000
commit514b49fd422e6b85164faa8c7cc169444b4ddab6 (patch)
treec50f2488040122cbd722fccb1f9a0c40ba3c1894 /src/java
parentd9c453d8fb11f27b5ddd3eaad5a63175ed90f019 (diff)
downloadxmlgraphics-fop-514b49fd422e6b85164faa8c7cc169444b4ddab6.tar.gz
xmlgraphics-fop-514b49fd422e6b85164faa8c7cc169444b4ddab6.zip
Bugfix: Avoid directly encoding if the sample model is not exactly right. For example, monochrome image generated by JAI (error-diffusion rasterization) use a non-packed sample model which caused badly encoded images.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1067878 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
index ca0544542..c38af8fac 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
@@ -24,8 +24,10 @@ import java.awt.Rectangle;
import java.awt.image.ColorModel;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferByte;
+import java.awt.image.MultiPixelPackedSampleModel;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
+import java.awt.image.SampleModel;
import java.io.IOException;
import java.io.OutputStream;
@@ -254,6 +256,12 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler implements Ima
if (tiles > 1) {
return false;
}
+ SampleModel sampleModel = renderedImage.getSampleModel();
+ SampleModel expectedSampleModel = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ renderedImage.getWidth(), renderedImage.getHeight(), 1);
+ if (!expectedSampleModel.equals(sampleModel)) {
+ return false; //Pixels are not packed
+ }
imageObjectInfo.setBitsPerPixel(1);
@@ -290,6 +298,7 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler implements Ima
}
/** {@inheritDoc} */
+ @Override
protected AFPDataObjectInfo createDataObjectInfo() {
return new AFPImageObjectInfo();
}