private void drawJAIImage(OutputStream outStr, int iThumbWidth, int iThumbHeight, float fQuality)
throws IOException, InterruptedException, NullPointerException, IllegalArgumentException {
com.sun.media.jai.codec.ImageDecoder oDecoder;
RenderedImage oRenderedImg;
javax.media.jai.PlanarImage oPlI;
javax.media.jai.PlanarImage oScI;
ParameterBlock oBlk;
com.sun.media.jai.codec.ImageEncoder oImgEnc;
String sInputURI;
InputStream oInputStream;
URL oURI;
if (DebugFile.trace) {
DebugFile.writeln("Begin Image.drawJAIImage([OutputStream], " + String.valueOf(iThumbWidth) + "," + String.valueOf(iThumbHeight) + "," + String.valueOf(fQuality) + ")");
DebugFile.incIdent();
}
sInputURI = getString(DB.path_image);
if (sInputURI.startsWith("http://") || sInputURI.startsWith("https://")) {
if (DebugFile.trace) DebugFile.writeln("new URL(" + sInputURI + ")");
oURI = new URL(sInputURI);
oInputStream = oURI.openStream();
}
else {
if (DebugFile.trace) DebugFile.writeln("new FileInputStream(" + sInputURI + ")");
try {
oInputStream = new FileInputStream(sInputURI);
} catch (FileNotFoundException fnf) {
if (DebugFile.trace) DebugFile.decIdent();
throw new FileNotFoundException(fnf.getMessage());
}
}
oDecoder = com.sun.media.jai.codec.ImageCodec.createImageDecoder(getImageCodec(), oInputStream, null);
oRenderedImg = oDecoder.decodeAsRenderedImage();
if (getImageType().equals("gif")) {
// Increase color depth to 16M RGB
try {
javax.media.jai.ImageLayout layout = new javax.media.jai.ImageLayout();
ColorModel cm = new ComponentColorModel (ColorSpace.getInstance(ColorSpace.CS_sRGB),
new int[] {8,8,8}, false, false,
Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
layout.setColorModel(cm);
layout.setSampleModel(cm.createCompatibleSampleModel(oRenderedImg.getWidth(),oRenderedImg.getHeight()));
RenderingHints hints = new RenderingHints(javax.media.jai.JAI.KEY_IMAGE_LAYOUT, layout);
javax.media.jai.ParameterBlockJAI pb = new javax.media.jai.ParameterBlockJAI( "format" );
pb.addSource( oRenderedImg );
oRenderedImg = javax.media.jai.JAI.create( "format", pb, hints );
} catch (IllegalArgumentException iae) {
if (DebugFile.trace) DebugFile.writeln(iae.getMessage() + " " + oRenderedImg.getColorModel().getClass().getName() + " " + oRenderedImg.getSampleModel().getClass().getName());
}
// End increase color depth
} // gif
oPlI = javax.media.jai.PlanarImage.wrapRenderedImage(oRenderedImg);