Skip to main content

Urgent! How to get a handle of output stream from JAI ?

1 reply [Last post]
Joined: 2006-02-17

I need know how to get the output stream so I can feed the stream to an input stream.

The reason I need do some like this is that after all JAI.create() commands I need ftp the image created in memory directly. In another word, I want to skip JAI.create("filestore") command at all.

Is this accomplishable? Thank you for your info and advise.


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-04-19

Hi Robert,

There are two options that would serve your purpose.

1. You can use the JAI "encode" operation to encode the image to an image file format. However instead of supplying a file based OutputStream, you can create a ByteArrayOutputStream and pass that to encode. This way the encoded bytes are available from the ByteArrayOutputStream.toByteArray() method. The byte array can then be written to an OutputStream and read back into a ByteArrayInputStream, from which the image can be re-created by "fileload".

2. Use the class to serialize the image. The SerializableRenderedImage can then be written out to an OutputStream (serialized) and read back (de-serialized) on the other end with an InputStream.