diff options
-rw-r--r-- | lib/xmlgraphics-commons-1.4svn.jar | bin | 562817 -> 568485 bytes | |||
-rw-r--r-- | src/documentation/content/xdocs/trunk/configuration.xml | 36 | ||||
-rw-r--r-- | src/java/org/apache/fop/apps/FopFactoryConfigurator.java | 36 | ||||
-rw-r--r-- | src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java | 5 | ||||
-rw-r--r-- | src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java | 5 | ||||
-rw-r--r-- | status.xml | 3 |
6 files changed, 75 insertions, 10 deletions
diff --git a/lib/xmlgraphics-commons-1.4svn.jar b/lib/xmlgraphics-commons-1.4svn.jar Binary files differindex aaf991377..4f82992d3 100644 --- a/lib/xmlgraphics-commons-1.4svn.jar +++ b/lib/xmlgraphics-commons-1.4svn.jar diff --git a/src/documentation/content/xdocs/trunk/configuration.xml b/src/documentation/content/xdocs/trunk/configuration.xml index 7fc0d97d9..eaa788990 100644 --- a/src/documentation/content/xdocs/trunk/configuration.xml +++ b/src/documentation/content/xdocs/trunk/configuration.xml @@ -218,6 +218,42 @@ <!-- etc. etc..... --> </fop>]]></source> </section> + <section id="image-loading"> + <title>Image Loading Customization</title> + <p> + Apache FOP uses the image loading framework from + <a href="http://xmlgraphics.apache.org/commons/">Apache XML Graphics Commons</a> to load + images using various plug-ins. Every image loader plug-in has a hard-coded usage penalty + that influences which solution is chosen if there are multiple possibilities to load an image. + Sometimes, though, these penalties need to be tweaked and this can be done in the FOP + configuration. An example: + </p> + <source><![CDATA[<fop version="1.0"> + [..] + <image-loading> + <penalty value="10000" + class="org.apache.xmlgraphics.image.loader.impl.ImageLoaderRawCCITTFax"/> + <penalty value="INFINITE" + class="org.apache.xmlgraphics.image.loader.impl.ImageLoaderInternalTIFF"/> + </image-loading> + <renderers.... +</fop>]]></source> + <p> + The first penalty element increases the penalty for the raw CCITT loader. This practically + forces the decoding of CCITT compressed TIFF images except if there are no TIFF codecs + available. + </p> + <p> + The second penalty element sets an "infinite" penalty for the TIFF loader using the internal + TIFF codec. This practically disables that plug-in as it will never be chosen as a possible + solution. + </p> + <p> + Negative penalties are possible to promote a plug-in but a negative penalty sum will be + treated as zero penalty in most cases. For more details on the image loading framework, + please consult the documentation there. + </p> + </section> <section id="renderers"> <title>Renderer configuration</title> <p> diff --git a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java b/src/java/org/apache/fop/apps/FopFactoryConfigurator.java index a8b964a5d..736ae05d8 100644 --- a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java +++ b/src/java/org/apache/fop/apps/FopFactoryConfigurator.java @@ -31,6 +31,9 @@ import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry; +import org.apache.xmlgraphics.image.loader.util.Penalty; + import org.apache.fop.fonts.FontManager; import org.apache.fop.fonts.FontManagerConfigurator; import org.apache.fop.util.LogUtil; @@ -198,6 +201,39 @@ public class FopFactoryConfigurator { FontManager fontManager = factory.getFontManager(); FontManagerConfigurator fontManagerConfigurator = new FontManagerConfigurator(cfg); fontManagerConfigurator.configure(fontManager, strict); + + // configure image loader framework + configureImageLoading(cfg.getChild("image-loading", false), strict); + } + + private void configureImageLoading(Configuration parent, boolean strict) throws FOPException { + if (parent == null) { + return; + } + ImageImplRegistry registry = factory.getImageManager().getRegistry(); + Configuration[] penalties = parent.getChildren("penalty"); + try { + for (int i = 0, c = penalties.length; i < c; i++) { + Configuration penaltyCfg = penalties[i]; + String className = penaltyCfg.getAttribute("class"); + String value = penaltyCfg.getAttribute("value"); + Penalty p = null; + if (value.toUpperCase().startsWith("INF")) { + p = Penalty.INFINITE_PENALTY; + } else { + try { + p = Penalty.toPenalty(Integer.parseInt(value)); + } catch (NumberFormatException nfe) { + LogUtil.handleException(log, nfe, strict); + } + } + if (p != null) { + registry.setAdditionalPenalty(className, p); + } + } + } catch (ConfigurationException e) { + LogUtil.handleException(log, e, strict); + } } /** diff --git a/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java b/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java index b37ba925b..3add8be8b 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java @@ -52,11 +52,6 @@ public class ImageLoaderFactorySVG extends AbstractImageLoaderFactory { } /** {@inheritDoc} */ - public int getUsagePenalty(String mime, ImageFlavor flavor) { - return 0; - } - - /** {@inheritDoc} */ public boolean isAvailable() { return BatikUtil.isBatikAvailable(); } diff --git a/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java b/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java index 6c5384bdb..eaefe9efe 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java @@ -50,11 +50,6 @@ public class ImageLoaderFactoryWMF extends AbstractImageLoaderFactory { } /** {@inheritDoc} */ - public int getUsagePenalty(String mime, ImageFlavor flavor) { - return 0; - } - - /** {@inheritDoc} */ public boolean isAvailable() { return BatikUtil.isBatikAvailable(); } diff --git a/status.xml b/status.xml index dab39c99d..3925cac48 100644 --- a/status.xml +++ b/status.xml @@ -58,6 +58,9 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> <release version="FOP Trunk" date="TBD"> + <action context="Images" dev="JM" type="add"> + Added customization ability for the image loading framework from FOP's configuration file. + </action> <action context="Renderers" dev="JM" type="fix" fixes-bug="48696" due-to="Peter Hancock"> Bugfix for color model in IOCA IDE structure parameter for 4- and 8-bit grayscale images. </action> |