8270952: Improve TIFF file handling
Reviewed-by: jdv, psadhukhan, mschoene, rhalade
This commit is contained in:
parent
1fddb03d93
commit
9a94fbc793
@ -136,12 +136,7 @@ public class TIFFNullDecompressor extends TIFFDecompressor {
|
||||
|
||||
int lastRow = activeSrcHeight - 1;
|
||||
for (int y = 0; y < activeSrcHeight; y++) {
|
||||
int bytesRead = stream.read(b, dstOffset, activeBytesPerRow);
|
||||
if (bytesRead < 0) {
|
||||
throw new EOFException();
|
||||
} else if (bytesRead != activeBytesPerRow) {
|
||||
break;
|
||||
}
|
||||
stream.readFully(b, dstOffset, activeBytesPerRow);
|
||||
dstOffset += scanlineStride;
|
||||
|
||||
// Skip unneeded bytes (row suffix + row prefix).
|
||||
@ -154,17 +149,10 @@ public class TIFFNullDecompressor extends TIFFDecompressor {
|
||||
stream.seek(offset);
|
||||
int bytesPerRow = (srcWidth*bitsPerPixel + 7)/8;
|
||||
if(bytesPerRow == scanlineStride) {
|
||||
if (stream.read(b, dstOffset, bytesPerRow*srcHeight) < 0) {
|
||||
throw new EOFException();
|
||||
}
|
||||
stream.readFully(b, dstOffset, bytesPerRow*srcHeight);
|
||||
} else {
|
||||
for (int y = 0; y < srcHeight; y++) {
|
||||
int bytesRead = stream.read(b, dstOffset, bytesPerRow);
|
||||
if (bytesRead < 0) {
|
||||
throw new EOFException();
|
||||
} else if (bytesRead != bytesPerRow) {
|
||||
break;
|
||||
}
|
||||
stream.readFully(b, dstOffset, bytesPerRow);
|
||||
dstOffset += scanlineStride;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user