}
providerIgnoresICC = checkProviderIgnoresICC(reader
.getOriginatingProvider());
break; //Quit early, we have the image
} catch (IndexOutOfBoundsException indexe) {
throw new ImageException("Page does not exist. Invalid image index: "
+ pageIndex);
} catch (IllegalArgumentException iae) {
//Some codecs like com.sun.imageio.plugins.wbmp.WBMPImageReader throw
//IllegalArgumentExceptions when they have trouble parsing the image.
throw new ImageException("Error loading image using ImageIO codec", iae);
} catch (IIOException iioe) {
if (firstException == null) {
firstException = iioe;
} else {
log.debug("non-first error loading image: " + iioe.getMessage());
}
}
try {
//Try fallback for CMYK images
BufferedImage bi = getFallbackBufferedImage(reader, pageIndex, param);
imageData = bi;
firstException = null; //Clear exception after successful fallback attempt
break;
} catch (IIOException iioe) {
//ignore
}
imgStream.reset();
} finally {
reader.dispose();
}
}
} finally {
ImageUtil.closeQuietly(src);
//TODO Some codecs may do late reading.
}
if (firstException != null) {
throw new ImageException("Error while loading image: "
+ firstException.getMessage(), firstException);
}
if (imageData == null) {
throw new ImageException("No ImageIO ImageReader found .");
}
ColorModel cm = imageData.getColorModel();
Color transparentColor = null;