Changeset 7484 for branches/4.1


Ignore:
Timestamp:
01/04/11 12:05:14 (9 years ago)
Author:
melissa
Message:

Various fixes to allow retrieval of pixel data from truncated TIFFs.

Location:
branches/4.1/components/bio-formats/src/loci/formats/tiff
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.1/components/bio-formats/src/loci/formats/tiff/IFD.java

    r6064 r7484  
    713713      offsets = getIFDLongArray(STRIP_OFFSETS, false); 
    714714    } 
     715    if (offsets == null) return null; 
    715716 
    716717    if (isTiled()) return offsets; 
     
    748749      // have the StripByteCounts tag, it also won't have the RowsPerStrip tag 
    749750      long[] offsets = getStripOffsets(); 
     751      if (offsets == null) return null; 
    750752      int bytesPerSample = getBytesPerSample()[0]; 
    751753      long imageWidth = getImageWidth(); 
     
    851853      sb.append("="); 
    852854      Object value = get(tags[entry]); 
    853       if ((value instanceof Boolean) || (value instanceof Number) || 
     855      if (value == null) { 
     856        sb.append("null"); 
     857      } 
     858      else if ((value instanceof Boolean) || (value instanceof Number) || 
    854859        (value instanceof String)) 
    855860      { 
  • branches/4.1/components/bio-formats/src/loci/formats/tiff/TiffParser.java

    r6464 r7484  
    372372        LogTools.debug("getIFDs: truncated " + (oldCount - count) + 
    373373          " array elements for tag " + tag); 
     374        if (count < 0) count = oldCount; 
    374375      } 
    375376      if (count < 0 || count > in.length()) break; 
     
    420421    int count = entry.getValueCount(); 
    421422    long offset = entry.getValueOffset(); 
     423 
     424    if (offset >= in.length()) { 
     425      return null; 
     426    } 
    422427 
    423428    if (offset != in.getFilePointer()) { 
     
    702707      long[] stripByteCounts = ifd.getStripByteCounts(); 
    703708 
    704       int tile = (int) ((y / tileLength) * numTileCols + (x / tileWidth)); 
    705       in.seek(stripOffsets[tile]); 
    706       in.read(buf, 0, (int) Math.min(buf.length, stripByteCounts[tile])); 
     709      if (stripOffsets != null && stripByteCounts != null) { 
     710        int tile = (int) ((y / tileLength) * numTileCols + (x / tileWidth)); 
     711        in.seek(stripOffsets[tile]); 
     712        in.read(buf, 0, (int) Math.min(buf.length, stripByteCounts[tile])); 
     713      } 
    707714      return buf; 
    708715    } 
Note: See TracChangeset for help on using the changeset viewer.