Browse Source

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
tags/fop-2_0
Peter Hancock 11 years ago
parent
commit
d99dc75ffa

BIN
lib/xmlgraphics-commons-1.5svn.jar View File


+ 5
- 0
src/documentation/content/xdocs/trunk/output.xml View File

@@ -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>

+ 4
- 0
src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java View File

@@ -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} */

+ 16
- 3
src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java View File

@@ -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;
@@ -67,6 +70,14 @@ public final class TIFFRendererConfig extends BitmapRendererConfig {
return (TIFFCompressionValue) params.get(TIFFRendererOption.COMPRESSION);
}

/**
* @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.
*/
@@ -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;
}

+ 7
- 1
src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java View File

@@ -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));
}
}


+ 5
- 0
status.xml View File

@@ -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.

+ 6
- 1
test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java View File

@@ -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;
}
}

+ 11
- 1
test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java View File

@@ -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());
}
}

+ 12
- 1
test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java View File

@@ -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());
}

}

Loading…
Cancel
Save