aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2006-04-04 15:15:23 +0000
committerJeremias Maerki <jeremias@apache.org>2006-04-04 15:15:23 +0000
commitdece1d7361bfe21604222d1dbfdc1b599084a363 (patch)
tree15e90914861c79b74e32f8ae82176e29d9059c90 /src/java/org/apache/fop/render/bitmap/PNGRenderer.java
parent46f47c3095c086d88ff7d652aee40303a9ed9601 (diff)
downloadxmlgraphics-fop-dece1d7361bfe21604222d1dbfdc1b599084a363.tar.gz
xmlgraphics-fop-dece1d7361bfe21604222d1dbfdc1b599084a363.zip
Adding dependency on XML Graphics Commons.
Switching to code in XML Graphics Commons for: - PSGraphics2D - Service discovery - Codecs Removed local classes that have been ported to Commons. xmlgraphics-commons-snapshot.jar is a Trunk snapshot built with JDK 1.4.2 from today. It should work under JDK 1.3.1. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@391332 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/bitmap/PNGRenderer.java')
-rw-r--r--src/java/org/apache/fop/render/bitmap/PNGRenderer.java26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/java/org/apache/fop/render/bitmap/PNGRenderer.java b/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
index f6ed458c5..e89275484 100644
--- a/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
+++ b/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,9 +26,12 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.batik.ext.awt.image.codec.PNGEncodeParam;
-import org.apache.batik.ext.awt.image.codec.PNGImageEncoder;
+import org.apache.xmlgraphics.image.writer.ImageWriter;
+import org.apache.xmlgraphics.image.writer.ImageWriterParams;
+import org.apache.xmlgraphics.image.writer.ImageWriterRegistry;
+
import org.apache.commons.io.IOUtils;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.area.PageViewport;
@@ -50,9 +53,6 @@ public class PNGRenderer extends Java2DRenderer {
/** The output directory where images are to be written */
private File outputDir;
- /** The PNGEncodeParam for the image */
- private PNGEncodeParam renderParams;
-
/** The OutputStream for the first Image */
private OutputStream firstOutputStream;
@@ -115,17 +115,13 @@ public class PNGRenderer extends Java2DRenderer {
// Encode this image
log.debug("Encoding page " + (i + 1));
- renderParams = PNGEncodeParam.getDefaultEncodeParam(image);
-
- // Set resolution
- float pixSzMM = userAgent.getTargetPixelUnitToMillimeter();
- // num Pixs in 1 Meter
- int numPix = (int)((1000 / pixSzMM) + 0.5);
- renderParams.setPhysicalDimension(numPix, numPix, 1); // 1 means 'pix/meter'
+ ImageWriterParams params = new ImageWriterParams();
+ params.setResolution(Math.round(userAgent.getTargetResolution()));
// Encode PNG image
- PNGImageEncoder encoder = new PNGImageEncoder(os, renderParams);
- encoder.encode(image);
+ ImageWriter writer = ImageWriterRegistry.getInstance().getWriterFor(getMimeType());
+ log.debug("Writing image using " + writer.getClass().getName());
+ writer.writeImage(image, os, params);
} finally {
//Only close self-created OutputStreams
if (os != firstOutputStream) {