diff options
author | Jeremias Maerki <jeremias@apache.org> | 2006-03-18 20:28:33 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2006-03-18 20:28:33 +0000 |
commit | 148095dd2eb3b68a27f0d76a13beff79cc8b4336 (patch) | |
tree | 4fa5912c2c32e9d56a71fd29396dd9504563bbbf | |
parent | 97a13831e8fce797ad4d321b778ba0af69d6eddf (diff) | |
download | xmlgraphics-fop-148095dd2eb3b68a27f0d76a13beff79cc8b4336.tar.gz xmlgraphics-fop-148095dd2eb3b68a27f0d76a13beff79cc8b4336.zip |
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
-rw-r--r-- | src/java/org/apache/fop/image/AbstractFopImage.java | 2 | ||||
-rw-r--r-- | src/java/org/apache/fop/render/pdf/FopPDFImage.java | 14 | ||||
-rw-r--r-- | status.xml | 4 | ||||
-rw-r--r-- | test/layoutengine/standard-testcases/external-graphic_tiff.xml | 10 | ||||
-rw-r--r-- | test/resources/images/tiff_group4-multi-strip.tif | bin | 0 -> 5467 bytes |
5 files changed, 26 insertions, 4 deletions
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 @@ <changes> <release version="FOP Trunk"> + <action context="Code" dev="JM" type="fix"> + Bugfix: CCITT Group 4 encoded TIFF images with multiple strips are now properly + embedded in PDF files. + </action> <action context="Code" dev="JM" type="add"> Added support for fixed-width spaces. </action> 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 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - Copyright 2005 The Apache Software Foundation + Copyright 2005-2006 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -42,6 +42,10 @@ <fo:block> <fo:external-graphic src="../../resources/images/tiff_group4.tif"/>EOG </fo:block> + <fo:block>TIFF external-graphic (CCITT group 4 encoding, multiple strips)</fo:block> + <fo:block> + <fo:external-graphic src="../../resources/images/tiff_group4-multi-strip.tif"/>EOG + </fo:block> <fo:block>EOF</fo:block> </fo:flow> </fo:page-sequence> @@ -60,5 +64,9 @@ <eval expected="550588" xpath="//flow/block[6]/lineArea/viewport/@ipda"/> <eval expected="66705" xpath="//flow/block[6]/lineArea/viewport/@bpd"/> <eval expected="66705" xpath="//flow/block[6]/lineArea/viewport/@bpda"/> + <eval expected="550588" xpath="//flow/block[8]/lineArea/viewport/@ipd"/> + <eval expected="550588" xpath="//flow/block[8]/lineArea/viewport/@ipda"/> + <eval expected="66705" xpath="//flow/block[8]/lineArea/viewport/@bpd"/> + <eval expected="66705" xpath="//flow/block[8]/lineArea/viewport/@bpda"/> </checks> </testcase> diff --git a/test/resources/images/tiff_group4-multi-strip.tif b/test/resources/images/tiff_group4-multi-strip.tif Binary files differnew file mode 100644 index 000000000..3b03b5d14 --- /dev/null +++ b/test/resources/images/tiff_group4-multi-strip.tif |