Changeset 3300


Ignore:
Timestamp:
10/18/07 13:42:09 (12 years ago)
Author:
melissa
Message:

Changed TiffIFDEntry's 'offset' field to 'long'; calls to TiffTools.getFirst* now check if the file is BigTIFF.

Location:
trunk/loci/formats
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/TiffIFDEntry.java

    r3015 r3300  
    5151   * for the field. 
    5252   */ 
    53   private int valueOffset; 
     53  private long valueOffset; 
    5454 
    55   public TiffIFDEntry(int tag, int type, int valueCount, int valueOffset) { 
     55  public TiffIFDEntry(int tag, int type, int valueCount, long valueOffset) { 
    5656    this.tag = tag; 
    5757    this.type = type; 
     
    8282   * @return the entry's <i>ValueOffset</i> value. 
    8383   */ 
    84   public int getValueOffset() { return valueOffset; } 
     84  public long getValueOffset() { return valueOffset; } 
    8585 
    8686} 
  • trunk/loci/formats/TiffTools.java

    r3296 r3300  
    305305    if (result == null) return null; 
    306306 
    307     long offset = getFirstOffset(in); 
    308  
    309     return getIFD(in, 0, offset); 
     307    in.seek(2); 
     308    boolean bigTiff = in.readShort() == BIG_TIFF_MAGIC_NUMBER; 
     309 
     310    long offset = getFirstOffset(in, bigTiff); 
     311 
     312    Hashtable ifd = getIFD(in, 0, offset, bigTiff); 
     313    ifd.put(new Integer(BIG_TIFF), new Boolean(bigTiff)); 
     314    return ifd; 
    310315  } 
    311316 
     
    325330    if (result == null) return null; 
    326331 
     332    in.seek(2); 
     333    boolean bigTiff = in.readShort() == BIG_TIFF_MAGIC_NUMBER; 
     334 
    327335    // Get the offset of the first IFD 
    328     long offset = getFirstOffset(in); 
     336    long offset = getFirstOffset(in, bigTiff); 
    329337 
    330338    // The following loosely resembles the logic of getIFD()... 
    331339    in.seek(offset); 
    332     int numEntries = in.readShort() & 0xffff; 
     340    long numEntries = bigTiff ? in.readLong() : in.readShort() & 0xffff; 
    333341 
    334342    for (int i = 0; i < numEntries; i++) { 
    335343      in.seek(offset + // The beginning of the IFD 
    336344        2 + // The width of the initial numEntries field 
    337         BYTES_PER_ENTRY * i); 
     345        (bigTiff ? BIG_TIFF_BYTES_PER_ENTRY : BYTES_PER_ENTRY) * i); 
    338346 
    339347      int entryTag = in.readShort() & 0xffff; 
     
    346354 
    347355      // Parse the entry's "ValueCount" 
    348       int valueCount = in.readInt(); 
     356      int valueCount = 
     357        bigTiff ? (int) (in.readLong() & 0xffffffff) : in.readInt(); 
    349358      if (valueCount < 0) { 
    350359        throw new RuntimeException("Count of '" + valueCount + "' unexpected."); 
     
    352361 
    353362      // Parse the entry's "ValueOffset" 
    354       int valueOffset = in.readInt(); 
     363      long valueOffset = bigTiff ? in.readLong() : in.readInt(); 
    355364 
    356365      return new TiffIFDEntry(entryTag, entryType, valueCount, valueOffset); 
Note: See TracChangeset for help on using the changeset viewer.