You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2007/11/14 13:20:13 UTC

svn commit: r594851 - in /xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test: java/org/apache/fop/image2/ java/org/apache/fop/visual/ resources/images/

Author: jeremias
Date: Wed Nov 14 04:20:12 2007
New Revision: 594851

URL: http://svn.apache.org/viewvc?rev=594851&view=rev
Log:
Test cases and additional test files for the new image package.

Added:
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/image2/
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/image2/ImageLoaderTestCase.java   (with props)
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/image2/ImagePreloaderTestCase.java   (with props)
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/resources/images/img-with-tiff-preview.eps   (with props)
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/resources/images/no-resolution.tif   (with props)
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/resources/images/testChart.wmf
      - copied unchanged from r591256, xmlgraphics/batik/trunk/samples/tests/resources/wmf/testChart.wmf
Modified:
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/visual/BatchDiffer.java

Added: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/image2/ImageLoaderTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/image2/ImageLoaderTestCase.java?rev=594851&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/image2/ImageLoaderTestCase.java (added)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/image2/ImageLoaderTestCase.java Wed Nov 14 04:20:12 2007
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.image2;
+
+import java.io.File;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.image2.impl.ImageRendered;
+import org.apache.fop.image2.impl.ImageXMLDOM;
+import org.apache.xmlgraphics.image.writer.ImageWriterUtil;
+
+/**
+ * Tests for bundled ImageLoader implementations.
+ */
+public class ImageLoaderTestCase extends TestCase {
+
+    private static final File DEBUG_TARGET_DIR = null; //new File("D:/");
+    
+    private FopFactory fopFactory;
+    
+    public ImageLoaderTestCase(String name) {
+        super(name);
+        fopFactory = FopFactory.newInstance();
+        fopFactory.setSourceResolution(72);
+        fopFactory.setTargetResolution(300);
+    }
+    
+    public void testPNG() throws Exception {
+        String uri = "examples/fo/graphics/asf-logo.png";
+        
+        FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        
+        ImageManager manager = fopFactory.getImageManager();
+        ImageInfo info = manager.preloadImage(uri, userAgent);
+        assertNotNull("ImageInfo must not be null", info);
+        
+        Image img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE);
+        assertNotNull("Image must not be null", img);
+        assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
+        ImageRendered imgRed = (ImageRendered)img;
+        assertNotNull(imgRed.getRenderedImage());
+        assertEquals(169, imgRed.getRenderedImage().getWidth());
+        assertEquals(51, imgRed.getRenderedImage().getHeight());
+        info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image
+        assertEquals(126734, info.getSize().getWidthMpt());
+        assertEquals(38245, info.getSize().getHeightMpt());
+    }
+    
+    public void testGIF() throws Exception {
+        String uri = "test/resources/images/bgimg72dpi.gif";
+        
+        FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        
+        ImageManager manager = fopFactory.getImageManager();
+        ImageInfo info = manager.preloadImage(uri, userAgent);
+        assertNotNull("ImageInfo must not be null", info);
+        
+        Image img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE);
+        assertNotNull("Image must not be null", img);
+        assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
+        ImageRendered imgRed = (ImageRendered)img;
+        assertNotNull(imgRed.getRenderedImage());
+        assertEquals(192, imgRed.getRenderedImage().getWidth());
+        assertEquals(192, imgRed.getRenderedImage().getHeight());
+        info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image
+        assertEquals(192000, info.getSize().getWidthMpt());
+        assertEquals(192000, info.getSize().getHeightMpt());
+    }
+    
+    public void testSVG() throws Exception {
+        String uri = "test/resources/images/img-w-size.svg";
+        
+        FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        
+        ImageManager manager = fopFactory.getImageManager();
+        ImageInfo info = manager.preloadImage(uri, userAgent);
+        assertNotNull("ImageInfo must not be null", info);
+        
+        Image img = manager.getImage(info, ImageFlavor.XML_DOM);
+        assertNotNull("Image must not be null", img);
+        assertEquals(ImageFlavor.XML_DOM, img.getFlavor());
+        ImageXMLDOM imgDom = (ImageXMLDOM)img;
+        assertNotNull(imgDom.getDocument());
+        assertEquals("http://www.w3.org/2000/svg", imgDom.getRootNamespace());
+        info = imgDom.getInfo(); //Switch to the ImageInfo returned by the image
+        assertEquals(16000, info.getSize().getWidthMpt());
+        assertEquals(16000, info.getSize().getHeightMpt());
+        
+        img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, getDefaultHints(userAgent));
+        assertNotNull("Image must not be null", img);
+        assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
+        ImageRendered imgRed = (ImageRendered)img;
+        assertNotNull(imgRed.getRenderedImage());
+        if (DEBUG_TARGET_DIR != null) {
+            ImageWriterUtil.saveAsPNG(imgRed.getRenderedImage(),
+                    (int)userAgent.getTargetResolution(),
+                    new File(DEBUG_TARGET_DIR, "out.svg.png"));
+        }
+        assertEquals(67, imgRed.getRenderedImage().getWidth());
+        assertEquals(67, imgRed.getRenderedImage().getHeight());
+        info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image
+        assertEquals(16000, info.getSize().getWidthMpt());
+        assertEquals(16000, info.getSize().getHeightMpt());
+    }
+    
+    public void testWMF() throws Exception {
+        String uri = "test/resources/images/testChart.wmf";
+        
+        FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        
+        ImageManager manager = fopFactory.getImageManager();
+        ImageInfo info = manager.preloadImage(uri, userAgent);
+        assertNotNull("ImageInfo must not be null", info);
+        
+        Image img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, getDefaultHints(userAgent));
+        assertNotNull("Image must not be null", img);
+        assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
+        ImageRendered imgRed = (ImageRendered)img;
+        assertNotNull(imgRed.getRenderedImage());
+        if (DEBUG_TARGET_DIR != null) {
+            ImageWriterUtil.saveAsPNG(imgRed.getRenderedImage(),
+                    (int)userAgent.getTargetResolution(),
+                    new File(DEBUG_TARGET_DIR, "out.wmf.png"));
+        }
+        assertEquals(3300, imgRed.getRenderedImage().getWidth());
+        assertEquals(2550, imgRed.getRenderedImage().getHeight());
+        info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image
+        assertEquals(792000, info.getSize().getWidthMpt());
+        assertEquals(612000, info.getSize().getHeightMpt());
+    }
+ 
+    private Map getDefaultHints(FOUserAgent userAgent) {
+        java.util.Map hints = new java.util.HashMap();
+        hints.put(ImageProcessingHints.SOURCE_RESOLUTION,
+                new Float(userAgent.getSourceResolution()));
+        hints.put(ImageProcessingHints.TARGET_RESOLUTION,
+                new Float(userAgent.getTargetResolution()));
+        return hints;
+    }
+    
+    
+}

