1114
1115 Point p = imageReadParam.getDestinationOffset();
1116 dstXOffset = p.x;
1117 dstYOffset = p.y;
1118
1119 // This could probably be made more efficient...
1120 Rectangle srcRegion = new Rectangle(0, 0, 0, 0);
1121 Rectangle destRegion = new Rectangle(0, 0, 0, 0);
1122
1123 computeRegions(imageReadParam, width, height, theImage,
1124 srcRegion, destRegion);
1125
1126 // Initial source pixel, taking source region and source
1127 // subsamplimg offsets into account
1128 sourceXOffset = srcRegion.x;
1129 sourceYOffset = srcRegion.y;
1130
1131 pixelsToRead = destRegion.width * destRegion.height;
1132 pixelsRead = 0;
1133
1134 processImageStarted(imageIndex);
1135 processImageProgress(0.0f);
1136
1137 tilesAcross = (width + tileOrStripWidth - 1) / tileOrStripWidth;
1138 tilesDown = (height + tileOrStripHeight - 1) / tileOrStripHeight;
1139
1140 int compression = getCompression();
1141
1142 // Set the decompressor
1143 if (compression == BaselineTIFFTagSet.COMPRESSION_NONE) {
1144 // Get the fillOrder field.
1145 TIFFField fillOrderField
1146 = imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_FILL_ORDER);
1147
1148 // Set the decompressor based on the fill order.
1149 if (fillOrderField != null && fillOrderField.getAsInt(0) == 2) {
1150 this.decompressor = new TIFFLSBDecompressor();
1151 } else {
1152 this.decompressor = new TIFFNullDecompressor();
1153 }
1154 } else if (compression
1155 == BaselineTIFFTagSet.COMPRESSION_CCITT_T_6) {
1269
1270 if (planarConfiguration
1271 == BaselineTIFFTagSet.PLANAR_CONFIGURATION_PLANAR) {
1272
1273 decompressor.setPlanar(true);
1274
1275 int[] sb = new int[1];
1276 int[] db = new int[1];
1277 for (int tj = minTileY; tj <= maxTileY; tj++) {
1278 for (int ti = minTileX; ti <= maxTileX; ti++) {
1279 for (int band = 0; band < numBands; band++) {
1280 sb[0] = sourceBands[band];
1281 decompressor.setSourceBands(sb);
1282 db[0] = destinationBands[band];
1283 decompressor.setDestinationBands(db);
1284
1285 decodeTile(ti, tj, band);
1286 }
1287
1288 reportProgress();
1289 }
1290 }
1291 } else {
1292 for (int tj = minTileY; tj <= maxTileY; tj++) {
1293 for (int ti = minTileX; ti <= maxTileX; ti++) {
1294 decodeTile(ti, tj, -1);
1295
1296 reportProgress();
1297 }
1298 }
1299 }
1300
1301 if (abortRequested()) {
1302 processReadAborted();
1303 } else {
1304 processImageComplete();
1305 }
1306
1307 return theImage;
1308 }
1309
1310 public void reset() {
1311 super.reset();
1312 resetLocal();
1313 }
1314
1315 protected void resetLocal() {
1316 stream = null;
1317 gotHeader = false;
1318 imageReadParam = getDefaultReadParam();
1319 streamMetadata = null;
1320 currIndex = -1;
1321 imageMetadata = null;
1322 imageStartPosition = new ArrayList<Long>();
1323 numImages = -1;
1324 imageTypeMap = new HashMap<Integer, List<ImageTypeSpecifier>>();
1325 width = -1;
1326 height = -1;
|
1114
1115 Point p = imageReadParam.getDestinationOffset();
1116 dstXOffset = p.x;
1117 dstYOffset = p.y;
1118
1119 // This could probably be made more efficient...
1120 Rectangle srcRegion = new Rectangle(0, 0, 0, 0);
1121 Rectangle destRegion = new Rectangle(0, 0, 0, 0);
1122
1123 computeRegions(imageReadParam, width, height, theImage,
1124 srcRegion, destRegion);
1125
1126 // Initial source pixel, taking source region and source
1127 // subsamplimg offsets into account
1128 sourceXOffset = srcRegion.x;
1129 sourceYOffset = srcRegion.y;
1130
1131 pixelsToRead = destRegion.width * destRegion.height;
1132 pixelsRead = 0;
1133
1134 clearAbortRequest();
1135 processImageStarted(imageIndex);
1136 if (abortRequested()) {
1137 processReadAborted();
1138 return theImage;
1139 }
1140
1141 tilesAcross = (width + tileOrStripWidth - 1) / tileOrStripWidth;
1142 tilesDown = (height + tileOrStripHeight - 1) / tileOrStripHeight;
1143
1144 int compression = getCompression();
1145
1146 // Set the decompressor
1147 if (compression == BaselineTIFFTagSet.COMPRESSION_NONE) {
1148 // Get the fillOrder field.
1149 TIFFField fillOrderField
1150 = imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_FILL_ORDER);
1151
1152 // Set the decompressor based on the fill order.
1153 if (fillOrderField != null && fillOrderField.getAsInt(0) == 2) {
1154 this.decompressor = new TIFFLSBDecompressor();
1155 } else {
1156 this.decompressor = new TIFFNullDecompressor();
1157 }
1158 } else if (compression
1159 == BaselineTIFFTagSet.COMPRESSION_CCITT_T_6) {
1273
1274 if (planarConfiguration
1275 == BaselineTIFFTagSet.PLANAR_CONFIGURATION_PLANAR) {
1276
1277 decompressor.setPlanar(true);
1278
1279 int[] sb = new int[1];
1280 int[] db = new int[1];
1281 for (int tj = minTileY; tj <= maxTileY; tj++) {
1282 for (int ti = minTileX; ti <= maxTileX; ti++) {
1283 for (int band = 0; band < numBands; band++) {
1284 sb[0] = sourceBands[band];
1285 decompressor.setSourceBands(sb);
1286 db[0] = destinationBands[band];
1287 decompressor.setDestinationBands(db);
1288
1289 decodeTile(ti, tj, band);
1290 }
1291
1292 reportProgress();
1293 if (abortRequested()) {
1294 processReadAborted();
1295 return theImage;
1296 }
1297 }
1298 }
1299 } else {
1300 for (int tj = minTileY; tj <= maxTileY; tj++) {
1301 for (int ti = minTileX; ti <= maxTileX; ti++) {
1302 decodeTile(ti, tj, -1);
1303
1304 reportProgress();
1305 if (abortRequested()) {
1306 processReadAborted();
1307 return theImage;
1308 }
1309 }
1310 }
1311 }
1312 processImageComplete();
1313 return theImage;
1314 }
1315
1316 public void reset() {
1317 super.reset();
1318 resetLocal();
1319 }
1320
1321 protected void resetLocal() {
1322 stream = null;
1323 gotHeader = false;
1324 imageReadParam = getDefaultReadParam();
1325 streamMetadata = null;
1326 currIndex = -1;
1327 imageMetadata = null;
1328 imageStartPosition = new ArrayList<Long>();
1329 numImages = -1;
1330 imageTypeMap = new HashMap<Integer, List<ImageTypeSpecifier>>();
1331 width = -1;
1332 height = -1;
|