Index: src/openmap/com/bbn/openmap/image/JPEGHelper.java
===================================================================
--- src/openmap/com/bbn/openmap/image/JPEGHelper.java	(revision 2247)
+++ src/openmap/com/bbn/openmap/image/JPEGHelper.java	(working copy)
@@ -1,33 +1,40 @@
 // **********************************************************************
-// 
+//
 // <copyright>
-// 
+//
 //  BBN Technologies
 //  10 Moulton Street
 //  Cambridge, MA 02138
 //  (617) 873-8000
-// 
+//
 //  Copyright (C) BBNT Solutions LLC. All rights reserved.
-// 
+//
 // </copyright>
 // **********************************************************************
-// 
+//
 // $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/image/JPEGHelper.java,v $
 // $RCSfile: JPEGHelper.java,v $
 // $Revision: 1.3 $
 // $Date: 2004/10/14 18:05:51 $
 // $Author: dietrick $
-// 
+//
 // **********************************************************************
 
 package com.bbn.openmap.image;
 
-import com.sun.image.codec.jpeg.*;
 import java.io.*;
 import java.awt.image.*;
 import java.net.URL;
 
 import com.bbn.openmap.util.Debug;
+import java.util.Iterator;
+import javax.imageio.IIOImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.FileImageOutputStream;
+import javax.imageio.stream.ImageOutputStream;
+import javax.imageio.stream.MemoryCacheImageOutputStream;
 
 /**
  * This class provides some utility methods for creating jpeg encoded
@@ -35,127 +42,145 @@
  */
 public class JPEGHelper {
 
-    /**
-     * This class has only static methods, so there is no need to
-     * construct anything.
-     */
-    private JPEGHelper() {};
+	/**
+	 * This class has only static methods, so there is no need to
+	 * construct anything.
+	 */
+	private JPEGHelper() {}
 
-    /**
-     * Return a byte array that contains the JPEG encoded image.
-     * 
-     * @param image the image to encode
-     * @param quality the JPEG quality factor to use in encoding
-     * @exception IOException an error occurred in encoding the image
-     */
-    public static byte[] encodeJPEG(BufferedImage image, float quality)
-            throws IOException {
+	/**
+	 * Return a byte array that contains the JPEG encoded image.
+	 *
+	 * @param image the image to encode
+	 * @param quality the JPEG quality factor to use in encoding
+	 * @exception IOException an error occurred in encoding the image
+	 */
+	public static byte[] encodeJPEG(BufferedImage image, float quality)
+			throws IOException {
+		ByteArrayOutputStream out = new ByteArrayOutputStream();
+		ImageOutputStream iosout = new MemoryCacheImageOutputStream(out);
+		if (Debug.debugging("jpeghelper")) {
+			Debug.output("Got output stream..." + out);
+		}
 
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
-        if (Debug.debugging("jpeghelper")) {
-            Debug.output("Got output stream..." + out);
-        }
+		Iterator<ImageWriter> iter = ImageIO.getImageWritersByFormatName("jpeg");
+		ImageWriter writer = iter.next();
+		ImageWriteParam iwp = writer.getDefaultWriteParam();
+		iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
+		iwp.setCompressionQuality(quality);
+		if (Debug.debugging("jpeghelper")) {
+			Debug.output("Got encode params...");
+		}
 
-        JPEGEncodeParam param = JPEGCodec.getDefaultJPEGEncodeParam(image);
-        param.setQuality(quality, true);
-        if (Debug.debugging("jpeghelper")) {
-            Debug.output("Got encode params...");
-        }
+		writer.setOutput(iosout);
+		if (Debug.debugging("jpeghelper")) {
+			Debug.output("Got jpeg encoder...");
+		}
 
-        JPEGImageEncoder enc = JPEGCodec.createJPEGEncoder(out, param);
-        if (Debug.debugging("jpeghelper")) {
-            Debug.output("Got jpeg encoder...");
-        }
+		IIOImage iioi = new IIOImage(image, null, null);
+		writer.write(null, iioi, iwp);
+		if (Debug.debugging("jpeghelper")) {
+			Debug.output("encoded?");
+		}
 
-        enc.encode(image);
-        if (Debug.debugging("jpeghelper")) {
-            Debug.output("encoded?");
-        }
+		writer.dispose();
 
-        return out.toByteArray();
-    }
+		return out.toByteArray();
+	}
 
-    /**
-     * Return a byte array that contains the JPEG encoded image.
-     * 
-     * @param w the width of the image
-     * @param h the height of the image
-     * @param pixels the array of pixels in RGB directcolor
-     * @param quality the JPEG quality factor to use in encoding
-     * @exception IOException an error occurred in encoding the image
-     */
-    public static byte[] encodeJPEG(int w, int h, int[] pixels, float quality)
-            throws IOException {
-        BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
-        bi.setRGB(0, 0, w, h, pixels, 0, w);
-        pixels = null;
-        return encodeJPEG(bi, quality);
-    }
+	/**
+	 * Return a byte array that contains the JPEG encoded image.
+	 *
+	 * @param w the width of the image
+	 * @param h the height of the image
+	 * @param pixels the array of pixels in RGB directcolor
+	 * @param quality the JPEG quality factor to use in encoding
+	 * @exception IOException an error occurred in encoding the image
+	 */
+	public static byte[] encodeJPEG(int w, int h, int[] pixels, float quality)
+			throws IOException {
+		BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+		bi.setRGB(0, 0, w, h, pixels, 0, w);
+		pixels = null;
+		return encodeJPEG(bi, quality);
+	}
 
-    /**
-     * A test main that encodes an image url at various jpeg quality
-     * factors.
-     * 
-     * @param args url [width height]
-     */
-    public static void main(String args[]) throws Exception {
-        if (args.length == 0) {
-            System.out.println("java jpeg url [width height]");
-            System.exit(-1);
-        }
+	private static void encodeAndWriteJPEGFile(File file, BufferedImage image, float quality)
+			throws IOException {
+		Iterator<ImageWriter> iter = ImageIO.getImageWritersByFormatName("jpeg");
+		ImageWriter writer = iter.next();
+		ImageWriteParam iwp = writer.getDefaultWriteParam();
+		iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
+		iwp.setCompressionQuality(quality);
 
-        Debug.init();
+		FileImageOutputStream output = new FileImageOutputStream(file);
+		writer.setOutput(output);
+		IIOImage iioi = new IIOImage(image, null, null);
+		writer.write(null, iioi, iwp);
+		writer.dispose();
+	}
 
-        int uw = -1;
-        int uh = -1;
-        if (args.length > 1) {
-            uw = Integer.parseInt(args[1]);
-            uh = Integer.parseInt(args[2]);
-        }
+	/**
+	 * A test main that encodes an image url at various jpeg quality
+	 * factors.
+	 *
+	 * @param args url [width height]
+	 */
+	public static void main(String args[]) throws Exception {
+		if (args.length == 0) {
+			System.out.println("java jpeg url [width height]");
+			System.exit(-1);
+		}
 
-        String urlsource = args[0];
-        int lastslash = urlsource.lastIndexOf('/');
-        if (lastslash == -1) {
-            lastslash = 0;
-        } else {
-            lastslash++;
-        }
-        int lastdot = urlsource.lastIndexOf('.');
-        if (lastdot == -1) {
-            lastdot = 0;
-        }
-        String filebase = urlsource.substring(lastslash, lastdot);
+		Debug.init();
 
-        Debug.output("url=" + urlsource + " filebase=" + filebase);
+		int uw = -1;
+		int uh = -1;
+		if (args.length > 1) {
+			uw = Integer.parseInt(args[1]);
+			uh = Integer.parseInt(args[2]);
+		}
 
-        BufferedImage bi = BufferedImageHelper.getBufferedImage(new URL(urlsource),
-                0,
-                0,
-                uw,
-                uh);
-        if (bi == null) {
-            Debug.error("JPEGHelper: Image load failed");
-        } else {
-            PrintStream html = new PrintStream(new FileOutputStream(new File(filebase
-                    + ".html")));
+		String urlsource = args[0];
+		int lastslash = urlsource.lastIndexOf('/');
+		if (lastslash == -1) {
+			lastslash = 0;
+		} else {
+			lastslash++;
+		}
+		int lastdot = urlsource.lastIndexOf('.');
+		if (lastdot == -1) {
+			lastdot = 0;
+		}
+		String filebase = urlsource.substring(lastslash, lastdot);
 
-            html.println("Source url = " + urlsource + " <br>");
-            html.println(" width = " + uw + " height=" + uh + " pixels=" + uw
-                    * uh + " <hr>");
-            for (int i = 0; i < 20; i++) {
-                File f = new File(filebase + ((i < 10) ? "0" : "") + i + ".jpg");
-                float quality = 0.0499f * i;
-                byte data[] = encodeJPEG(bi, quality);
-                OutputStream writef = new FileOutputStream(f);
-                writef.write(data);
-                writef.close();
-                html.println("Image Quality Factor: " + quality + " <br>");
-                html.println("Image Size (bytes) : " + data.length + " <br>");
-                html.println("<img src=\"" + f.getName() + "\"> <hr>");
-            }
+		Debug.output("url=" + urlsource + " filebase=" + filebase);
 
-            html.close();
-        }
-        System.exit(-1); //awt stinks
-    }
-}
\ No newline at end of file
+		BufferedImage bi = BufferedImageHelper.getBufferedImage(new URL(urlsource),
+				0,
+				0,
+				uw,
+				uh);
+		if (bi == null) {
+			Debug.error("JPEGHelper: Image load failed");
+		} else {
+			PrintStream html = new PrintStream(new FileOutputStream(new File(filebase
+					+ ".html")));
+
+			html.println("Source url = " + urlsource + " <br>");
+			html.println(" width = " + uw + " height=" + uh + " pixels=" + uw
+					* uh + " <hr>");
+			for (int i = 0; i < 20; i++) {
+				File f = new File(filebase + ((i < 10) ? "0" : "") + i + ".jpg");
+				float quality = 0.0499f * i;
+				encodeAndWriteJPEGFile(f, bi, quality);
+				html.println("Image Quality Factor: " + quality + " <br>");
+				html.println("Image Size (bytes) : " + f.length() + " <br>");
+				html.println("<img src=\"" + f.getName() + "\"> <hr>");
+			}
+
+			html.close();
+		}
+		System.exit(-1); //awt stinks
+	}
+}
Index: src/openmap/com/bbn/openmap/image/BufferedImageHelper.java
===================================================================
--- src/openmap/com/bbn/openmap/image/BufferedImageHelper.java	(revision 2247)
+++ src/openmap/com/bbn/openmap/image/BufferedImageHelper.java	(working copy)
@@ -1,23 +1,23 @@
 // **********************************************************************
