Skip to main content

[JAI-IMAGEIO] RE: How do I read a j2c file...

1 reply [Last post]

Well, I did the following. It seems to work. Note that I read the image file bytes into a byte array first. The code below suceeds without exception. I haven't really drawn the image yet. Works for JPEG and JPEG2000 just by changing the "jpeg" to "jpeg2000" and in the debugger the image looks the right size and shape.

ImageIO is a lot simpler to use than the old createImage() stuff. I'm pleased -- depending on how the image actually looks -- tomorrow.

So I guess I've answered my questions....


private boolean makeImage()
boolean status = true;
ImageInputStream iis = ImageIO.createImageInputStream(new ByteArrayInputStream(imageBuffer));
Iterator readers = ImageIO.getImageReadersByFormatName("jpeg2000");

ImageReader reader = (ImageReader);
System.err.println("Got a reader -- " + reader.getFormatName());
String [] formatNames = ImageIO.getReaderFormatNames();
for( int i = 0; i < formatNames.length; i++ )

reader.setInput(iis, true);
BufferedImage bi =;
System.err.println("Made an image...");
catch (IllegalArgumentException iae)
System.err.println("Illegal Arguement Exception...");
status = false;

catch (IOException ioe)
System.err.println("IO Exception...");
status = false;

return status;

To unsubscribe, e-mail:
For additional commands, e-mail:

Reply viewing options

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

Good! ;-)

> So I guess I've answered my questions....