xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r446706 - /xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java
Date Fri, 15 Sep 2006 19:54:23 GMT
Author: jeremias
Date: Fri Sep 15 12:54:23 2006
New Revision: 446706

URL: http://svn.apache.org/viewvc?view=rev&rev=446706
Log:
Bugfix: Added missing close() on the output stream. Temporary files don't get deleted and
the image file may not be properly written.
Remove System.out.println()

Modified:
    xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java

Modified: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java?view=diff&rev=446706&r1=446705&r2=446706
==============================================================================
--- xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java
(original)
+++ xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java
Fri Sep 15 12:54:23 2006
@@ -76,28 +76,33 @@
             iiowriter.addIIOWriteWarningListener(this);
             
             ImageOutputStream imgout = ImageIO.createImageOutputStream(out);
-            
-            ImageWriteParam iwParam = getDefaultWriteParam(iiowriter, image, params);
-            
-            ImageTypeSpecifier type;
-            if (iwParam.getDestinationType() != null) {
-                type = iwParam.getDestinationType();
-            } else {
-                type = ImageTypeSpecifier.createFromRenderedImage(image);
+            try {
+                
+                ImageWriteParam iwParam = getDefaultWriteParam(iiowriter, image, params);
+                
+                ImageTypeSpecifier type;
+                if (iwParam.getDestinationType() != null) {
+                    type = iwParam.getDestinationType();
+                } else {
+                    type = ImageTypeSpecifier.createFromRenderedImage(image);
+                }
+                
+                //Handle metadata
+                IIOMetadata meta = iiowriter.getDefaultImageMetadata(
+                        type, iwParam);
+                //meta might be null for some JAI codecs as they don't support metadata
+                if (params != null && meta != null) {
+                    meta = updateMetadata(meta, params); 
+                }
+                
+                //Write image
+                iiowriter.setOutput(imgout);
+                IIOImage iioimg = new IIOImage(image, null, meta);
+                iiowriter.write(null, iioimg, iwParam);
+                
+            } finally {
+                imgout.close();
             }
-            
-            //Handle metadata
-            IIOMetadata meta = iiowriter.getDefaultImageMetadata(
-                    type, iwParam);
-            //meta might be null for some JAI codecs as they don't support metadata
-            if (params != null && meta != null) {
-                meta = updateMetadata(meta, params); 
-            }
-            
-            //Write image
-            iiowriter.setOutput(imgout);
-            IIOImage iioimg = new IIOImage(image, null, meta);
-            iiowriter.write(null, iioimg, iwParam);
         } else {
             throw new UnsupportedOperationException("No ImageIO codec for writing " 
                     + getMIMEType() + " is available!");
@@ -116,7 +121,7 @@
             javax.imageio.ImageWriter iiowriter, RenderedImage image, 
             ImageWriterParams params) {
         ImageWriteParam param = iiowriter.getDefaultWriteParam();
-        System.err.println("Param: " + params);
+        //System.err.println("Param: " + params);
         if ((params != null) && (params.getCompressionMethod() != null)) {
             param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
             param.setCompressionType(params.getCompressionMethod());



---------------------------------------------------------------------
Apache XML Graphics Project URL: http://xmlgraphics.apache.org/
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


Mime
View raw message