Hi,
I’m trying to load a tiff image straight into a byte array, but seem to be struggling. At the moment I’m trying JAI to do it:
File imgFile = new ("c:\\image.tif");
ImageInputStream stream = ImageIO.createImageInputStream;
Iterator iter = ImageIO.getImageReaders(stream);
if (iter.hasNext())
{
ImageReader reader = (ImageReader)iter.next();
reader.setInput(stream, true, true);
int w = reader.getWidth(0);
int h = reader.getHeight(0);
byte[] b = new byte[w*h*3];
stream.read(b);
}
The trouble is, this creates an image which is 90% black with a load of colour at the end. So I’m presuming that it’s not been decoded and decompressed.
I guess what I’m really what I’m looking for is:
reader.read(b);
but this doesn’t seem to be available. It seems like it should be a fairly common thing to want to do, so I was wondering if it was possible in JAI or any other APIs. I’ve spent quite a few days trawling through the javadocs and so far not managed to come up with nothing. Any help would be great!