Changeset 4037


Ignore:
Timestamp:
05/13/08 11:39:27 (12 years ago)
Author:
melissa
Message:

Fixed lingering Zeiss LSM bugs, and a bug in RandomAccessStream's readFully(byte[]) method.

Location:
trunk/loci/formats
Files:
3 edited

Legend:

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

    r4031 r4037  
    9797  protected int ext = 0; 
    9898 
    99   /** Number of valid entries in the buffer size array. */ 
    100   protected int lastValid = 0; 
    101  
    10299  /** Flag indicating this file has been compressed. */ 
    103100  protected boolean compressed = false; 
     
    195192        raf.readFully(buf); 
    196193        raf.seek(0); 
    197         lastValid = 1; 
    198194        nextMark = MAX_OVERHEAD; 
    199195      } 
     
    457453  /** Read bytes from the stream into the given array. */ 
    458454  public void readFully(byte[] array) throws IOException { 
    459     int status = checkEfficiency(array.length); 
    460  
    461     if (status == DIS) { 
    462       readFully(array, 0, array.length); 
    463     } 
    464     else if (status == ARRAY) { 
    465       System.arraycopy(buf, (int) afp, array, 0, array.length); 
    466     } 
    467     else { 
    468       raf.readFully(array, 0, array.length); 
    469     } 
    470     afp += array.length; 
    471     if (status == DIS) fp += array.length; 
     455    readFully(array, 0, array.length); 
    472456  } 
    473457 
     
    614598    } 
    615599    else { 
    616       if (dis != null && afp >= mark && fp < mark + MAX_OVERHEAD) { 
     600      if (dis != null && afp >= mark && fp < mark) { 
    617601        boolean valid = true; 
    618602 
  • trunk/loci/formats/TiffTools.java

    r4035 r4037  
    457457      Object value = null; 
    458458 
     459      if (count > threshhold / BYTES_PER_ELEMENT[type]) { 
     460        long pointer = bigTiff ? in.readLong() : 
     461          (long) (in.readInt() & 0xffffffffL); 
     462        in.seek(pointer); 
     463      } 
     464 
    459465      if (type == BYTE) { 
    460466        // 8-bit unsigned integer 
    461         if (count > threshhold) { 
    462           long pointer = bigTiff ? in.readLong() : 
    463             (long) (in.readInt() & 0xffffffffL); 
    464           in.seek(pointer); 
    465         } 
    466467        if (count == 1) value = new Short(in.readByte()); 
    467468        else { 
     
    478479        // the last byte must be NUL (binary zero) 
    479480        byte[] ascii = new byte[count]; 
    480         if (count > threshhold) { 
    481           long pointer = bigTiff ? in.readLong() : 
    482             (long) (in.readInt() & 0xffffffffL); 
    483           in.seek(pointer); 
    484         } 
    485481        in.read(ascii); 
    486482 
     
    511507      else if (type == SHORT) { 
    512508        // 16-bit (2-byte) unsigned integer 
    513         if (count > threshhold / 2) { 
    514           long pointer = bigTiff ? in.readLong() : 
    515             (long) (in.readInt() & 0xffffffffL); 
    516           in.seek(pointer); 
    517         } 
    518509        if (count == 1) value = new Integer(in.readShort() & 0xffff); 
    519510        else { 
     
    527518      else if (type == LONG) { 
    528519        // 32-bit (4-byte) unsigned integer 
    529         if (count > threshhold / 4) { 
    530           long pointer = bigTiff ? in.readLong() : 
    531             (long) (in.readInt() & 0xffffffffL); 
    532           in.seek(pointer); 
    533         } 
    534520        if (count == 1) value = new Long(in.readInt()); 
    535521        else { 
     
    540526      } 
    541527      else if (type == LONG8 || type == SLONG8 || type == IFD8) { 
    542         if (count > threshhold / 8) { 
    543           long pointer = bigTiff ? in.readLong() : 
    544             (long) (in.readInt() & 0xffffffffL); 
    545           in.seek(pointer); 
    546         } 
    547528        if (count == 1) value = new Long(in.readLong()); 
    548529        else { 
     
    557538        // Two SLONG's: the first represents the numerator of a fraction, 
    558539        // the second the denominator 
    559         long pointer = bigTiff ? in.readLong() : 
    560           (long) (in.readInt() & 0xffffffffL); 
    561         if (count > threshhold / 8) in.seek(pointer); 
    562540        if (count == 1) value = new TiffRational(in.readInt(), in.readInt()); 
    563541        else { 
     
    573551        // UNDEFINED: An 8-bit byte that may contain anything, 
    574552        // depending on the definition of the field 
    575         if (count > threshhold) { 
    576           long pointer = bigTiff ? in.readLong() : 
    577             (long) (in.readInt() & 0xffffffffL); 
    578           in.seek(pointer); 
    579         } 
    580553        if (count == 1) value = new Byte(in.readByte()); 
    581554        else { 
     
    587560      else if (type == SSHORT) { 
    588561        // A 16-bit (2-byte) signed (twos-complement) integer 
    589         if (count > threshhold / 2) { 
    590           long pointer = bigTiff ? in.readLong() : 
    591             (long) (in.readInt() & 0xffffffffL); 
    592           in.seek(pointer); 
    593         } 
    594562        if (count == 1) value = new Short(in.readShort()); 
    595563        else { 
     
    601569      else if (type == SLONG) { 
    602570        // A 32-bit (4-byte) signed (twos-complement) integer 
    603         if (count > threshhold / 4) { 
    604           long pointer = bigTiff ? in.readLong() : 
    605             (long) (in.readInt() & 0xffffffffL); 
    606           in.seek(pointer); 
    607         } 
    608571        if (count == 1) value = new Integer(in.readInt()); 
    609572        else { 
     
    615578      else if (type == FLOAT) { 
    616579        // Single precision (4-byte) IEEE format 
    617         if (count > threshhold / 4) { 
    618           long pointer = bigTiff ? in.readLong() : 
    619             (long) (in.readInt() & 0xffffffffL); 
    620           in.seek(pointer); 
    621         } 
    622580        if (count == 1) value = new Float(in.readFloat()); 
    623581        else { 
     
    629587      else if (type == DOUBLE) { 
    630588        // Double precision (8-byte) IEEE format 
    631         long pointer = bigTiff ? in.readLong() : 
    632           (long) (in.readInt() & 0xffffffffL); 
    633         in.seek(pointer); 
    634589        if (count == 1) value = new Double(in.readDouble()); 
    635590        else { 
  • trunk/loci/formats/in/ZeissLSMReader.java

    r4035 r4037  
    669669    store.setDimensionsPhysicalSizeZ(pixZ, 0, 0); 
    670670 
    671     float firstStamp = ((Double) timestamps.get(0)).floatValue(); 
     671    float firstStamp = 
     672      timestamps.size() == 0 ? 0f : ((Double) timestamps.get(0)).floatValue(); 
    672673 
    673674    for (int i=0; i<core.imageCount[0]; i++) { 
     
    698699      if (checkSuffix(dirList[i], MDB_SUFFIX)) { 
    699700        try { 
    700           mdbFilename = 
    701             (new Location(dir.getPath(), dirList[i])).getAbsolutePath(); 
    702           MDBParser.parseDatabase(mdbFilename, metadata); 
     701          Location file = new Location(dir.getPath(), dirList[i]); 
     702          if (!file.isDirectory()) { 
     703            mdbFilename = file.getAbsolutePath(); 
     704            MDBParser.parseDatabase(mdbFilename, metadata); 
     705          } 
    703706        } 
    704707        catch (Exception exc) { 
     
    728731 
    729732    Vector newIFDs = new Vector(); 
    730     int[] bitsPerSample = TiffTools.getBitsPerSample(ifds[0]); 
    731     long[] byteCounts = TiffTools.getStripByteCounts(ifds[0]); 
    732     boolean uncompressed = 
    733       TiffTools.getCompression(ifds[0]) == TiffTools.UNCOMPRESSED; 
    734733    for (int i=0; i<ifds.length; i++) { 
    735734      long subFileType = TiffTools.getIFDLongValue(ifds[i], 
     
    742741          ifds[i].put(new Integer(TiffTools.PREDICTOR), new Integer(1)); 
    743742        } 
    744         if (i > 0) { 
    745           ifds[i].put(new Integer(TiffTools.BITS_PER_SAMPLE), bitsPerSample); 
    746           if (uncompressed) { 
    747             ifds[i].put(new Integer(TiffTools.STRIP_BYTE_COUNTS), byteCounts); 
    748           } 
    749         } 
    750743        newIFDs.add(ifds[i]); 
    751744      } 
     
    757750 
    758751    initMetadata(); 
     752    core.littleEndian[0] = !core.littleEndian[0]; 
    759753  } 
    760754 
Note: See TracChangeset for help on using the changeset viewer.