Changeset 3054 for trunk


Ignore:
Timestamp:
08/07/07 13:36:10 (13 years ago)
Author:
curtis
Message:

Several bugfixes to ImprovisionTiffReader.isThisType.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/in/ImprovisionTiffReader.java

    r3036 r3054  
    5454  /* @see loci.formats.IFormatHandler#isThisType(String, boolean) */ 
    5555  public boolean isThisType(String name, boolean open) { 
    56     if (!name.toLowerCase().endsWith("tif") && 
    57       !name.toLowerCase().endsWith("tiff")) 
    58     { 
    59       return false; 
    60     } 
    61  
    62     try { 
    63       RandomAccessStream ras = new RandomAccessStream(name); 
    64       Hashtable ifd = TiffTools.getFirstIFD(ras); 
    65       ras.close(); 
    66       if (ifd == null) return false; 
    67  
    68       String comment = 
    69         (String) ifd.get(new Integer(TiffTools.IMAGE_DESCRIPTION)); 
    70       return comment.indexOf("Improvision") != -1; 
    71     } 
    72     catch (Exception e) { return false; } 
     56    if (!super.isThisType(name, open)) return false; // check extension 
     57 
     58    if (open) { 
     59      try { 
     60        RandomAccessStream ras = new RandomAccessStream(name); 
     61        Hashtable ifd = TiffTools.getFirstIFD(ras); 
     62        ras.close(); 
     63        if (ifd == null) return false; 
     64 
     65        String comment = 
     66          (String) ifd.get(new Integer(TiffTools.IMAGE_DESCRIPTION)); 
     67        return comment == null ? false : comment.indexOf("Improvision") != -1; 
     68      } 
     69      catch (IOException exc) { 
     70        if (debug) trace(exc); 
     71        return false; 
     72      } 
     73    } 
     74    else return false; 
    7375  } 
    7476 
Note: See TracChangeset for help on using the changeset viewer.