]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugfix: Avoid directly encoding if the sample model is not exactly right. For example...
authorJeremias Maerki <jeremias@apache.org>
Mon, 7 Feb 2011 08:28:41 +0000 (08:28 +0000)
committerJeremias Maerki <jeremias@apache.org>
Mon, 7 Feb 2011 08:28:41 +0000 (08:28 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1067878 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java

index ca0544542270dcd3f4ab7800885904a3f085e2a9..c38af8facee09e064835cb5a4698d6fd21151789 100644 (file)
@@ -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();
     }