Skip to main content

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

1 reply [Last post]
Anonymous

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;
try
{
ImageInputStream iis = ImageIO.createImageInputStream(new ByteArrayInputStream(imageBuffer));
Iterator readers = ImageIO.getImageReadersByFormatName("jpeg2000");

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

reader.setInput(iis, true);
BufferedImage bi = reader.read(0);
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: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Reply viewing options

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

Good! ;-)

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