X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fmisc%2FWebdbImage.java;h=5a2936a5cb4d91751fe366016221e442227b826d;hb=c6a2204d8d75293256fd17c07e54971d7672359a;hp=99ed77f1dbf46437a7e58ea326ea3c76cf7ffa1b;hpb=f648183ac28a7f1fc1a4dede14065d752404576b;p=mir.git diff --git a/source/mir/misc/WebdbImage.java b/source/mir/misc/WebdbImage.java index 99ed77f1..5a2936a5 100755 --- a/source/mir/misc/WebdbImage.java +++ b/source/mir/misc/WebdbImage.java @@ -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();