first cut of merge of STABLE-pre1_0 into HEAD. I won't even guarantee that it
[mir.git] / source / mir / misc / WebdbImage.java
index 99ed77f..5a2936a 100755 (executable)
@@ -17,17 +17,12 @@ import java.awt.image.renderable.ParameterBlock;
 public class WebdbImage
 {
 
-       // imageTypes
-       public final static int        WEBDB_JPG=0;
-       public final static int        WEBDB_GIF=1;
-
        // default values for scaling
        private int               maxIconSize=120;
        private int               maxImageSize=640;
 
        private byte[]            iconData;
        private byte[]            imageData;
-       private int               imageType;
        private int               iconWidth;
        private int               iconHeight;
 
@@ -36,27 +31,24 @@ public class WebdbImage
 
 
        // constructor
-       public WebdbImage(byte[] image, int type)
+       public WebdbImage(byte[] image)
                throws IOException
        {
-               imageType=type;
                planarImage = JAI.create("stream",new ByteArraySeekableStream(image));
                scaleImage();
        }
 
-       public WebdbImage(byte[] image, int type, int iconMax)
+       public WebdbImage(byte[] image, int iconMax)
                throws IOException
        {
-               imageType=type;
                maxIconSize=iconMax;
                planarImage = JAI.create("stream",new ByteArraySeekableStream(image));
                scaleImage();
        }
 
-       public WebdbImage(byte[] image, int type, int iconMax, int imageMax)
+       public WebdbImage(byte[] image, int iconMax, int imageMax)
                throws IOException
        {
-               imageType=type;
                maxIconSize=iconMax;
                maxImageSize=imageMax;
                planarImage = JAI.create("stream",new ByteArraySeekableStream(image));
@@ -86,16 +78,8 @@ public class WebdbImage
        public byte[] getImage() {
                if (imageData==null) {
                        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-
-                       switch (imageType) {
-                               case WEBDB_JPG:
-                                       JAI.create("encode", planarImage, outStream, "JPEG", null);break;
-                               case WEBDB_GIF:
-                                       JAI.create("encode", planarImage, outStream, "JPEG", null);break;
-                               default:
-                                       System.err.println("unknown image format: " + imageType);
-                       }
-
+            // @todo the choice of PNG or JPEG should be made configurable
+            JAI.create("encode", planarImage, outStream, "PNG", null);
                        imageData = outStream.toByteArray();
                }
                return imageData;
@@ -137,15 +121,8 @@ public class WebdbImage
                        InterpolationBilinear interp = new InterpolationBilinear();
                        PlanarImage temp = JAI.create("scale", planarImage, scale, scale, 0.0F, 0.0F, interp);
                        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-                       /** @todo gif */
-                       switch (imageType) {
-                               case WEBDB_JPG:
-                                       JAI.create("encode", temp, outStream, "JPEG", null);break;
-                               case WEBDB_GIF:
-                                       JAI.create("encode", temp, outStream, "JPEG", null);break;
-                               default:
-                                       System.err.println("unknown image format: " + imageType);
-                       }
+            // @todo the choice of PNG or JPEG should be made configurable
+            JAI.create("encode", temp, outStream, "PNG", null);
                        iconData = outStream.toByteArray();
                        iconWidth=temp.getWidth();
                        iconHeight=temp.getHeight();