< prev index next >
src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2003, 2014, 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
--- 1,7 ----
/*
! * Copyright (c) 2003, 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
*** 747,756 ****
--- 747,760 ----
}
checkIndex(imageIndex);
clearAbortRequest();
processImageStarted(imageIndex);
+ if (abortRequested()) {
+ processReadAborted();
+ return bi;
+ }
if (param == null)
param = getDefaultReadParam();
//read header
*** 1003,1022 ****
if (noTransform) {
int j = isBottomUp ? (height -1)*bytesPerScanline : 0;
for (int i=0; i<height; i++) {
- if (abortRequested()) {
- break;
- }
iis.readFully(bdata, j, bytesPerScanline);
iis.skipBytes(padding);
j += isBottomUp ? -bytesPerScanline : bytesPerScanline;
processImageUpdate(bi, 0, i,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F * i/destinationRegion.height);
}
} else {
byte[] buf = new byte[lineLength];
int lineStride =
((MultiPixelPackedSampleModel)sampleModel).getScanlineStride();
--- 1007,1026 ----
if (noTransform) {
int j = isBottomUp ? (height -1)*bytesPerScanline : 0;
for (int i=0; i<height; i++) {
iis.readFully(bdata, j, bytesPerScanline);
iis.skipBytes(padding);
j += isBottomUp ? -bytesPerScanline : bytesPerScanline;
processImageUpdate(bi, 0, i,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F * i/destinationRegion.height);
+ if (abortRequested()) {
+ break;
+ }
}
} else {
byte[] buf = new byte[lineLength];
int lineStride =
((MultiPixelPackedSampleModel)sampleModel).getScanlineStride();
*** 1049,1061 ****
if (isBottomUp)
k += (destinationRegion.height - 1) * lineStride;
for (int j = 0, y = sourceRegion.y;
j < destinationRegion.height; j++, y+=scaleY) {
-
- if (abortRequested())
- break;
iis.read(buf, 0, lineLength);
for (int i = 0; i < destinationRegion.width; i++) {
//get the bit and assign to the data buffer of the raster
int v = (buf[srcPos[i]] >> srcOff[i]) & 1;
bdata[k + destPos[i]] |= v << destOff[i];
--- 1053,1062 ----
*** 1065,1074 ****
--- 1066,1078 ----
iis.skipBytes(skipLength);
processImageUpdate(bi, 0, j,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F*j/destinationRegion.height);
+ if (abortRequested()) {
+ break;
+ }
}
}
}
// Method to read a 4 bit BMP image data
*** 1085,1104 ****
if (noTransform) {
int j = isBottomUp ? (height -1) * bytesPerScanline : 0;
for (int i=0; i<height; i++) {
- if (abortRequested()) {
- break;
- }
iis.readFully(bdata, j, bytesPerScanline);
iis.skipBytes(padding);
j += isBottomUp ? -bytesPerScanline : bytesPerScanline;
processImageUpdate(bi, 0, i,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F * i/destinationRegion.height);
}
} else {
byte[] buf = new byte[lineLength];
int lineStride =
((MultiPixelPackedSampleModel)sampleModel).getScanlineStride();
--- 1089,1108 ----
if (noTransform) {
int j = isBottomUp ? (height -1) * bytesPerScanline : 0;
for (int i=0; i<height; i++) {
iis.readFully(bdata, j, bytesPerScanline);
iis.skipBytes(padding);
j += isBottomUp ? -bytesPerScanline : bytesPerScanline;
processImageUpdate(bi, 0, i,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F * i/destinationRegion.height);
+ if (abortRequested()) {
+ break;
+ }
}
} else {
byte[] buf = new byte[lineLength];
int lineStride =
((MultiPixelPackedSampleModel)sampleModel).getScanlineStride();
*** 1131,1143 ****
if (isBottomUp)
k += (destinationRegion.height - 1) * lineStride;
for (int j = 0, y = sourceRegion.y;
j < destinationRegion.height; j++, y+=scaleY) {
-
- if (abortRequested())
- break;
iis.read(buf, 0, lineLength);
for (int i = 0; i < destinationRegion.width; i++) {
//get the bit and assign to the data buffer of the raster
int v = (buf[srcPos[i]] >> srcOff[i]) & 0x0F;
bdata[k + destPos[i]] |= v << destOff[i];
--- 1135,1144 ----
*** 1147,1156 ****
--- 1148,1160 ----
iis.skipBytes(skipLength);
processImageUpdate(bi, 0, j,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F*j/destinationRegion.height);
+ if (abortRequested()) {
+ break;
+ }
}
}
}
// Method to read 8 bit BMP image data
*** 1166,1185 ****
if (noTransform) {
int j = isBottomUp ? (height -1) * width : 0;
for (int i=0; i<height; i++) {
- if (abortRequested()) {
- break;
- }
iis.readFully(bdata, j, width);
iis.skipBytes(padding);
j += isBottomUp ? -width : width;
processImageUpdate(bi, 0, i,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F * i/destinationRegion.height);
}
} else {
byte[] buf = new byte[lineLength];
int lineStride =
((ComponentSampleModel)sampleModel).getScanlineStride();
--- 1170,1189 ----
if (noTransform) {
int j = isBottomUp ? (height -1) * width : 0;
for (int i=0; i<height; i++) {
iis.readFully(bdata, j, width);
iis.skipBytes(padding);
j += isBottomUp ? -width : width;
processImageUpdate(bi, 0, i,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F * i/destinationRegion.height);
+ if (abortRequested()) {
+ break;
+ }
}
} else {
byte[] buf = new byte[lineLength];
int lineStride =
((ComponentSampleModel)sampleModel).getScanlineStride();
*** 1198,1210 ****
k += (destinationRegion.height - 1) * lineStride;
k += destinationRegion.x;
for (int j = 0, y = sourceRegion.y;
j < destinationRegion.height; j++, y+=scaleY) {
-
- if (abortRequested())
- break;
iis.read(buf, 0, lineLength);
for (int i = 0, m = sourceRegion.x;
i < destinationRegion.width; i++, m += scaleX) {
//get the bit and assign to the data buffer of the raster
bdata[k + i] = buf[m];
--- 1202,1211 ----
*** 1214,1223 ****
--- 1215,1227 ----
iis.skipBytes(skipLength);
processImageUpdate(bi, 0, j,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F*j/destinationRegion.height);
+ if (abortRequested()) {
+ break;
+ }
}
}
}
// Method to read 24 bit BMP image data
*** 1233,1252 ****
if (noTransform) {
int j = isBottomUp ? (height -1) * width * 3 : 0;
for (int i=0; i<height; i++) {
- if (abortRequested()) {
- break;
- }
iis.readFully(bdata, j, lineStride);
iis.skipBytes(padding);
j += isBottomUp ? -lineStride : lineStride;
processImageUpdate(bi, 0, i,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F * i/destinationRegion.height);
}
} else {
byte[] buf = new byte[lineLength];
lineStride =
((ComponentSampleModel)sampleModel).getScanlineStride();
--- 1237,1256 ----
if (noTransform) {
int j = isBottomUp ? (height -1) * width * 3 : 0;
for (int i=0; i<height; i++) {
iis.readFully(bdata, j, lineStride);
iis.skipBytes(padding);
j += isBottomUp ? -lineStride : lineStride;
processImageUpdate(bi, 0, i,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F * i/destinationRegion.height);
+ if (abortRequested()) {
+ break;
+ }
}
} else {
byte[] buf = new byte[lineLength];
lineStride =
((ComponentSampleModel)sampleModel).getScanlineStride();
*** 1265,1277 ****
k += (destinationRegion.height - 1) * lineStride;
k += destinationRegion.x * 3;
for (int j = 0, y = sourceRegion.y;
j < destinationRegion.height; j++, y+=scaleY) {
-
- if (abortRequested())
- break;
iis.read(buf, 0, lineLength);
for (int i = 0, m = 3 * sourceRegion.x;
i < destinationRegion.width; i++, m += 3 * scaleX) {
//get the bit and assign to the data buffer of the raster
int n = 3 * i + k;
--- 1269,1278 ----
*** 1283,1292 ****
--- 1284,1296 ----
iis.skipBytes(skipLength);
processImageUpdate(bi, 0, j,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F*j/destinationRegion.height);
+ if (abortRequested()) {
+ break;
+ }
}
}
}
private void read16Bit(short sdata[]) throws IOException {
*** 1300,1321 ****
int lineLength = width + padding / 2;
if (noTransform) {
int j = isBottomUp ? (height -1) * width : 0;
for (int i=0; i<height; i++) {
- if (abortRequested()) {
- break;
- }
-
iis.readFully(sdata, j, width);
iis.skipBytes(padding);
j += isBottomUp ? -width : width;
processImageUpdate(bi, 0, i,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F * i/destinationRegion.height);
}
} else {
short[] buf = new short[lineLength];
int lineStride =
((SinglePixelPackedSampleModel)sampleModel).getScanlineStride();
--- 1304,1324 ----
int lineLength = width + padding / 2;
if (noTransform) {
int j = isBottomUp ? (height -1) * width : 0;
for (int i=0; i<height; i++) {
iis.readFully(sdata, j, width);
iis.skipBytes(padding);
j += isBottomUp ? -width : width;
processImageUpdate(bi, 0, i,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F * i/destinationRegion.height);
+ if (abortRequested()) {
+ break;
+ }
}
} else {
short[] buf = new short[lineLength];
int lineStride =
((SinglePixelPackedSampleModel)sampleModel).getScanlineStride();
*** 1334,1346 ****
k += (destinationRegion.height - 1) * lineStride;
k += destinationRegion.x;
for (int j = 0, y = sourceRegion.y;
j < destinationRegion.height; j++, y+=scaleY) {
-
- if (abortRequested())
- break;
iis.readFully(buf, 0, lineLength);
for (int i = 0, m = sourceRegion.x;
i < destinationRegion.width; i++, m += scaleX) {
//get the bit and assign to the data buffer of the raster
sdata[k + i] = buf[m];
--- 1337,1346 ----
*** 1350,1377 ****
iis.skipBytes(skipLength);
processImageUpdate(bi, 0, j,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F*j/destinationRegion.height);
}
}
}
private void read32Bit(int idata[]) throws IOException {
if (noTransform) {
int j = isBottomUp ? (height -1) * width : 0;
for (int i=0; i<height; i++) {
- if (abortRequested()) {
- break;
- }
iis.readFully(idata, j, width);
j += isBottomUp ? -width : width;
processImageUpdate(bi, 0, i,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F * i/destinationRegion.height);
}
} else {
int[] buf = new int[width];
int lineStride =
((SinglePixelPackedSampleModel)sampleModel).getScanlineStride();
--- 1350,1380 ----
iis.skipBytes(skipLength);
processImageUpdate(bi, 0, j,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F*j/destinationRegion.height);
+ if (abortRequested()) {
+ break;
+ }
}
}
}
private void read32Bit(int idata[]) throws IOException {
if (noTransform) {
int j = isBottomUp ? (height -1) * width : 0;
for (int i=0; i<height; i++) {
iis.readFully(idata, j, width);
j += isBottomUp ? -width : width;
processImageUpdate(bi, 0, i,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F * i/destinationRegion.height);
+ if (abortRequested()) {
+ break;
+ }
}
} else {
int[] buf = new int[width];
int lineStride =
((SinglePixelPackedSampleModel)sampleModel).getScanlineStride();
*** 1390,1402 ****
k += (destinationRegion.height - 1) * lineStride;
k += destinationRegion.x;
for (int j = 0, y = sourceRegion.y;
j < destinationRegion.height; j++, y+=scaleY) {
-
- if (abortRequested())
- break;
iis.readFully(buf, 0, width);
for (int i = 0, m = sourceRegion.x;
i < destinationRegion.width; i++, m += scaleX) {
//get the bit and assign to the data buffer of the raster
idata[k + i] = buf[m];
--- 1393,1402 ----
*** 1406,1415 ****
--- 1406,1418 ----
iis.skipBytes(skipLength);
processImageUpdate(bi, 0, j,
destinationRegion.width, 1, 1, 1,
new int[]{0});
processImageProgress(100.0F*j/destinationRegion.height);
+ if (abortRequested()) {
+ break;
+ }
}
}
}
private void readRLE8(byte bdata[]) throws IOException {
< prev index next >