Changeset 7481


Ignore:
Timestamp:
12/31/10 11:04:45 (9 years ago)
Author:
melissa
Message:

Expanded special strip unpacking case to allow multiple strips.

File:
1 edited

Legend:

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

    r7311 r7481  
    651651    // any special handling, then we can just read it directly and return 
    652652    if ((x % tileWidth) == 0 && (y % tileLength) == 0 && width == tileWidth && 
    653       height == tileLength && samplesPerPixel == 1 && 
    654       (ifd.getBitsPerSample()[0] % 8) == 0 && 
     653      samplesPerPixel == 1 && (ifd.getBitsPerSample()[0] % 8) == 0 && 
    655654      photoInterp != PhotoInterp.WHITE_IS_ZERO && 
    656655      photoInterp != PhotoInterp.CMYK && photoInterp != PhotoInterp.Y_CB_CR && 
     
    660659      long[] stripByteCounts = ifd.getStripByteCounts(); 
    661660 
    662       int tile = (int) ((y / tileLength) * numTileCols + (x / tileWidth)); 
    663  
    664       if (stripByteCounts[tile] == numSamples && pixel > 1) { 
    665         stripByteCounts[tile] *= pixel; 
    666       } 
    667  
    668       in.seek(stripOffsets[tile]); 
    669       in.read(buf, 0, (int) Math.min(buf.length, stripByteCounts[tile])); 
     661      int firstTile = (int) ((y / tileLength) * numTileCols + (x / tileWidth)); 
     662      int lastTile = 
     663        (int) ((height / tileLength) * numTileCols + (x / tileWidth)); 
     664 
     665      if (stripByteCounts[firstTile] == numSamples && pixel > 1) { 
     666        stripByteCounts[firstTile] *= pixel; 
     667      } 
     668 
     669      int offset = 0; 
     670      for (int tile=firstTile; tile<lastTile; tile++) { 
     671        in.seek(stripOffsets[tile]); 
     672        int len = (int) Math.min(buf.length, stripByteCounts[tile]); 
     673        in.read(buf, offset, len); 
     674        offset += len; 
     675      } 
    670676      return buf; 
    671677    } 
Note: See TracChangeset for help on using the changeset viewer.