aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Hancock <phancock@apache.org>2012-09-13 12:45:27 +0000
committerPeter Hancock <phancock@apache.org>2012-09-13 12:45:27 +0000
commitd99dc75ffa1d37817ce18cff188fdabc29f9f73e (patch)
tree57e54bc96b79ce2980a5ed00afb0bd5ff313aab6
parent03bedaf0caa6c39823437e43b2f8547d476d24e7 (diff)
downloadxmlgraphics-fop-d99dc75ffa1d37817ce18cff188fdabc29f9f73e.tar.gz
xmlgraphics-fop-d99dc75ffa1d37817ce18cff188fdabc29f9f73e.zip
Bugzilla #53865: Add Rows per Strip configuration for Tiff renderer
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1384310 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--lib/xmlgraphics-commons-1.5svn.jarbin603006 -> 607764 bytes
-rw-r--r--src/documentation/content/xdocs/trunk/output.xml5
-rw-r--r--src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java4
-rw-r--r--src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java19
-rw-r--r--src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java8
-rw-r--r--status.xml5
-rw-r--r--test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java7
-rw-r--r--test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java12
-rw-r--r--test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java13
9 files changed, 66 insertions, 7 deletions
diff --git a/lib/xmlgraphics-commons-1.5svn.jar b/lib/xmlgraphics-commons-1.5svn.jar
index 802ae49ae..1a56594b2 100644
--- a/lib/xmlgraphics-commons-1.5svn.jar
+++ b/lib/xmlgraphics-commons-1.5svn.jar
Binary files differ
diff --git a/src/documentation/content/xdocs/trunk/output.xml b/src/documentation/content/xdocs/trunk/output.xml
index 4f792971b..5de820c18 100644
--- a/src/documentation/content/xdocs/trunk/output.xml
+++ b/src/documentation/content/xdocs/trunk/output.xml
@@ -1270,6 +1270,7 @@ Note that the value of the encoding attribute in the example is the double-byte
<source><![CDATA[<renderer mime="image/tiff">
<transparent-page-background>true</transparent-page-background>
<compression>CCITT T.6</compression>
+ <single-strip>true</single-strip>
<fonts><!-- described elsewhere --></fonts>
</renderer>]]></source>
<p>
@@ -1303,6 +1304,10 @@ Note that the value of the encoding attribute in the example is the double-byte
added separately. The internal TIFF codec from XML Graphics Commons only supports PackBits,
Deflate and JPEG compression for writing.
</note>
+ <p>
+ 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>
</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 48e79520f..d536167c3 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java
@@ -19,9 +19,12 @@
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;
+import org.apache.fop.render.intermediate.IFDocumentHandler;
import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator;
/**
@@ -32,6 +35,7 @@ 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 3c833d3b0..1e44397f6 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java
@@ -23,21 +23,24 @@ import java.util.EnumMap;
import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.xmlgraphics.util.MimeConstants;
-
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.MimeConstants;
import org.apache.fop.fonts.DefaultFontConfig;
import org.apache.fop.fonts.DefaultFontConfig.DefaultFontConfigParser;
import org.apache.fop.render.RendererConfigOption;
+import static org.apache.fop.render.bitmap.TIFFCompressionValue.PACKBITS;
+
/**
* The renderer configuration object for the TIFF renderer.
*/
public final class TIFFRendererConfig extends BitmapRendererConfig {
public enum TIFFRendererOption implements RendererConfigOption {
- COMPRESSION("compression", TIFFCompressionValue.PACKBITS);
+ COMPRESSION("compression", PACKBITS),
+ /** option to encode one row per strip or a all rows in a single strip*/
+ SINGLE_STRIP("single-strip", Boolean.FALSE);
private final String name;
private final Object defaultValue;
@@ -68,6 +71,14 @@ public final class TIFFRendererConfig extends BitmapRendererConfig {
}
/**
+ * @return True if all rows are contained in a single strip, False each strip contains one row or null
+ * if not set.
+ */
+ public Boolean isSingleStrip() {
+ return (Boolean) params.get(TIFFRendererOption.SINGLE_STRIP);
+ }
+
+ /**
* The TIFF renderer configuration parser.
*/
public static final class TIFFRendererConfigParser extends BitmapRendererConfigParser {
@@ -94,6 +105,8 @@ public final class TIFFRendererConfig extends BitmapRendererConfig {
if (cfg != null) {
setParam(TIFFRendererOption.COMPRESSION,
TIFFCompressionValue.getType(getValue(cfg, TIFFRendererOption.COMPRESSION)));
+ setParam(TIFFRendererOption.SINGLE_STRIP, Boolean.valueOf(getValue(cfg,
+ TIFFRendererOption.SINGLE_STRIP)));
}
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 593934b45..19abb8131 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java
@@ -76,7 +76,12 @@ public class TIFFRendererConfigurator extends BitmapRendererConfigurator {
}
}
- /** {@inheritDoc} */
+ private boolean isSingleStrip(TIFFRendererConfig config) {
+ Boolean singleRowPerStrip = config.isSingleStrip();
+ return singleRowPerStrip == null ? false : singleRowPerStrip;
+ }
+
+ @Override
public void configure(IFDocumentHandler documentHandler) throws FOPException {
final TIFFRendererConfig config = (TIFFRendererConfig) getRendererConfig(documentHandler);
if (config != null) {
@@ -84,6 +89,7 @@ public class TIFFRendererConfigurator extends BitmapRendererConfigurator {
BitmapRenderingSettings settings = tiffHandler.getSettings();
configure(documentHandler, settings, new TIFFRendererConfigParser());
setCompressionMethod(config.getCompressionType(), settings);
+ settings.getWriterParams().setSingleStrip(isSingleStrip(config));
}
}
diff --git a/status.xml b/status.xml
index 3e73488fb..b39d3d9e0 100644
--- a/status.xml
+++ b/status.xml
@@ -62,6 +62,11 @@
documents. Example: the fix of marks layering will be such a case when it's done.
-->
<release version="FOP Trunk" date="TBD">
+ <action context="Renderers" dev="PH" type="add" fixes-bug="53865" importance="low">
+ Added configuration for RowPerStrip configuration in the Tiff renderer.
+ RowsPerStrip can be configured to 1 or to the total # of rows.
+ See docs for fop.xconf configuration details.
+ </action>
<action context="Layout" dev="VH" type="fix" fixes-bug="53598" due-to="Robert Meyer">
Always set the breakClass field to a legal value in BreakElement, so as to avoid
IllegalArgumentExceptions in other parts of the code.
diff --git a/test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java b/test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java
index 8b72a558d..f39df2988 100644
--- a/test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java
+++ b/test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java
@@ -20,7 +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.SINGLE_STRIP;
public class TIFFRendererConfBuilder extends BitmapRendererConfBuilder {
public TIFFRendererConfBuilder() {
@@ -31,4 +31,9 @@ public class TIFFRendererConfBuilder extends BitmapRendererConfBuilder {
createTextElement(COMPRESSION, mode);
return this;
}
+
+ public TIFFRendererConfBuilder setSingleStrip(boolean single) {
+ createTextElement(SINGLE_STRIP, String.valueOf(single));
+ 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 487b8cb9f..69326559e 100644
--- a/test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java
+++ b/test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java
@@ -26,9 +26,11 @@ import org.apache.fop.apps.TIFFRendererConfBuilder;
import org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererConfigParser;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
public class TIFFRendererConfigParserTestCase
- extends AbstractBitmapRendererConfigParserTester {
+extends AbstractBitmapRendererConfigParserTester {
public TIFFRendererConfigParserTestCase() {
super(new TIFFRendererConfigParser());
@@ -52,4 +54,12 @@ public class TIFFRendererConfigParserTestCase
assertEquals(value, getConfig().getCompressionType());
}
}
+
+ @Test
+ public void testSingleStrip() throws Exception {
+ parseConfig(createRenderer().setSingleStrip(true));
+ assertTrue(getConfig().isSingleStrip());
+ parseConfig(createRenderer().setSingleStrip(false));
+ assertFalse(getConfig().isSingleStrip());
+ }
}
diff --git a/test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java b/test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java
index c97d73333..3e6c951a6 100644
--- a/test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java
+++ b/test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java
@@ -23,7 +23,6 @@ import java.awt.image.BufferedImage;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
import org.apache.fop.apps.FopConfBuilder;
import org.apache.fop.apps.MimeConstants;
@@ -32,6 +31,9 @@ import org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererConfigParser;
import static org.apache.fop.render.bitmap.TIFFCompressionValue.CCITT_T4;
import static org.apache.fop.render.bitmap.TIFFCompressionValue.CCITT_T6;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
public class TIFFRendererConfiguratorTestCase extends AbstractBitmapRendererConfiguratorTest {
@@ -61,4 +63,13 @@ public class TIFFRendererConfiguratorTestCase extends AbstractBitmapRendererConf
}
}
}
+
+ @Test
+ public void testSingleStrip() throws Exception {
+ parseConfig(createBuilder().setSingleStrip(true));
+ assertTrue(settings.getWriterParams().isSingleStrip());
+ parseConfig(createBuilder().setSingleStrip(false));
+ assertFalse(settings.getWriterParams().isSingleStrip());
+ }
+
}