Revision: 4338
          http://sourceforge.net/p/jump-pilot/code/4338
Author:   ma15569
Date:     2015-03-15 15:04:21 +0000 (Sun, 15 Mar 2015)
Log Message:
-----------
2015-03-15 Giuseppe Aruta (ma15569) 
  * Add RasterImageIOUtils.class, with various methods to perform
    some raster image  Input/Output operations

Modified Paths:
--------------
    core/trunk/ChangeLog
    core/trunk/src/org/openjump/core/rasterimage/RasterImageIOUtils.java

Modified: core/trunk/ChangeLog
===================================================================
--- core/trunk/ChangeLog        2015-03-14 16:55:27 UTC (rev 4337)
+++ core/trunk/ChangeLog        2015-03-15 15:04:21 UTC (rev 4338)
@@ -1,5 +1,9 @@
 # for display continuity sake please use 2 spaces instead of tabs
 
+2015-03-15 Giuseppe Aruta (ma15569) 
+  * Add RasterImageIOUtils.class, with various methods to perform
+    some raster image  Input/Output operations
+
 2015-03-14 mmichaud <m.michael.mich...@orange.fr>
   * Manage new attribute types BOOLEAN and LONG in jml and shp drivers
     (also manage other datatypes so that they can be written as one

Modified: core/trunk/src/org/openjump/core/rasterimage/RasterImageIOUtils.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/RasterImageIOUtils.java        
2015-03-14 16:55:27 UTC (rev 4337)
+++ core/trunk/src/org/openjump/core/rasterimage/RasterImageIOUtils.java        
2015-03-15 15:04:21 UTC (rev 4338)
@@ -3,6 +3,7 @@
 import java.awt.Point;
 import java.awt.geom.NoninvertibleTransformException;
 import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
 import java.awt.image.Raster;
 import java.io.File;
 import java.io.FileInputStream;
@@ -82,6 +83,31 @@
                         .getNoDataValue());
     }
 
+    /**
+     * Export selected raster to various image file formats using ImageIO
+     * 
+     * @param File
+     *            destination file (absolute or relative path)
+     * @param format
+     *            Image I/O built-in support for both Oracle Java and OpenJDK 
is
+     *            "gif", "png" and "tif". Oracle Java support also "jpg". Other
+     *            formats might be work depending on installed codecs
+     * @param BufferedImag
+     *            bufferedimage
+     * @param Envelope
+     *            envelope
+     * @throws IOException
+     */
+
+    public static void saveImage(File file, String format,
+            BufferedImage bufferedimage, Envelope envelope) throws IOException 
{
+        ImageIO.write(bufferedimage, format, file);
+        WorldFileHandler worldFileHandler = new WorldFileHandler(
+                file.getAbsolutePath(), false);
+        worldFileHandler.writeWorldFile(envelope, bufferedimage.getWidth(),
+                bufferedimage.getHeight());
+
+    }
     
     /**
      * Export selected raster to TIF/TFW - using ImageIO.class
@@ -520,7 +546,7 @@
      *            . Name of the category to load the file
      */
 
-    public static void loadTIF(File file, PlugInContext context, String 
catName)
+    public static void loadTIF(File file, PlugInContext context, String 
category)
             throws NoninvertibleTransformException, TiffReadingException,
             Exception {
 
@@ -541,11 +567,11 @@
                 file.getAbsolutePath(), imageAndMetadata.getImage(), env);
         //String catName = StandardCategoryNames.RESULT;
         try {
-            catName = ((Category) context.getLayerNamePanel()
+            category = ((Category) context.getLayerNamePanel()
                     .getSelectedCategories().toArray()[0]).getName();
         } catch (RuntimeException e1) {
         }
-        context.getLayerManager().addLayerable(catName, ril);
+        context.getLayerManager().addLayerable(category, ril);
 
     }
 


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to