< prev index next >

src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java

Print this page

        

*** 1084,1097 **** byte[] byteData = null; short[] shortData = null; byte[] curr = new byte[bytesPerRow]; byte[] prior = new byte[bytesPerRow]; // Create a 1-row tall Raster to hold the data ! WritableRaster passRow = createRaster(passWidth, 1, inputBands, ! eltsPerRow, bitDepth); // Create an array suitable for holding one pixel int[] ps = passRow.getPixel(0, 0, (int[])null); DataBuffer dataBuffer = passRow.getDataBuffer(); --- 1084,1107 ---- byte[] byteData = null; short[] shortData = null; byte[] curr = new byte[bytesPerRow]; byte[] prior = new byte[bytesPerRow]; + WritableRaster passRow = null; + try { // Create a 1-row tall Raster to hold the data ! passRow = createRaster(passWidth, 1, inputBands, eltsPerRow, bitDepth); + } catch (Exception e) { + /* + * createRaster() can throw many types of Exception but according + * to specification we must throw only IIOException if we face any + * issue while reading an image. So at this high level we catch + * the exception and wrap it around IIOException. + */ + throw new IIOException("Caught exception during read: ", e); + } // Create an array suitable for holding one pixel int[] ps = passRow.getPixel(0, 0, (int[])null); DataBuffer dataBuffer = passRow.getDataBuffer();
< prev index next >