-// 
+//
 // <copyright>
-// 
+//
 //  BBN Technologies
 //  10 Moulton Street
 //  Cambridge, MA 02138
 //  (617) 873-8000
-// 
+//
 //  Copyright (C) BBNT Solutions LLC. All rights reserved.
-// 
+//
 // </copyright>
 // **********************************************************************
-// 
+//
 // $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/image/BufferedImageHelper.java,v $
 // $RCSfile: BufferedImageHelper.java,v $
 // $Revision: 1.9 $
 // $Date: 2006/08/09 21:08:31 $
 // $Author: dietrick $
-// 
+//
 // **********************************************************************
 
 package com.bbn.openmap.image;
@@ -40,7 +40,7 @@
  * This class provides some utility methods for creating a
  * BufferedImage. It will check to see if the Java Advanced Image
  * package is available and use it if it can.
- * 
+ *
  * @author dietrick - original implementation and reflection mods.
  * @author Fredrik Lyden - JAI inspiration and initial code.
  */
@@ -52,7 +52,7 @@
      */
     private BufferedImageHelper() {
     }
-    
+
     /**
      * A test/instantiation copy of the JAI object to use if JAI is
      * installed.
@@ -77,7 +77,7 @@
     /**
      * Run the operation on JAI to create BufferedImage. Uses
      * reflection to determine if JAI is available.
-     * 
+     *
      * @param opName JAI opName, like "file" or "url"
      * @param param JAI object to use for operation, like the file
      *        path (String) or URL.
@@ -158,7 +158,7 @@
      * reflection to determine if JAI is available. If x or y is not
      * zero, or w and h are not the image dimensions, the image
      * returned will be cropped/translated to match the values.
-     * 
+     *
      * @param opName JAI opName, like "file" or "url"
      * @param param JAI object to use for operation, like the file
      *        path (String) or URL.
@@ -193,7 +193,7 @@
 
     /**
      * Return a BufferedImage loaded from a URL.
-     * 
+     *
      * @return BufferedImage if it can be created, null if anything
      *         goes wrong.
      * @throws InterruptedException
@@ -205,7 +205,7 @@
 
     /**
      * Return a BufferedImage loaded from a URL.
-     * 
+     *
      * @param url the source URL
      * @param x x start pixel
      * @param y y start pixel
@@ -222,7 +222,7 @@
         if (url == null) {
             return null;
         }
-        
+
         BufferedImage bi = getJAIBufferedImage("url", url, x, y, w, h);
 
         if (bi != null) {
@@ -239,17 +239,18 @@
             w = ii.getIconWidth();
         if (h <= 0)
             h = ii.getIconHeight();
+
         return getBufferedImage(ii.getImage(),
                 x,
                 y,
                 w,
                 h,
-                BufferedImage.TYPE_INT_ARGB);
+                BufferedImage.TYPE_INT_RGB);
     }
 
     /**
      * Return a BufferedImage loaded from a file path.
-     * 
+     *
      * @return BufferedImage if it can be created, null if anything
      *         goes wrong.
      * @throws InterruptedException
@@ -261,7 +262,7 @@
 
     /**
      * Return a BufferedImage loaded from an image file path.
-     * 
+     *
      * @param path file path to the image
      * @param x x start pixel
      * @param y y start pixel
@@ -296,7 +297,7 @@
                 y,
                 w,
                 h,
-                BufferedImage.TYPE_INT_ARGB);
+                BufferedImage.TYPE_INT_RGB);
     }
 
     /**
@@ -304,7 +305,7 @@
      * is BufferedImage.Type_INT_RGB. If you know the height and
      * width, use them because it's slower to have the class figure it
      * out.
-     * 
+     *
      * @param image the source Image
      * @param x x start pixel
      * @param y y start pixel
@@ -324,7 +325,7 @@
      * Return a BufferedImage loaded from a Image. If you know the
      * height and width, use them because it's slower to have the
      * class figure it out.
-     * 
+     *
      * @param image the source Image
      * @param x x start pixel - the horizontal pixel location in the
      *        returned image that the provided image will be set.
@@ -365,7 +366,7 @@
      * PixelGrabber. Good for when you have an Image, not a
      * BufferedImage, and don't know the width and height. There is a
      * performance penalty with this method, though.
-     * 
+     *
      * @param image the source Image
      * @param x x start pixel - the horizontal pixel location in the
      *        returned image that the provided image will be set.
@@ -408,7 +409,7 @@
          */
         WritableRaster raster = (WritableRaster) bi.getRaster();
         raster.setDataElements(0, 0, w, h, pixels);
