Changeset 5996 for branches/cleanup


Ignore:
Timestamp:
03/08/10 08:16:30 (10 years ago)
Author:
melissa
Message:

Tweaked FEI reader to support Philips .img files. See #412.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/cleanup/components/bio-formats/src/loci/formats/in/FEIReader.java

    r5852 r5996  
    3535 
    3636/** 
    37  * FEIReader is the file format reader for FEI .img files. 
     37 * FEIReader is the file format reader for FEI and Philips .img files. 
    3838 * 
    3939 * <dl><dt><b>Source code:</b></dt> 
     
    4646 
    4747  public static final String FEI_MAGIC_STRING = "XL"; 
     48  private static final int INVALID_PIXELS = 112; 
    4849 
    4950  // -- Fields -- 
    5051 
    51   private int originalWidth; 
     52  private int headerSize; 
    5253 
    5354  // -- Constructor -- 
     
    5556  /** Constructs a new FEI reader. */ 
    5657  public FEIReader() { 
    57     super("FEI", "img"); 
     58    super("FEI/Philips", "img"); 
    5859    suffixSufficient = false; 
    5960    domains = new String[] {FormatTools.SEM_DOMAIN}; 
     
    7778    FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); 
    7879 
    79     in.seek(1536); 
     80    in.seek(headerSize); 
     81 
    8082    byte[] segment = new byte[getSizeX() / 2]; 
    81     int skip = (originalWidth / 2) - (getSizeX() / 2); 
    8283    // interlace frames - there are four rows of two columns 
    8384    int halfRow = getSizeX() / 2; 
     
    8687        for (int s=0; s<2; s++) { 
    8788          in.read(segment); 
    88           in.skipBytes(skip); 
     89          in.skipBytes(INVALID_PIXELS / 2); 
    8990          for (int col=s; col<w; col+=2) { 
    9091            buf[row*w + col] = segment[col / 2]; 
     
    100101  public void close(boolean fileOnly) throws IOException { 
    101102    super.close(fileOnly); 
    102     if (!fileOnly) originalWidth = 0; 
     103    if (!fileOnly) { 
     104      headerSize = 0; 
     105    } 
    103106  } 
    104107 
     
    109112    super.initFile(id); 
    110113    in = new RandomAccessInputStream(id); 
     114    in.order(true); 
    111115 
    112116    LOGGER.info("Reading file header"); 
    113117 
    114     in.seek(0x51a); 
    115     in.order(true); 
    116     core[0].sizeX = in.readShort(); 
     118    in.skipBytes(44); 
     119 
     120    float magnification = in.readFloat(); 
     121    float kV = in.readFloat() / 1000; 
     122    float wd = in.readFloat(); 
     123    in.skipBytes(12); 
     124    float spot = in.readFloat(); 
     125 
     126    in.seek(514); 
     127    core[0].sizeX = in.readShort() - INVALID_PIXELS; 
    117128    core[0].sizeY = in.readShort(); 
    118  
    119     originalWidth = getSizeX(); 
    120  
    121     // FEI files can only be 1424x968 or 712x484 
    122  
    123     if (1424 < getSizeX()) { 
    124       core[0].sizeX = 1424; 
    125       core[0].sizeY = 968; 
    126     } 
    127     else { 
    128       core[0].sizeX = 712; 
    129       core[0].sizeY = 484; 
    130     } 
     129    in.skipBytes(4); 
     130    headerSize = in.readShort(); 
    131131 
    132132    // always one grayscale plane per file 
Note: See TracChangeset for help on using the changeset viewer.