Propchange: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/image2/ImageLoaderTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/image2/ImageLoaderTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/image2/ImagePreloaderTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/image2/ImagePreloaderTestCase.java?rev=594851&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/image2/ImagePreloaderTestCase.java (added)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/image2/ImagePreloaderTestCase.java Wed Nov 14 04:20:12 2007
@@ -0,0 +1,250 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.image2;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.image2.impl.batik.ImageWMF;
+import org.apache.fop.image2.spi.ImageLoaderFactory;
+
+/**
+ * Tests for bundled Imagepreloader implementations.
+ */
+public class ImagePreloaderTestCase extends TestCase {
+
+    private FopFactory fopFactory;
+    
+    public ImagePreloaderTestCase(String name) {
+        super(name);
+        fopFactory = FopFactory.newInstance();
+        fopFactory.setSourceResolution(72);
+        fopFactory.setTargetResolution(300);
+    }
+    
+    public void testImageLoaderFactory() throws Exception {
+        ImageManager manager = fopFactory.getImageManager();
+        ImageLoaderFactory ilf = manager.getRegistry().getImageLoaderFactory(
+                MimeConstants.MIME_PNG, ImageFlavor.BUFFERED_IMAGE);
+        assertNotNull(ilf);
+    }
+    
+    public void testPNG() throws Exception {
+        String uri = "examples/fo/graphics/asf-logo.png";
+        
+        FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        
+        ImageManager manager = fopFactory.getImageManager();
+        ImageInfo info = manager.preloadImage(uri, userAgent);
+        assertNotNull("ImageInfo must not be null", info);
+        assertEquals(MimeConstants.MIME_PNG, info.getMimeType());
+        assertEquals("examples/fo/graphics/asf-logo.png", info.getOriginalURI());
+        assertEquals(169, info.getSize().getWidthPx());
+        assertEquals(51, info.getSize().getHeightPx());
+        assertEquals(96, info.getSize().getDpiHorizontal(), 0.1);
+        assertEquals(126734, info.getSize().getWidthMpt());
+        assertEquals(38245, info.getSize().getHeightMpt());
+    }
+    
+    public void testTIFF() throws Exception {
+        String uri = "test/resources/images/tiff_group4.tif";
+        
+        FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        
+        ImageManager manager = fopFactory.getImageManager();
+        ImageInfo info = manager.preloadImage(uri, userAgent);
+        assertNotNull("ImageInfo must not be null", info);
+        assertEquals(MimeConstants.MIME_TIFF, info.getMimeType());
+        assertEquals(uri, info.getOriginalURI());
+        assertEquals(1560, info.getSize().getWidthPx());
+        assertEquals(189, info.getSize().getHeightPx());
+        assertEquals(204, info.getSize().getDpiHorizontal(), 0.1);
+        assertEquals(550588, info.getSize().getWidthMpt());
+        assertEquals(66706, info.getSize().getHeightMpt());
+    }
+    
+    public void testTIFFNoResolution() throws Exception {
+        String uri = "test/resources/images/no-resolution.tif";
+        
+        FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        
+        ImageManager manager = fopFactory.getImageManager();
+        ImageInfo info = manager.preloadImage(uri, userAgent);
+        assertNotNull("ImageInfo must not be null", info);
+        assertEquals(MimeConstants.MIME_TIFF, info.getMimeType());
+        assertEquals(uri, info.getOriginalURI());
+        assertEquals(51, info.getSize().getWidthPx());
+        assertEquals(24, info.getSize().getHeightPx());
+        assertEquals(userAgent.getSourceResolution(), info.getSize().getDpiHorizontal(), 0.1);
+        assertEquals(51000, info.getSize().getWidthMpt());
+        assertEquals(24000, info.getSize().getHeightMpt());
+    }
+    
+    public void testGIF() throws Exception {
+        String uri = "test/resources/images/bgimg72dpi.gif";
+        
+        FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        
+        ImageManager manager = fopFactory.getImageManager();
+        ImageInfo info = manager.preloadImage(uri, userAgent);
+        assertNotNull("ImageInfo must not be null", info);
+        assertEquals(MimeConstants.MIME_GIF, info.getMimeType());
+        assertEquals(uri, info.getOriginalURI());
+        assertEquals(192, info.getSize().getWidthPx());
+        assertEquals(192, info.getSize().getHeightPx());
+        assertEquals(userAgent.getSourceResolution(), info.getSize().getDpiHorizontal(), 0.1);
+        assertEquals(192000, info.getSize().getWidthMpt());
+        assertEquals(192000, info.getSize().getHeightMpt());
+    }
+    
+    public void testSVG() throws Exception {
+        String uri = "test/resources/images/img-w-size.svg";
+        
+        checkSVGFile(uri);
+    }
+
+    public void testSVGZ() throws Exception {
+        String uri = "test/resources/images/img-w-size.svgz";
+        
+        checkSVGFile(uri);
+    }
+
+    private void checkSVGFile(String uri) throws ImageException, IOException {
+        FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        
+        ImageManager manager = fopFactory.getImageManager();
+        ImageInfo info = manager.preloadImage(uri, userAgent);
+        assertNotNull("ImageInfo must not be null", info);
+        assertEquals(MimeConstants.MIME_SVG, info.getMimeType());
+        assertEquals(uri, info.getOriginalURI());
+        assertEquals(16, info.getSize().getWidthPx());
+        assertEquals(16, info.getSize().getHeightPx());
+        assertEquals(72, info.getSize().getDpiHorizontal(), 0.1);
+        assertEquals(16000, info.getSize().getWidthMpt());
+        assertEquals(16000, info.getSize().getHeightMpt());
+    }
+    
+    public void testWMF() throws Exception {
+        String uri = "test/resources/images/testChart.wmf";
+        
+        FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        
+        ImageManager manager = fopFactory.getImageManager();
+        ImageInfo info = manager.preloadImage(uri, userAgent);
+        assertNotNull("ImageInfo must not be null", info);
+        assertEquals(ImageWMF.MIME_WMF, info.getMimeType());
+        assertEquals(uri, info.getOriginalURI());
+        assertEquals(27940, info.getSize().getWidthPx());
+        assertEquals(21590, info.getSize().getHeightPx());
+        assertEquals(2540, info.getSize().getDpiHorizontal(), 0.1);
+        assertEquals(792000, info.getSize().getWidthMpt());
+        assertEquals(612000, info.getSize().getHeightMpt());
+    }
+ 
+    public void testEMF() throws Exception {
+        String uri = "test/resources/images/img.emf";
+        
+        FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        
+        ImageManager manager = fopFactory.getImageManager();
+        ImageInfo info = manager.preloadImage(uri, userAgent);
+        assertNotNull("ImageInfo must not be null", info);
+        assertEquals("image/emf", info.getMimeType());
+        assertEquals(uri, info.getOriginalURI());
+        assertEquals(76, info.getSize().getWidthPx());
+        assertEquals(76, info.getSize().getHeightPx());
+        assertEquals(96, info.getSize().getDpiHorizontal(), 1.0);
+        assertEquals(56665, info.getSize().getWidthMpt());
+        assertEquals(56665, info.getSize().getHeightMpt());
+    }
+ 
+    public void testJPEG() throws Exception {
+        String uri = "test/resources/images/bgimg300dpi.jpg";
+        
+        FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        
+        ImageManager manager = fopFactory.getImageManager();
+        ImageInfo info = manager.preloadImage(uri, userAgent);
+        assertNotNull("ImageInfo must not be null", info);
+        assertEquals(MimeConstants.MIME_JPEG, info.getMimeType());
+        assertEquals(uri, info.getOriginalURI());
+        assertEquals(192, info.getSize().getWidthPx());
+        assertEquals(192, info.getSize().getHeightPx());
+        assertEquals(300, info.getSize().getDpiHorizontal(), 0.1);
+        assertEquals(46080, info.getSize().getWidthMpt());
+        assertEquals(46080, info.getSize().getHeightMpt());
+    }
+ 
+    public void testBMP() throws Exception {
+        String uri = "test/resources/images/bgimg300dpi.bmp";
+        
+        FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        
+        ImageManager manager = fopFactory.getImageManager();
+        ImageInfo info = manager.preloadImage(uri, userAgent);
+        assertNotNull("ImageInfo must not be null", info);
+        assertEquals("image/bmp", info.getMimeType());
+        assertEquals(uri, info.getOriginalURI());
+        assertEquals(192, info.getSize().getWidthPx());
+        assertEquals(192, info.getSize().getHeightPx());
+        assertEquals(300, info.getSize().getDpiHorizontal(), 0.1);
+        assertEquals(46092, info.getSize().getWidthMpt());
+        assertEquals(46092, info.getSize().getHeightMpt());
+    }
+ 
+    public void testEPSAscii() throws Exception {
+        String uri = "test/resources/images/barcode.eps";
+        
+        FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        
+        ImageManager manager = fopFactory.getImageManager();
+        ImageInfo info = manager.preloadImage(uri, userAgent);
+        assertNotNull("ImageInfo must not be null", info);
+        assertEquals(MimeConstants.MIME_EPS, info.getMimeType());
+        assertEquals(uri, info.getOriginalURI());
+        assertEquals(136, info.getSize().getWidthPx());
+        assertEquals(43, info.getSize().getHeightPx());
+        assertEquals(userAgent.getSourceResolution(), info.getSize().getDpiHorizontal(), 0.1);
+        assertEquals(135655, info.getSize().getWidthMpt());
+        assertEquals(42525, info.getSize().getHeightMpt());
+    }
+ 
+    public void testEPSBinary() throws Exception {
+        String uri = "test/resources/images/img-with-tiff-preview.eps";
+        
+        FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        
+        ImageManager manager = fopFactory.getImageManager();
+        ImageInfo info = manager.preloadImage(uri, userAgent);
+        assertNotNull("ImageInfo must not be null", info);
+        assertEquals(MimeConstants.MIME_EPS, info.getMimeType());
+        assertEquals(uri, info.getOriginalURI());
+        assertEquals(17, info.getSize().getWidthPx());
+        assertEquals(17, info.getSize().getHeightPx());
+        assertEquals(userAgent.getSourceResolution(), info.getSize().getDpiHorizontal(), 0.1);
+        assertEquals(17000, info.getSize().getWidthMpt());
+        assertEquals(17000, info.getSize().getHeightMpt());
+    }
+ 
+}

