Dear Web,
I have the following problem: I need to adapt some code that reads an image from a file using JAI to read it from an array of bytes having exactly the same content as the file. The code for reading from a file is quite simple:
RenderedOp img = JAI.create("fileload", "filename.jpg");
My problem is that I don’t have the JPEG file on disk, but it’s in memory inside a byte[] and I guess that I should do something along the lines of:
RenderedOp img = JAI.create("WHOKNOWS", data);
Or:
RenderedOp img = JAI.create("WHOKNOWS", new ByteArrayInputStream(data));
I couldn’t find anything googling around, the JAI documentation is a mess and the FAQ is of no help.
Please help! What operation name should I use instead of “WHOKNOWS”, assuming what I’m trying to do is even possible?
Please note that the byte array does not contain a raster, but a JPEG-encoded image.


Search in google for ByteArraySeekableStream. Here’s an example:
http://www.mdsplus.org/cgi-bin/MDSplusCVS/javascope/FrameJAI.java?rev=1.13
Maybe “stream”?
Thanks Davanum, that did the trick!
Could you please add an example on this site. Davanum’s link is broken.
plase, can you post an example of Davanum’s site…
Davanum’s link is broken.
Please
I m having same problem ..
Just thought I’d post another option if you had it as an InputStream instead.
I think a similar thing would work for ByteArraySeekableStream as well…
SeekableStream seekableStream = SeekableStream.wrapInputStream(stream,false);
PlanarImage planarImage = JAI.create(”Stream”, seekableStream);