< prev index next >
src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -935,16 +935,10 @@
// Read the image row-by-row
for (int srcY = 0; srcY < passHeight; srcY++) {
// Skip filter byte and the remaining row bytes
pixelStream.skipBytes(1 + bytesPerRow);
-
- // If read has been aborted, just return
- // processReadAborted will be called later
- if (abortRequested()) {
- return;
- }
}
}
private void updateImageProgress(int newPixels) {
pixelsDone += newPixels;
@@ -994,10 +988,17 @@
// If no pixels need updating, just skip the input data
if (updateWidth == 0) {
for (int srcY = 0; srcY < passHeight; srcY++) {
// Update count of pixels read
updateImageProgress(passWidth);
+ /*
+ * If read has been aborted, just return
+ * processReadAborted will be called later
+ */
+ if (abortRequested()) {
+ return;
+ }
// Skip filter byte and the remaining row bytes
pixelStream.skipBytes(1 + bytesPerRow);
}
return;
}
@@ -1103,11 +1104,17 @@
// Decode the (sub)image row-by-row
for (int srcY = 0; srcY < passHeight; srcY++) {
// Update count of pixels read
updateImageProgress(passWidth);
-
+ /*
+ * If read has been aborted, just return
+ * processReadAborted will be called later
+ */
+ if (abortRequested()) {
+ return;
+ }
// Read the filter type byte and a row of data
int filter = pixelStream.read();
try {
// Swap curr and prior
byte[] tmp = prior;
@@ -1193,16 +1200,10 @@
processImageUpdate(theImage,
updateMinX, dstY,
updateWidth, 1,
updateXStep, updateYStep,
destinationBands);
-
- // If read has been aborted, just return
- // processReadAborted will be called later
- if (abortRequested()) {
- return;
- }
}
}
processPassComplete(theImage);
}
@@ -1213,12 +1214,10 @@
int height = metadata.IHDR_height;
this.pixelsDone = 0;
this.totalPixels = width*height;
- clearAbortRequest();
-
if (metadata.IHDR_interlaceMethod == 0) {
decodePass(0, 0, 0, 1, 1, width, height);
} else {
for (int i = 0; i <= sourceMaxProgressivePass; i++) {
int XOffset = adam7XOffset[i];
@@ -1239,12 +1238,14 @@
} else {
skipPass((width + xbump)/XSubsampling,
(height + ybump)/YSubsampling);
}
- // If read has been aborted, just return
- // processReadAborted will be called later
+ /*
+ * If read has been aborted, just return
+ * processReadAborted will be called later
+ */
if (abortRequested()) {
return;
}
}
}
@@ -1330,17 +1331,23 @@
int colorType = metadata.IHDR_colorType;
checkReadParamBandSettings(param,
inputBandsForColorType[colorType],
theImage.getSampleModel().getNumBands());
+ clearAbortRequest();
processImageStarted(0);
+ if (abortRequested()) {
+ processReadAborted();
+ } else {
decodeImage();
if (abortRequested()) {
processReadAborted();
} else {
processImageComplete();
}
+ }
+
} catch (IOException e) {
throw new IIOException("Error reading PNG image data", e);
} finally {
if (inf != null) {
inf.end();
< prev index next >