From 148095dd2eb3b68a27f0d76a13beff79cc8b4336 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Sat, 18 Mar 2006 20:28:33 +0000 Subject: [PATCH] Bugfix: CCITT Group 4 encoded TIFF images were not properly embedded in PDF files. FopPDFImage always used the bits/pixel and color space of the original image although our image adapter mostly convert all images to 24bit RGB. One day, we will need to improve the image handling. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@386879 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/image/AbstractFopImage.java | 2 +- .../org/apache/fop/render/pdf/FopPDFImage.java | 14 ++++++++++++-- status.xml | 4 ++++ .../standard-testcases/external-graphic_tiff.xml | 10 +++++++++- .../resources/images/tiff_group4-multi-strip.tif | Bin 0 -> 5467 bytes 5 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 test/resources/images/tiff_group4-multi-strip.tif diff --git a/src/java/org/apache/fop/image/AbstractFopImage.java b/src/java/org/apache/fop/image/AbstractFopImage.java index f64fdfb72..af4593038 100644 --- a/src/java/org/apache/fop/image/AbstractFopImage.java +++ b/src/java/org/apache/fop/image/AbstractFopImage.java @@ -216,7 +216,7 @@ public abstract class AbstractFopImage implements FopImage { try { this.raw = IOUtils.toByteArray(inputStream); } catch (java.io.IOException ex) { - log.error("Error while loading image (EMF): " + ex.getMessage(), ex); + log.error("Error while reading raw image: " + ex.getMessage(), ex); return false; } finally { IOUtils.closeQuietly(inputStream); diff --git a/src/java/org/apache/fop/render/pdf/FopPDFImage.java b/src/java/org/apache/fop/render/pdf/FopPDFImage.java index e709b26ad..d35204e9e 100644 --- a/src/java/org/apache/fop/render/pdf/FopPDFImage.java +++ b/src/java/org/apache/fop/render/pdf/FopPDFImage.java @@ -150,14 +150,24 @@ public class FopPDFImage implements PDFImage { */ public PDFColorSpace getColorSpace() { // DeviceGray, DeviceRGB, or DeviceCMYK - return toPDFColorSpace(fopImage.getColorSpace()); + if (isCCF || isDCT || isPS) { + return toPDFColorSpace(fopImage.getColorSpace()); + } else { + return toPDFColorSpace(ColorSpace.getInstance(ColorSpace.CS_sRGB)); + } } /** * @see org.apache.fop.pdf.PDFImage#getBitsPerPixel() */ public int getBitsPerPixel() { - return fopImage.getBitsPerPixel(); + if (isCCF) { + return fopImage.getBitsPerPixel(); + } else { + return 8; //TODO This is suboptimal, handling everything as RGB + //The image wrappers can mostly only return RGB bitmaps right now. This should + //be improved so the renderers can deal directly with RenderedImage instances. + } } /** diff --git a/status.xml b/status.xml index c0532a51c..4e23f12c1 100644 --- a/status.xml +++ b/status.xml @@ -27,6 +27,10 @@ + + Bugfix: CCITT Group 4 encoded TIFF images with multiple strips are now properly + embedded in PDF files. + Added support for fixed-width spaces. diff --git a/test/layoutengine/standard-testcases/external-graphic_tiff.xml b/test/layoutengine/standard-testcases/external-graphic_tiff.xml index 1b38504b0..d8db5af8e 100644 --- a/test/layoutengine/standard-testcases/external-graphic_tiff.xml +++ b/test/layoutengine/standard-testcases/external-graphic_tiff.xml @@ -1,6 +1,6 @@