} else
throw new IllegalArgumentException("Unsupported Input type:" + input);
PlanarImage planarImage;
ImageReader reader;
ImageReaderSpi readerSpi = spi;
if (useJAI) {
final ParameterBlock pbjImageRead = new ParameterBlock();
pbjImageRead.add(paramInput);
pbjImageRead.add(imageIndex);
pbjImageRead.add(Boolean.FALSE);
pbjImageRead.add(Boolean.FALSE);
pbjImageRead.add(Boolean.FALSE);
pbjImageRead.add(null);
pbjImageRead.add(null);
pbjImageRead.add(imageReadParam);
reader = readerSpi.createReaderInstance();
pbjImageRead.add(reader);
// Check if to use a simple JAI ImageRead operation or a
// multithreaded one
final String jaiOperation = useMultithreading ? "ImageReadMT" : "ImageRead";
// final String jaiOperation = "ImageRead";
/** TODO: SET HINTS */
planarImage = JAI.create(jaiOperation, pbjImageRead, null);
} else {
reader = readerSpi.createReaderInstance();
reader.setInput(paramInput, true, true);
planarImage = PlanarImage.wrapRenderedImage(reader.read(imageIndex, imageReadParam));
reader.dispose();
}
return planarImage;