()
| 362 | } |
| 363 | |
| 364 | FileInfo OpenIFD() throws IOException { |
| 365 | // Get Image File Directory data |
| 366 | int tag, fieldType, count, value; |
| 367 | int nEntries = getShort(); |
| 368 | if (nEntries<1 || nEntries>1000) |
| 369 | return null; |
| 370 | ifdCount++; |
| 371 | if ((ifdCount%50)==0 && ifdCount>0) |
| 372 | ij.IJ.showStatus("Opening IFDs: "+ifdCount); |
| 373 | FileInfo fi = new FileInfo(); |
| 374 | fi.fileType = FileInfo.BITMAP; //BitsPerSample defaults to 1 |
| 375 | for (int i=0; i<nEntries; i++) { |
| 376 | tag = getShort(); |
| 377 | fieldType = getShort(); |
| 378 | count = getInt(); |
| 379 | value = getValue(fieldType, count); |
| 380 | long lvalue = ((long)value)&0xffffffffL; |
| 381 | if (debugMode && ifdCount<10) dumpTag(tag, count, value, fi); |
| 382 | switch (tag) { |
| 383 | case IMAGE_WIDTH: |
| 384 | fi.width = value; |
| 385 | fi.intelByteOrder = littleEndian; |
| 386 | break; |
| 387 | case IMAGE_LENGTH: |
| 388 | fi.height = value; |
| 389 | break; |
| 390 | case STRIP_OFFSETS: |
| 391 | if (count==1) |
| 392 | fi.stripOffsets = new int[] {value}; |
| 393 | else { |
| 394 | long saveLoc = in.getLongFilePointer(); |
| 395 | in.seek(lvalue); |
| 396 | fi.stripOffsets = new int[count]; |
| 397 | for (int c=0; c<count; c++) |
| 398 | fi.stripOffsets[c] = getInt(); |
| 399 | in.seek(saveLoc); |
| 400 | } |
| 401 | fi.offset = count>0?fi.stripOffsets[0]:value; |
| 402 | if (count>1 && (((long)fi.stripOffsets[count-1])&0xffffffffL)<(((long)fi.stripOffsets[0])&0xffffffffL)) |
| 403 | fi.offset = fi.stripOffsets[count-1]; |
| 404 | break; |
| 405 | case STRIP_BYTE_COUNT: |
| 406 | if (count==1) |
| 407 | fi.stripLengths = new int[] {value}; |
| 408 | else { |
| 409 | long saveLoc = in.getLongFilePointer(); |
| 410 | in.seek(lvalue); |
| 411 | fi.stripLengths = new int[count]; |
| 412 | for (int c=0; c<count; c++) { |
| 413 | if (fieldType==SHORT) |
| 414 | fi.stripLengths[c] = getShort(); |
| 415 | else |
| 416 | fi.stripLengths[c] = getInt(); |
| 417 | } |
| 418 | in.seek(saveLoc); |
| 419 | } |
| 420 | break; |
| 421 | case PHOTO_INTERP: |
no test coverage detected