diff options
author | Jeremias Maerki <jeremias@apache.org> | 2007-02-28 10:03:38 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2007-02-28 10:03:38 +0000 |
commit | 3d2ae5e8b67ce957b207422ff4a6e6ba6b696176 (patch) | |
tree | c2467e3e7b96ed66d956483375b04c6e2a6a1f3e /test/java/org | |
parent | 656f061f1740a9c43d98fe868cc3a80747d776a6 (diff) | |
download | xmlgraphics-fop-3d2ae5e8b67ce957b207422ff4a6e6ba6b696176.tar.gz xmlgraphics-fop-3d2ae5e8b67ce957b207422ff4a6e6ba6b696176.zip |
Switch to XGCommons' ImageWriter for writing PNGs.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@512686 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/java/org')
-rw-r--r-- | test/java/org/apache/fop/visual/BatchDiffer.java | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/test/java/org/apache/fop/visual/BatchDiffer.java b/test/java/org/apache/fop/visual/BatchDiffer.java index 2fe836773..b42e440d7 100644 --- a/test/java/org/apache/fop/visual/BatchDiffer.java +++ b/test/java/org/apache/fop/visual/BatchDiffer.java @@ -20,6 +20,7 @@ package org.apache.fop.visual; import java.awt.image.BufferedImage; +import java.awt.image.RenderedImage; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -35,9 +36,6 @@ import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; import org.apache.avalon.framework.container.ContainerUtil; -import org.apache.batik.ext.awt.image.codec.PNGEncodeParam; -import org.apache.batik.ext.awt.image.codec.PNGImageEncoder; - import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.io.filefilter.IOFileFilter; @@ -47,6 +45,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.fop.layoutengine.LayoutEngineTestSuite; +import org.apache.xmlgraphics.image.writer.ImageWriter; +import org.apache.xmlgraphics.image.writer.ImageWriterRegistry; import org.xml.sax.SAXException; @@ -119,13 +119,11 @@ public class BatchDiffer { * @param outputFile the target file * @throws IOException in case of an I/O problem */ - public static void saveAsPNG(BufferedImage bitmap, File outputFile) throws IOException { + public static void saveAsPNG(RenderedImage bitmap, File outputFile) throws IOException { OutputStream out = new FileOutputStream(outputFile); try { - PNGImageEncoder encoder = new PNGImageEncoder( - out, - PNGEncodeParam.getDefaultEncodeParam(bitmap)); - encoder.encode(bitmap); + ImageWriter writer = ImageWriterRegistry.getInstance().getWriterFor("image/png"); + writer.writeImage(bitmap, out); } finally { IOUtils.closeQuietly(out); } @@ -197,9 +195,20 @@ public class BatchDiffer { try { File f = (File)i.next(); log.info("---=== " + f + " ===---"); + long[] times = new long[producers.length]; for (int j = 0; j < producers.length; j++) { + times[j] = System.currentTimeMillis(); bitmaps[j] = producers[j].produce(f, context); + times[j] = System.currentTimeMillis() - times[j]; + } + StringBuffer sb = new StringBuffer("Bitmap production times: "); + for (int j = 0; j < producers.length; j++) { + if (j > 0) { + sb.append(", "); + } + sb.append(times[j]).append("ms"); } + log.info(sb.toString()); //Create combined image if (bitmaps[0] == null) { throw new RuntimeException("First producer didn't return a bitmap." |