-        
+
         if (Debug.debugging("imagehelper")) {
             Debug.output("BufferedImageHelper.getBufferedImage(): set pixels in image...");
         }
Index: src/corba/com/bbn/openmap/layer/rpf/corba/CRFPClient.java
===================================================================
--- src/corba/com/bbn/openmap/layer/rpf/corba/CRFPClient.java	(revision 2247)
+++ src/corba/com/bbn/openmap/layer/rpf/corba/CRFPClient.java	(working copy)
@@ -1,23 +1,23 @@
 // **********************************************************************
-// 
+//
 // <copyright>
-// 
+//
 //  BBN Technologies
 //  10 Moulton Street
 //  Cambridge, MA 02138
 //  (617) 873-8000
-// 
+//
 //  Copyright (C) BBNT Solutions LLC. All rights reserved.
-// 
+//
 // </copyright>
 // **********************************************************************
-// 
+//
 // $Source: /cvs/distapps/openmap/src/corba/com/bbn/openmap/layer/rpf/corba/CRFPClient.java,v $
 // $RCSfile: CRFPClient.java,v $
 // $Revision: 1.6 $
 // $Date: 2005/12/09 21:09:15 $
 // $Author: dietrick $
-// 
+//
 // **********************************************************************
 
 package com.bbn.openmap.layer.rpf.corba;
