< prev index next >
src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java
Print this page
*** 1357,1374 ****
is = new InflaterInputStream(is, inf);
is = new BufferedInputStream(is);
this.pixelStream = new DataInputStream(is);
/*
! * NB: the PNG spec declares that valid range for width
* and height is [1, 2^31-1], so here we may fail to allocate
* a buffer for destination image due to memory limitation.
*
! * However, the recovery strategy for this case should be
! * defined on the level of application, so we will not
! * try to estimate the required amount of the memory and/or
! * handle OOM in any way.
*/
theImage = getDestination(param,
getImageTypes(0),
width,
height);
--- 1357,1378 ----
is = new InflaterInputStream(is, inf);
is = new BufferedInputStream(is);
this.pixelStream = new DataInputStream(is);
/*
! * PNG spec declares that valid range for width
* and height is [1, 2^31-1], so here we may fail to allocate
* a buffer for destination image due to memory limitation.
*
! * If the read operation triggers OutOfMemoryError, the same
! * will be wrapped in an IIOException at PNGImageReader.read
! * method.
! *
! * The recovery strategy for this case should be defined at
! * the level of application, so we will not try to estimate
! * the required amount of the memory and/or handle OOM in
! * any way.
*/
theImage = getDestination(param,
getImageTypes(0),
width,
height);
*** 1669,1679 ****
--- 1673,1692 ----
throws IIOException {
if (imageIndex != 0) {
throw new IndexOutOfBoundsException("imageIndex != 0!");
}
+ try {
readImage(param);
+ } catch (IOException |
+ IllegalStateException |
+ IllegalArgumentException e)
+ {
+ throw e;
+ } catch (Throwable e) {
+ throw new IIOException("Caught exception during read: ", e);
+ }
return theImage;
}
public void reset() {
super.reset();
< prev index next >