aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis Bernardo <lbernardo@apache.org>2012-11-25 23:24:41 +0000
committerLuis Bernardo <lbernardo@apache.org>2012-11-25 23:24:41 +0000
commit89dbe6e14282ecdcfc2ec252c5ccfb1ab1d802c6 (patch)
tree575ca367712c830de1f2acdbc2ef67863803b7a9
parent638ea00309ef225858fdc2b5ab2889e1236d783d (diff)
downloadxmlgraphics-fop-89dbe6e14282ecdcfc2ec252c5ccfb1ab1d802c6.tar.gz
xmlgraphics-fop-89dbe6e14282ecdcfc2ec252c5ccfb1ab1d802c6.zip
bugzilla #54196: configure big / little endian support for TIFF images; patch 29628 applied; submitted by Robert Meyer
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1413442 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--lib/xmlgraphics-commons-svn-trunk.jarbin626706 -> 628756 bytes
-rw-r--r--src/documentation/content/xdocs/trunk/output.xml6
-rw-r--r--src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java3
-rw-r--r--src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java15
-rw-r--r--src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java8
-rw-r--r--test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java6
-rw-r--r--test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java10
-rw-r--r--test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java9
8 files changed, 53 insertions, 4 deletions
diff --git a/lib/xmlgraphics-commons-svn-trunk.jar b/lib/xmlgraphics-commons-svn-trunk.jar
index bca45d578..91648b9ff 100644
--- a/lib/xmlgraphics-commons-svn-trunk.jar
+++ b/lib/xmlgraphics-commons-svn-trunk.jar
Binary files differ
diff --git a/src/documentation/content/xdocs/trunk/output.xml b/src/documentation/content/xdocs/trunk/output.xml
index 5de820c18..96792cd4c 100644
--- a/src/documentation/content/xdocs/trunk/output.xml
+++ b/src/documentation/content/xdocs/trunk/output.xml
@@ -1271,6 +1271,7 @@ Note that the value of the encoding attribute in the example is the double-byte
<transparent-page-background>true</transparent-page-background>
<compression>CCITT T.6</compression>
<single-strip>true</single-strip>
+ <endianness>default</endianness>
<fonts><!-- described elsewhere --></fonts>
</renderer>]]></source>
<p>
@@ -1308,6 +1309,11 @@ Note that the value of the encoding attribute in the example is the double-byte
The default value for the <code>"single-strip"</code> is <code>"false"</code> resulting in the RowsPerStrip Tiff Tag equal to the number of rows.
If set to <code>true</code> RowsPerStrip is set to 1.
</p>
+ <p>
+ The default value for <code>"endianness"</code> is <code>"default"</code>, which results in the
+ default endianness for the output format being generated. Note that not all image formats allow
+ specifying the endianness.
+ </p>
</section>
<section id="bitmap-rendering-options">
<title>Runtime Rendering Options</title>
diff --git a/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java b/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java
index 0de02c766..48e79520f 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java
@@ -19,8 +19,6 @@
package org.apache.fop.render.bitmap;
-import org.apache.xmlgraphics.image.writer.ResolutionUnit;
-
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererConfigParser;
import org.apache.fop.render.intermediate.IFContext;
@@ -34,7 +32,6 @@ public class TIFFDocumentHandler extends AbstractBitmapDocumentHandler {
TIFFDocumentHandler(IFContext context) {
super(context);
- getSettings().getWriterParams().setResolutionUnit(ResolutionUnit.CENTIMETER);
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java b/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java
index 1e44397f6..f2535d456 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java
@@ -23,6 +23,8 @@ import java.util.EnumMap;
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.xmlgraphics.image.writer.Endianness;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
@@ -40,7 +42,9 @@ public final class TIFFRendererConfig extends BitmapRendererConfig {
public enum TIFFRendererOption implements RendererConfigOption {
COMPRESSION("compression", PACKBITS),
/** option to encode one row per strip or a all rows in a single strip*/
- SINGLE_STRIP("single-strip", Boolean.FALSE);
+ SINGLE_STRIP("single-strip", Boolean.FALSE),
+ /** option to determine whether to use little or big endian encoding */
+ ENDIANNESS("endianness", Endianness.DEFAULT);
private final String name;
private final Object defaultValue;
@@ -79,6 +83,13 @@ public final class TIFFRendererConfig extends BitmapRendererConfig {
}
/**
+ * @return returns an object to determine whether little or big endian encoding is used
+ */
+ public Endianness getEndianness() {
+ return (Endianness) params.get(TIFFRendererOption.ENDIANNESS);
+ }
+
+ /**
* The TIFF renderer configuration parser.
*/
public static final class TIFFRendererConfigParser extends BitmapRendererConfigParser {
@@ -107,6 +118,8 @@ public final class TIFFRendererConfig extends BitmapRendererConfig {
TIFFCompressionValue.getType(getValue(cfg, TIFFRendererOption.COMPRESSION)));
setParam(TIFFRendererOption.SINGLE_STRIP, Boolean.valueOf(getValue(cfg,
TIFFRendererOption.SINGLE_STRIP)));
+ setParam(TIFFRendererOption.ENDIANNESS,
+ Endianness.getEndianType(getValue(cfg, TIFFRendererOption.ENDIANNESS)));
}
return config;
}
diff --git a/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java b/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java
index 19abb8131..fb24fa7bf 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java
@@ -22,6 +22,8 @@ package org.apache.fop.render.bitmap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.image.writer.Endianness;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.render.Renderer;
@@ -81,6 +83,11 @@ public class TIFFRendererConfigurator extends BitmapRendererConfigurator {
return singleRowPerStrip == null ? false : singleRowPerStrip;
}
+ private Endianness getEndianness(TIFFRendererConfig config) {
+ Endianness endianMode = config.getEndianness();
+ return endianMode == null ? Endianness.DEFAULT : endianMode;
+ }
+
@Override
public void configure(IFDocumentHandler documentHandler) throws FOPException {
final TIFFRendererConfig config = (TIFFRendererConfig) getRendererConfig(documentHandler);
@@ -90,6 +97,7 @@ public class TIFFRendererConfigurator extends BitmapRendererConfigurator {
configure(documentHandler, settings, new TIFFRendererConfigParser());
setCompressionMethod(config.getCompressionType(), settings);
settings.getWriterParams().setSingleStrip(isSingleStrip(config));
+ settings.getWriterParams().setEndianness(getEndianness(config));
}
}
diff --git a/test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java b/test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java
index f39df2988..e2262017f 100644
--- a/test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java
+++ b/test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java
@@ -20,6 +20,7 @@
package org.apache.fop.apps;
import static org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererOption.COMPRESSION;
+import static org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererOption.ENDIANNESS;
import static org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererOption.SINGLE_STRIP;
public class TIFFRendererConfBuilder extends BitmapRendererConfBuilder {
@@ -36,4 +37,9 @@ public class TIFFRendererConfBuilder extends BitmapRendererConfBuilder {
createTextElement(SINGLE_STRIP, String.valueOf(single));
return this;
}
+
+ public TIFFRendererConfBuilder setEndianness(String endianness) {
+ createTextElement(ENDIANNESS, endianness);
+ return this;
+ }
}
diff --git a/test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java b/test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java
index 69326559e..d33076983 100644
--- a/test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java
+++ b/test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java
@@ -21,6 +21,8 @@ package org.apache.fop.render.bitmap;
import org.junit.Test;
+import org.apache.xmlgraphics.image.writer.Endianness;
+
import org.apache.fop.apps.FopConfBuilder;
import org.apache.fop.apps.TIFFRendererConfBuilder;
import org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererConfigParser;
@@ -62,4 +64,12 @@ extends AbstractBitmapRendererConfigParserTester {
parseConfig(createRenderer().setSingleStrip(false));
assertFalse(getConfig().isSingleStrip());
}
+
+ @Test
+ public void testEndianness() throws Exception {
+ for (Endianness value : Endianness.values()) {
+ parseConfig(createRenderer().setEndianness(value.toString()));
+ assertEquals(value, getConfig().getEndianness());
+ }
+ }
}
diff --git a/test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java b/test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java
index 3e6c951a6..b5e6318ce 100644
--- a/test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java
+++ b/test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java
@@ -23,6 +23,7 @@ import java.awt.image.BufferedImage;
import org.junit.Test;
+import org.apache.xmlgraphics.image.writer.Endianness;
import org.apache.fop.apps.FopConfBuilder;
import org.apache.fop.apps.MimeConstants;
@@ -72,4 +73,12 @@ public class TIFFRendererConfiguratorTestCase extends AbstractBitmapRendererConf
assertFalse(settings.getWriterParams().isSingleStrip());
}
+ @Test
+ public void testEndianness() throws Exception {
+ for (Endianness value : Endianness.values()) {
+ parseConfig(createBuilder().setEndianness(value.toString()));
+ assertEquals(value, settings.getWriterParams().getEndianness());
+ }
+ }
+
}