Hi, i try to use the Java Advanced Imaging api with webobjects 5.2.4 with Tiger OS. I will scale at runtime image files that are stored in my SQL Database as a NSData. If i call JAI.create("stream",is); Webobjects starts the Bootstrap.jar and terminates my application. I have no idea what´s the problem.
I hope someone can help me!
Thanks, Raphael
Code: public NSData scaleDownToSize(int width, int height, NSData data){ try{ InputStream is = new ByteArrayInputStream(data.bytes(),0,data.length()); SeekableStream s = SeekableStream.wrapInputStream(is, true); RenderedOp objImage = JAI.create("stream", s); ((OpImage)objImage.getRendering()).setTileCache(null);
//scale 100 float xScale = objImage.getWidth()/width; float yScale = objImage.getHeight()/height;
ParameterBlock pb = new ParameterBlock(); pb.addSource(objImage); // The source image pb.add(xScale); // The xScale pb.add(yScale); // The yScale pb.add(0.0F); // The x translation pb.add(0.0F); // The y translation pb.add(new InterpolationNearest()); // The interpolation
objImage = JAI.create("scale", pb, null);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
JAI.create("encode", objImage, stream, "TIFF", null);
byte[] imageBytes = stream.toByteArray(); NSData result = null;//new NSData(imageBytes);
return result; } catch(Exception e){ System.out.println(e); NSData result = null; }
return null; }
|