Problem with scaling

Hi,

I was using the following code:

InputStream imageData/*= .initialization code*/;

try{

byte[] bytes = FileCopyUtils.copyToByteArray(imageData);

RenderedOp renderedOp = JAI.create("stream",new ByteArraySeekableStream(bytes));// byte[]

ParameterBlock pb =new ParameterBlock();

pb.addSource( renderedOp );

pb.add( 1.0F );

pb.add( 1.0F );

pb.add( 0.0F );

pb.add( 0.0F );

pb.add(new InterpolationBilinear() );

BorderExtender border = BorderExtender.createInstance( BorderExtender.BORDER_COPY );

RenderingHints rh =new RenderingHints( JAI.KEY_BORDER_EXTENDER,border );

PlanarImage pi = JAI.create("scale", pb, rh );

ByteArrayOutputStream os =new ByteArrayOutputStream();

JAI.create("filestore", pi, os,"JPG",null);

return os.toByteArray();

}catch(Exception e){

log.debug("Image exception: "+e.toString());

}

And the output I gott was:

Image exception: java.lang.IllegalArgumentException: FileStore - Para

meter value`s class (java.io.ByteArrayOutputStream) is not an instance of the pa

rameter class (java.lang.String) for parameter "filename".

What could be the reason? Please help.

[1882 byte] By [amishera2006a] at [2007-11-27 7:39:27]
# 1

> Image exception:

> java.lang.IllegalArgumentException: FileStore - Para

> meter value`s class (java.io.ByteArrayOutputStream)

> is not an instance of the pa

> rameter class (java.lang.String) for parameter

> "filename".

>

> What could be the reason? Please help.

The reason is described in this exception, isn't it?

You're trying to push ByteArrayOutputStream as parameter to "filestore" method but it needs just filename for file where to store

It is common problem with JAI as there are no good docs/API docs on it

trauta at 2007-7-12 19:20:08 > top of Java-index,Security,Cryptography...