Propchange: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/image2/ImagePreloaderTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/image2/ImagePreloaderTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/visual/BatchDiffer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/visual/BatchDiffer.java?rev=594851&r1=594850&r2=594851&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/visual/BatchDiffer.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/java/org/apache/fop/visual/BatchDiffer.java Wed Nov 14 04:20:12 2007
@@ -20,31 +20,28 @@
 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;
-import java.io.OutputStream;
 import java.util.Collection;
 import java.util.Iterator;
 
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.stream.StreamSource;
 
+import org.xml.sax.SAXException;
+
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.filefilter.IOFileFilter;
 import org.apache.commons.io.filefilter.SuffixFileFilter;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.image.writer.ImageWriterUtil;
+
 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;
 
 /**
  * This class is used to visually diff bitmap images created through various sources.
@@ -110,22 +107,6 @@
     }
 
     /**
-     * Saves a BufferedImage as a PNG file.
-     * @param bitmap the bitmap to encode
-     * @param outputFile the target file
-     * @throws IOException in case of an I/O problem
-     */
-    public static void saveAsPNG(RenderedImage bitmap, File outputFile) throws IOException {
-        OutputStream out = new FileOutputStream(outputFile);
-        try {
-            ImageWriter writer = ImageWriterRegistry.getInstance().getWriterFor("image/png");
-            writer.writeImage(bitmap, out);
-        } finally {
-            IOUtils.closeQuietly(out);
-        }
-    }
-    
-    /**
      * Runs the batch.
      * @param cfgFile configuration file to use
      * @throws ConfigurationException In case of a problem with the configuration
@@ -216,14 +197,14 @@
                     
                     //Save combined bitmap as PNG file
                     File outputFile = new File(targetDir, f.getName() + "._combined.png");
-                    saveAsPNG(combined, outputFile);
+                    ImageWriterUtil.saveAsPNG(combined, outputFile);
 
                     if (createDiffs) {
                         for (int k = 1; k < bitmaps.length; k++) {
                             BufferedImage diff = BitmapComparator.buildDiffImage(
                                     bitmaps[0], bitmaps[k]);
                             outputFile = new File(targetDir, f.getName() + "._diff" + k + ".png");
-                            saveAsPNG(diff, outputFile);
+                            ImageWriterUtil.saveAsPNG(diff, outputFile);
                         }
                     }
                     //Release memory as soon as possible. These images are huge!

Added: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/resources/images/img-with-tiff-preview.eps
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/resources/images/img-with-tiff-preview.eps?rev=594851&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/resources/images/img-with-tiff-preview.eps
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/resources/images/no-resolution.tif
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/resources/images/no-resolution.tif?rev=594851&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/resources/images/no-resolution.tif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org