private void drawJAIImage(String sCodec, InputStream imgSrc, OutputStream outStr, int iThumbWidth, int iThumbHeight, float fQuality)
throws IOException, InterruptedException, NullPointerException, IllegalArgumentException {
RenderedImage oRenderedImg;
PlanarImage oPlI;
RenderedOp oScI;
ParameterBlock oBlk;
ImageEncoder oImgEnc;
ImageDecoder oDecoder;
Log.out.debug("Begin Picture.drawJAIImage("+sCodec+","+String.valueOf(iThumbWidth)+","+String.valueOf(iThumbHeight)+")");
oDecoder = com.sun.media.jai.codec.ImageCodec.createImageDecoder(sCodec, imgSrc, null);
oRenderedImg = oDecoder.decodeAsRenderedImage();
if (sCodec.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);
ParameterBlockJAI pb = new ParameterBlockJAI( "format" );
pb.addSource( oRenderedImg );
oRenderedImg = javax.media.jai.JAI.create( "format", pb, hints );
} catch (IllegalArgumentException iae) {
}
// End increase color depth
} // gif
oPlI = PlanarImage.wrapRenderedImage(oRenderedImg);
int iImageWidth = oPlI.getWidth();
int iImageHeight = oPlI.getHeight();
float thumbRatio = ((float) iThumbWidth) / ((float) iThumbHeight);
float imageRatio = ((float) iImageWidth) / ((float) iImageHeight);