@@ -48,15 +48,16 @@
 import com.bbn.openmap.proj.Projection;
 import com.bbn.openmap.util.Debug;
 import com.bbn.openmap.util.PropUtils;
-import com.sun.image.codec.jpeg.JPEGCodec;
-import com.sun.image.codec.jpeg.JPEGImageDecoder;
+import javax.imageio.ImageIO;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.MemoryCacheImageInputStream;
 
 /**
  * An implementation of the RpfFrameProvider interface that uses CORBA to get
  * the subframe data via a server. The image data is transmitted in jpeg format.
  * This class requires the sunw package that handles jpeg encoding/decoding.
  * <P>
- * 
+ *
  * The client can connect to the server in two different ways. The client can
  * locate the server using an IOR file that the server has written. This IOR
  * file is read using an URL. The server can also be located using the CORBA
@@ -94,7 +95,7 @@
 
     /**
      * Set the JPEG quality parameter for subframe transfer.
-     * 
+     *
      * @param jq number between 0 and 1, should be between .4 and .8. Anything
      *        else is a waste.
      */
@@ -104,7 +105,7 @@
 
     /**
      * Get the quality setting for JPEG subframe retrieval.
-     * 
+     *
      * @return float reflecting JPEG quality.
      */
     public float getJpegQuality() {
@@ -200,7 +201,7 @@
     /**
      * Set the RpfViewAttribute object parameters, which describes alot about
      * what you'll be asking for later.
-     * 
+     *
      * @param rva the view attributes.
      */
     public void setViewAttributes(RpfViewAttributes rva) {
@@ -222,7 +223,7 @@
      * Given a projection that describes a map or geographical area, return
      * RpfCoverageBoxes that let you know how to locate and ask for
      * RpfSubframes.
-     * 
+     *
      * @param ullat NW latitude.
      * @param ullon NW longitude
      * @param lrlat SE latitude
@@ -261,7 +262,7 @@
      * Given a projection that describes a map or geographical area, return
      * RpfCoverageBoxes that let you know what bounding boxes of data are
      * available.
-     * 
+     *
      * @param ullat NW latitude.
      * @param ullon NW longitude
      * @param lrlat SE latitude
@@ -298,7 +299,7 @@
      * Given an area and a two-letter chart series code, find the percentage of
      * coverage on the map that that chart series can offer. If you want
      * specific coverage information, use the getCatalogCoverage call.
-     * 
+     *
      * @see #getCatalogCoverage(float ullat, float ullon, float lrlat, float
      *      lrlon, Projection p, String chartSeriesCode)
      */
@@ -385,7 +386,7 @@
 
     /**
      * Convert CRFPCoverageBox[] to vector of RpfCoverageBox.
-     * 
+     *
      * @param boxes CRFPCoverageBox[].
      * @return java.util.Vector
      */
@@ -420,7 +421,7 @@
      * tocNumber and entryNumber are given within the RpfCoverageBox received
      * from a getCoverage call. With the CORBA implementation, we are assuming
      * that the byte array is an encoded jpeg image.
-     * 
+     *
      * @param tocNumber the toc id for a RpfTocHandler for a particular frame
      *        provider.
      * @param entryNumber the RpfTocEntry id for a RpfTocHandler for a
@@ -451,10 +452,8 @@
             if (jpegData.length == 0)
                 return null;
 
-            ByteArrayInputStream bais = new ByteArrayInputStream(jpegData);
-            JPEGImageDecoder jid = JPEGCodec.createJPEGDecoder(bais);
-
-            BufferedImage bi = jid.decodeAsBufferedImage();
+			ImageInputStream iis = new MemoryCacheImageInputStream(new ByteArrayInputStream(jpegData));
+            BufferedImage bi = ImageIO.read(iis);
             int height = bi.getHeight();
             int width = bi.getWidth();
             int[] pixels = bi.getRGB(0, 0, width, height, null, 0, width);
@@ -503,7 +502,7 @@
      * the frame and return the attribute information. The tocNumber and
      * entryNumber are given within the RpfCoverageBox received from a
      * getCoverage call.
-     * 
+     *
      * @param tocNumber the toc id for a RpfTocHandler for a particular frame
      *        provider.
      * @param entryNumber the RpfTocEntry id for a RpfTocHandler for a
@@ -535,9 +534,9 @@
 
     /**
      * get the server proxy.
-     * 
+     *
      * @return Server server or null if error.
-     * 
+     *
      */
     public Server getServer() {
         if (server == null)
@@ -547,7 +546,7 @@
 
     /**
      * bind to the server.
-     * 
+     *
      */
     private void initServer() {
         String ior = null;

