Click to See Complete Forum and Search --> : Displaying "RenderedOp objImage" in JSP


Leon945
10-10-2006, 11:45 AM
Hello people..
as you may have noticed, i am a kind of newbie guy to java..
anyway the point is i do not have alot of experience..

I'm using JSP and i'm trying to display an image which is on the server at a smaller scale...

I found a way to resize the image using JAI (Java Advanced Imaging), which generates a RenderedOp object containing the resulting scaled image...

what i want to know is:
how can i display the resulting image in a JSP?

i'll be researching on this, but any help anyone can provide would be great!
thanks in advance..

here is the code i have in my JSP to resize the image:


RenderedOp objImage = null;
try{
InputStream is = new FileInputStream(results.getString("imagen"));
SeekableStream s = SeekableStream.wrapInputStream(is, true);
objImage = JAI.create("stream", s);
((OpImage)objImage.getRendering()).setTileCache(null);
} catch(FileNotFoundException e){
e.printStackTrace();
}
float xScale = 100/objImage.getWidth();
float yScale = 100/objImage.getHeight();
ParameterBlock pb = new ParameterBlock();
pb.addSource(objImage);
pb.add(xScale);
pb.add(yScale);
pb.add(0.0F);
pb.add(0.0F);
pb.add(new InterpolationNearest());

objImage = JAI.create("scale", pb, null);