Changeset 7483


Ignore:
Timestamp:
12/31/10 13:39:49 (9 years ago)
Author:
melissa
Message:

Fixed a handful of bugs introduced in r7481.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/tiff/TiffParser.java

    r7481 r7483  
    648648    TiffCompression compression = ifd.getCompression(); 
    649649 
     650    long imageLength = ifd.getImageLength(); 
     651 
    650652    // special case: if we only need one tile, and that tile doesn't need 
    651653    // any special handling, then we can just read it directly and return 
    652654    if ((x % tileWidth) == 0 && (y % tileLength) == 0 && width == tileWidth && 
    653       samplesPerPixel == 1 && (ifd.getBitsPerSample()[0] % 8) == 0 && 
     655      height == imageLength && samplesPerPixel == 1 && 
     656      (ifd.getBitsPerSample()[0] % 8) == 0 && 
    654657      photoInterp != PhotoInterp.WHITE_IS_ZERO && 
    655658      photoInterp != PhotoInterp.CMYK && photoInterp != PhotoInterp.Y_CB_CR && 
     
    661664      int firstTile = (int) ((y / tileLength) * numTileCols + (x / tileWidth)); 
    662665      int lastTile = 
    663         (int) ((height / tileLength) * numTileCols + (x / tileWidth)); 
    664  
    665       if (stripByteCounts[firstTile] == numSamples && pixel > 1) { 
    666         stripByteCounts[firstTile] *= pixel; 
    667       } 
     666        (int) (((y + height) / tileLength) * numTileCols + (x / tileWidth)); 
     667      lastTile = (int) Math.min(lastTile, stripOffsets.length - 1); 
    668668 
    669669      int offset = 0; 
    670       for (int tile=firstTile; tile<lastTile; tile++) { 
     670      for (int tile=firstTile; tile<=lastTile; tile++) { 
     671        if (stripByteCounts[tile] == numSamples && pixel > 1) { 
     672          stripByteCounts[tile] *= pixel; 
     673        } 
     674 
    671675        in.seek(stripOffsets[tile]); 
    672         int len = (int) Math.min(buf.length, stripByteCounts[tile]); 
     676        int len = (int) Math.min(buf.length - offset, stripByteCounts[tile]); 
    673677        in.read(buf, offset, len); 
    674678        offset += len; 
Note: See TracChangeset for help on using the changeset viewer.