mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 12:05:29 -04:00
TMI-62: Faster reading of short and integer rasters.
This commit is contained in:
parent
2fb9a54618
commit
3e0440b9f4
@ -1071,9 +1071,7 @@ public class TIFFImageReader extends ImageReaderBase {
|
|||||||
break; // We're done with this tile
|
break; // We're done with this tile
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int k = 0; k < rowDataShort.length; k++) {
|
readFully(input, rowDataShort);
|
||||||
rowDataShort[k] = input.readShort();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (row >= srcRegion.y) {
|
if (row >= srcRegion.y) {
|
||||||
normalizeBlack(interpretation, rowDataShort);
|
normalizeBlack(interpretation, rowDataShort);
|
||||||
@ -1101,9 +1099,7 @@ public class TIFFImageReader extends ImageReaderBase {
|
|||||||
break; // We're done with this tile
|
break; // We're done with this tile
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int k = 0; k < rowDataInt.length; k++) {
|
readFully(input, rowDataInt);
|
||||||
rowDataInt[k] = input.readInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (row >= srcRegion.y) {
|
if (row >= srcRegion.y) {
|
||||||
normalizeBlack(interpretation, rowDataInt);
|
normalizeBlack(interpretation, rowDataInt);
|
||||||
@ -1126,6 +1122,32 @@ public class TIFFImageReader extends ImageReaderBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Candidate util method (with off/len + possibly byte order)
|
||||||
|
private void readFully(final DataInput input, final int[] rowDataInt) throws IOException {
|
||||||
|
if (input instanceof ImageInputStream) {
|
||||||
|
ImageInputStream imageInputStream = (ImageInputStream) input;
|
||||||
|
imageInputStream.readFully(rowDataInt, 0, rowDataInt.length);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (int k = 0; k < rowDataInt.length; k++) {
|
||||||
|
rowDataInt[k] = input.readInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Candidate util method (with off/len + possibly byte order)
|
||||||
|
private void readFully(final DataInput input, final short[] rowDataShort) throws IOException {
|
||||||
|
if (input instanceof ImageInputStream) {
|
||||||
|
ImageInputStream imageInputStream = (ImageInputStream) input;
|
||||||
|
imageInputStream.readFully(rowDataShort, 0, rowDataShort.length);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (int k = 0; k < rowDataShort.length; k++) {
|
||||||
|
rowDataShort[k] = input.readShort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void normalizeBlack(int photometricInterpretation, short[] data) {
|
private void normalizeBlack(int photometricInterpretation, short[] data) {
|
||||||
if (photometricInterpretation == TIFFBaseline.PHOTOMETRIC_WHITE_IS_ZERO) {
|
if (photometricInterpretation == TIFFBaseline.PHOTOMETRIC_WHITE_IS_ZERO) {
|
||||||
// Inverse values
|
// Inverse values
|
||||||
|
Loading…
x
Reference in New Issue
Block a user