Changeset 2584


Ignore:
Timestamp:
04/09/07 13:55:11 (13 years ago)
Author:
melissa
Message:

Moved several variables out of the readers and into CoreMetadata.

Location:
trunk/loci/formats
Files:
45 edited

Legend:

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

    r2557 r2584  
    2727/** Encompasses core metadata values. */ 
    2828public class CoreMetadata { 
    29   public int[] sizeX, sizeY, sizeZ, sizeC, sizeT, pixelType; 
     29  public int[] sizeX, sizeY, sizeZ, sizeC, sizeT, pixelType, imageCount; 
    3030  public int[][] cLengths; 
    3131  public String[][] cTypes; 
    3232  public String[] currentOrder; 
    33   public boolean[] orderCertain; 
     33  public boolean[] orderCertain, rgb, littleEndian, interleaved; 
    3434 
    3535  public CoreMetadata(int series) { 
     
    4040    sizeT = new int[series]; 
    4141    pixelType = new int[series]; 
     42    imageCount = new int[series]; 
    4243    cLengths = new int[series][]; 
    4344    cTypes = new String[series][]; 
    4445    currentOrder = new String[series]; 
    4546    orderCertain = new boolean[series]; 
     47    rgb = new boolean[series]; 
     48    littleEndian = new boolean[series]; 
     49    interleaved = new boolean[series]; 
    4650  } 
    4751 
  • trunk/loci/formats/FormatReader.java

    r2583 r2584  
    4848 
    4949  // -- Fields -- 
     50 
     51  /** Current file. */ 
     52  protected RandomAccessStream in; 
    5053 
    5154  /** Hashtable containing metadata key/value pairs. */ 
     
    188191 
    189192  /* @see IFormatReader#getImageCount() */ 
    190   public abstract int getImageCount() throws FormatException, IOException; 
     193  public int getImageCount() throws FormatException, IOException { 
     194    return core.imageCount[series]; 
     195  } 
    191196 
    192197  /* @see IFormatReader#setId(String) */ 
     
    197202  /* @see IFormatReader#isRGB() */ 
    198203  public boolean isRGB() throws FormatException, IOException { 
    199     return getRGBChannelCount() > 1; 
     204    return core.rgb[series]; 
    200205  } 
    201206 
     
    274279 
    275280  /* @see IFormatReader.isLittleEndian() */ 
    276   public abstract boolean isLittleEndian() throws FormatException, IOException; 
     281  public boolean isLittleEndian() throws FormatException, IOException { 
     282    return core.littleEndian[series]; 
     283  } 
    277284 
    278285  /* @see IFormatReader#getDimensionOrder() */ 
     
    292299 
    293300  /* @see IFormatReader#isInterleaved(int) */ 
    294   public abstract boolean isInterleaved(int subC)  
    295     throws FormatException, IOException; 
     301  public boolean isInterleaved(int subC) throws FormatException, IOException { 
     302    return core.interleaved[series]; 
     303  } 
    296304 
    297305  /* @see IFormatReader#openImage(int) */ 
     
    331339 
    332340  /* @see IFormatReader#close() */ 
    333   public abstract void close() throws FormatException, IOException; 
     341  public void close() throws FormatException, IOException { 
     342    if (in != null) in.close(); 
     343    in = null; 
     344    currentId = null; 
     345  } 
    334346 
    335347  /* @see IFormatReader#getSeriesCount() */ 
    336348  public int getSeriesCount() throws FormatException, IOException { 
    337     return 1; 
     349    return core.sizeX.length; 
    338350  } 
    339351 
  • trunk/loci/formats/in/AVIReader.java

    r2583 r2584  
    4040  // -- Fields -- 
    4141 
    42   /** Current file. */ 
    43   protected RandomAccessStream in; 
    44  
    45   /** Number of images in current AVI movie. */ 
    46   private int numImages; 
    47  
    4842  /** Offset to each plane. */ 
    4943  private Vector offsets; 
    50  
    51   /** Endianness flag. */ 
    52   private boolean little = true; 
    5344 
    5445  private String type = "error"; 
     
    8475  } 
    8576 
    86   /* @see loci.formats.IFormatReader#getImageCount() */  
    87   public int getImageCount() throws FormatException, IOException { 
    88     return numImages; 
    89   } 
    90  
    91   /* @see loci.formats.IFormatReader#isRGB() */ 
    92   public boolean isRGB() throws FormatException, IOException { 
    93     return bmpBitsPerPixel > 8; 
    94   } 
    95  
    96   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    97   public boolean isLittleEndian() throws FormatException, IOException { 
    98     return little; 
    99   } 
    100  
    101   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    102   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    103     return false; 
    104   } 
    105  
    10677  /* @see loci.formats.IFormatReader#openBytes(int) */  
    10778  public byte[] openBytes(int no) throws FormatException, IOException { 
     
    155126    } 
    156127    else close(); 
    157   } 
    158  
    159   /* @see loci.formats.IFormatReader#close() */  
    160   public void close() throws FormatException, IOException { 
    161     if (in != null) in.close(); 
    162     in = null; 
    163     currentId = null; 
    164128  } 
    165129 
     
    447411    status("Populating metadata");   
    448412     
    449     numImages = offsets.size(); 
    450  
     413    core.imageCount[0] = offsets.size(); 
     414 
     415    core.rgb[0] = bmpBitsPerPixel > 8; 
    451416    core.sizeZ[0] = 1; 
    452     core.sizeC[0] = isRGB() ? 3 : 1; 
    453     core.sizeT[0] = numImages; 
     417    core.sizeC[0] = core.rgb[0] ? 3 : 1; 
     418    core.sizeT[0] = core.imageCount[0]; 
    454419    core.currentOrder[0] = core.sizeC[0] == 3 ? "XYCTZ" : "XYTCZ"; 
     420    core.littleEndian[0] = true; 
    455421 
    456422    int bitsPerPixel = ((Integer) getMeta("Bits per pixel")).intValue(); 
     
    469435      new Integer(core.sizeZ[0]), // SizeZ 
    470436      new Integer(core.sizeC[0]), // SizeC 
    471       new Integer(numImages), // SizeT 
     437      new Integer(core.sizeT[0]), // SizeT 
    472438      new Integer(core.pixelType[0]), // PixelType 
    473       new Boolean(!little), // BigEndian 
     439      new Boolean(!core.littleEndian[0]), // BigEndian 
    474440      core.currentOrder[0], // DimensionOrder 
    475441      null, // Use image index 0 
  • trunk/loci/formats/in/AliconaReader.java

    r2583 r2584  
    3535  // -- Fields -- 
    3636 
    37   /** Current file. */ 
    38   protected RandomAccessStream in; 
    39  
    40   /** Number of image planes in the file. */ 
    41   protected int numImages = 0; 
    42  
    4337  /** Image offset. */ 
    4438  private int textureOffset; 
     
    5953  } 
    6054  
    61   /* @see loci.formats.IFormatReader#getImageCount() */ 
    62   public int getImageCount() throws FormatException, IOException { 
    63     return numImages; 
    64   } 
    65  
    66   /* @see loci.formats.IFormatReader#isRGB() */ 
    67   public boolean isRGB() throws FormatException, IOException { 
    68     return false; 
    69   } 
    70  
    71   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    72   public boolean isLittleEndian() throws FormatException, IOException { 
    73     return true; 
    74   } 
    75  
    76   /* @see loci.formats.IFormatReader#isInterleaved(, int) */  
    77   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    78     return false; 
    79   } 
    80  
    8155  /* @see loci.formats.IFormatReader#openBytes(int) */  
    8256  public byte[] openBytes(int no) throws FormatException, IOException { 
     
    12094    if (fileOnly && in != null) in.close(); 
    12195    else if (!fileOnly) close(); 
    122   } 
    123  
    124   /* @see loci.formats.IFormatReader#close() */  
    125   public void close() throws FormatException, IOException { 
    126     if (in != null) in.close(); 
    127     in = null; 
    128     currentId = null; 
    12996  } 
    13097 
     
    171138      else if (key.equals("Cols")) core.sizeX[0] = Integer.parseInt(value); 
    172139      else if (key.equals("NumberOfPlanes")) { 
    173         numImages = Integer.parseInt(value); 
     140        core.imageCount[0] = Integer.parseInt(value); 
    174141      } 
    175142      else if (key.equals("TextureImageOffset")) { 
     
    181148 
    182149    numBytes = (int) (in.length() - textureOffset) /  
    183       (core.sizeX[0] * core.sizeY[0] * numImages); 
     150      (core.sizeX[0] * core.sizeY[0] * core.imageCount[0]); 
    184151 
    185152    boolean hasC = !((String) getMeta("TexturePtr")).trim().equals("7"); 
     
    187154    core.sizeC[0] = hasC ? 3 : 1; 
    188155    core.sizeZ[0] = 1; 
    189     core.sizeT[0] = numImages / core.sizeC[0]; 
     156    core.sizeT[0] = core.imageCount[0] / core.sizeC[0]; 
     157    core.rgb[0] = false; 
     158    core.interleaved[0] = false; 
     159    core.littleEndian[0] = true; 
    190160 
    191161    core.pixelType[0] = numBytes == 2 ? FormatTools.UINT16 : FormatTools.UINT8; 
     
    200170      new Integer(core.sizeT[0]), 
    201171      new Integer(core.pixelType[0]), 
    202       new Boolean(true), 
     172      new Boolean(!core.littleEndian[0]),  
    203173      core.currentOrder[0], 
    204174      null, 
  • trunk/loci/formats/in/BMPReader.java

    r2583 r2584  
    4040  // -- Fields -- 
    4141 
    42   /** Current file. */ 
    43   protected RandomAccessStream in; 
    44  
    4542  /** Offset to the image data. */ 
    4643  protected int offset; 
     
    8077  } 
    8178 
    82   /* @see loci.formats.IFormatReader#getImageCount() */  
    83   public int getImageCount() throws FormatException, IOException { 
    84     return 1; 
    85   } 
    86  
    87   /* @see loci.formats.IFormatReader#isRGB() */ 
    88   public boolean isRGB() throws FormatException, IOException { 
    89     return bpp > 8; 
    90   } 
    91  
    92   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    93   public boolean isLittleEndian() throws FormatException, IOException { 
    94     return true; 
    95   } 
    96  
    97   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    98   public boolean isInterleaved(int subC) 
    99     throws FormatException, IOException 
    100   { 
    101     return true; 
    102   } 
    103  
    10479  /* @see loci.formats.IFormatReader#openBytes(int, byte[]) */ 
    10580  public byte[] openBytes(int no, byte[] buf) 
     
    174149  } 
    175150 
    176   /* @see loci.formats.IFormatReader#close() */  
    177   public void close() throws FormatException, IOException { 
    178     if (in != null) in.close(); 
    179     in = null; 
    180     currentId = null; 
    181   } 
    182  
    183151  /** Initializes the given BMP file. */ 
    184152  protected void initFile(String id) throws FormatException, IOException { 
     
    284252 
    285253    if (core.sizeX[0] % 2 == 1) core.sizeX[0]++;  
     254    core.rgb[0] = bpp > 8;  
     255    core.littleEndian[0] = true; 
     256    core.interleaved[0] = true; 
     257    core.imageCount[0] = 1;  
    286258    core.sizeZ[0] = 1; 
    287     core.sizeC[0] = isRGB() ? 3 : 1; 
     259    core.sizeC[0] = core.rgb[0] ? 3 : 1; 
    288260    core.sizeT[0] = 1; 
    289261    core.currentOrder[0] = "XYCTZ"; 
  • trunk/loci/formats/in/BaseTiffReader.java

    r2583 r2584  
    4444  // -- Fields -- 
    4545 
    46   /** Current TIFF file. */ 
    47   protected RandomAccessStream in; 
    48  
    4946  /** List of IFDs for the current TIFF. */ 
    5047  protected Hashtable[] ifds; 
    51  
    52   /** Number of images in the current TIFF stack. */ 
    53   protected int numImages; 
    5448 
    5549  // -- Constructors -- 
     
    7165      TiffTools.getIFDIntValue(ifds[0], TiffTools.IMAGE_WIDTH, false, -1), 
    7266      TiffTools.getIFDIntValue(ifds[0], TiffTools.IMAGE_LENGTH, false, -1), 
    73       numImages 
     67      core.imageCount[0]  
    7468    }; 
    7569  } 
     
    445439    } 
    446440 
     441    int samples = TiffTools.getIFDIntValue(ifds[0],  
     442      TiffTools.SAMPLES_PER_PIXEL, false, 1); 
     443    core.rgb[0] = samples > 1 || p == TiffTools.RGB_PALETTE || 
     444      p == TiffTools.CFA_ARRAY || p == TiffTools.RGB; 
     445    core.interleaved[0] = TiffTools.getSamplesPerPixel(ifds[0]) > 1; 
     446    core.littleEndian[0] = TiffTools.isLittleEndian(ifds[0]); 
     447 
    447448    core.sizeX[0] = 
    448449      TiffTools.getIFDIntValue(ifds[0], TiffTools.IMAGE_WIDTH, false, 0); 
     
    450451      TiffTools.getIFDIntValue(ifds[0], TiffTools.IMAGE_LENGTH, false, 0); 
    451452    core.sizeZ[0] = 1; 
    452  
    453     try { 
    454       core.sizeC[0] = isRGB() ? 3 : 1; 
    455     } 
    456     catch (IOException e) { 
    457       throw new FormatException(e); 
    458     } 
    459  
     453    core.sizeC[0] = core.rgb[0] ? 3 : 1; 
    460454    core.sizeT[0] = ifds.length; 
    461455 
     
    686680  } 
    687681 
    688   /* @see loci.formats.IFormatReader#getImageCount() */  
    689   public int getImageCount() throws FormatException, IOException { 
    690     return numImages; 
    691   } 
    692  
    693   /* @see loci.formats.IFormatReader#isRGB() */ 
    694   public boolean isRGB() throws FormatException, IOException { 
    695     if (TiffTools.getIFDIntValue(ifds[0], 
    696       TiffTools.SAMPLES_PER_PIXEL, false, 1) > 1) 
    697     { 
    698       return true; 
    699     } 
    700     int p = TiffTools.getIFDIntValue(ifds[0], 
    701       TiffTools.PHOTOMETRIC_INTERPRETATION, true, 0); 
    702     return p == TiffTools.RGB_PALETTE || p == TiffTools.CFA_ARRAY ||  
    703       p == TiffTools.RGB; 
    704   } 
    705  
    706682  /* @see loci.formats.IFormatReader#getMetadataValue(String) */  
    707683  public Object getMetadataValue(String field) 
     
    709685  { 
    710686    return getMeta(field); 
    711   } 
    712  
    713   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    714   public boolean isLittleEndian() throws FormatException, IOException { 
    715     return TiffTools.isLittleEndian(ifds[0]); 
    716   } 
    717  
    718   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    719   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    720     return TiffTools.getSamplesPerPixel(ifds[0]) > 1;  
    721687  } 
    722688 
     
    760726  } 
    761727 
    762   /* @see loci.formats.IFormatReader#close() */  
    763   public void close() throws FormatException, IOException { 
    764     if (in != null) in.close(); 
    765     in = null; 
    766     currentId = null; 
    767   } 
    768  
    769728  /** Initializes the given TIFF file. */ 
    770729  protected void initFile(String id) throws FormatException, IOException { 
     
    781740    status("Populating metadata");  
    782741 
    783     numImages = ifds.length; 
     742    core.imageCount[0] = ifds.length; 
    784743    initMetadata(); 
    785744  } 
  • trunk/loci/formats/in/BioRadReader.java

    r2583 r2584  
    6565  // -- Fields -- 
    6666 
    67   /** Input stream for current Bio-Rad PIC. */ 
    68   private RandomAccessStream in; 
    69  
    70   /** Number of images in current Bio-Rad PIC. */ 
    71   private int npic; 
    72  
    7367  /** Flag indicating current Bio-Rad PIC is packed with bytes. */ 
    7468  private boolean byteFormat; 
     
    8781  } 
    8882 
    89   /* @see loci.formats.IFormatReader#getImageCount() */  
    90   public int getImageCount() throws FormatException, IOException { 
    91     return npic; 
    92   } 
    93  
    94   /* @see loci.formats.IFormatReader#isRGB() */ 
    95   public boolean isRGB() throws FormatException, IOException { 
    96     return false; 
    97   } 
    98  
    99   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    100   public boolean isLittleEndian() throws FormatException, IOException { 
    101     return LITTLE_ENDIAN; 
    102   } 
    103  
    104   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    105   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    106     return false; 
    107   } 
    108  
    10983  /* @see loci.formats.IFormatReader#openBytes(int) */  
    11084  public byte[] openBytes(int no) throws FormatException, IOException { 
     
    11791    throws FormatException, IOException 
    11892  { 
    119     if (no < 0 || no >= npic) { 
     93    if (no < 0 || no >= core.imageCount[0]) { 
    12094      throw new FormatException("Invalid image number: " + no); 
    12195    } 
     
    143117  } 
    144118 
    145   /* @see loci.formats.IFormatReader#close() */  
    146   public void close() throws FormatException, IOException { 
    147     currentId = null; 
    148     if (in != null) in.close(); 
    149     in = null; 
    150     metadata = null; 
    151   } 
    152  
    153119  /** Initializes the given Bio-Rad file. */ 
    154120  protected void initFile(String id) throws FormatException, IOException { 
     
    164130    core.sizeX[0] = in.readShort(); 
    165131    core.sizeY[0] = in.readShort(); 
    166     npic = in.readShort(); 
     132    core.imageCount[0] = in.readShort(); 
    167133 
    168134    int ramp1min = in.readShort(); 
     
    192158    addMeta("nx", new Integer(core.sizeX[0])); 
    193159    addMeta("ny", new Integer(core.sizeY[0])); 
    194     addMeta("npic", new Integer(npic)); 
     160    addMeta("npic", new Integer(core.imageCount[0])); 
    195161    addMeta("ramp1_min", new Integer(ramp1min)); 
    196162    addMeta("ramp1_max", new Integer(ramp1max)); 
     
    212178    int imageLen = core.sizeX[0] * core.sizeY[0]; 
    213179    int bpp = byteFormat ? 1 : 2; 
    214     in.skipBytes(bpp * npic * imageLen + 6); 
     180    in.skipBytes(bpp * core.imageCount[0] * imageLen + 6); 
    215181 
    216182    Vector pixelSize = new Vector(); 
    217183 
    218     core.sizeZ[0] = npic; 
     184    core.sizeZ[0] = core.imageCount[0]; 
    219185    core.sizeC[0] = 1; 
    220186    core.sizeT[0] = 1; 
    221187 
    222188    core.orderCertain[0] = false; 
     189    core.rgb[0] = false; 
     190    core.interleaved[0] = false; 
     191    core.littleEndian[0] = LITTLE_ENDIAN; 
    223192 
    224193    status("Reading notes"); 
     
    494463                addMeta(key + " time (Y) in seconds", params.get(1)); 
    495464                core.sizeZ[0] = 1; 
    496                 core.sizeT[0] = npic; 
     465                core.sizeT[0] = core.imageCount[0]; 
    497466                core.orderCertain[0] = true; 
    498467              } 
  • trunk/loci/formats/in/DeltavisionReader.java

    r2583 r2584  
    4242  // -- Fields -- 
    4343 
    44   /** Current file. */ 
    45   protected RandomAccessStream in; 
    46  
    47   /** Number of images in the current file. */ 
    48   protected int numImages; 
    49  
    50   /** Flag indicating whether current file is little endian. */ 
    51   protected boolean little; 
    52  
    5344  /** Byte array containing basic image header data. */ 
    5445  protected byte[] header; 
     
    9384  /* @see loci.formats.IFormatReader#isThisType(byte[]) */  
    9485  public boolean isThisType(byte[] block) { 
    95     return (DataTools.bytesToShort(block, 0, 2, little) == LITTLE_ENDIAN); 
    96   } 
    97  
    98   /* @see loci.formats.IFormatReader#getImageCount() */  
    99   public int getImageCount() throws FormatException, IOException { 
    100     return numImages; 
    101   } 
    102  
    103   /* @see loci.formats.IFormatReader#isRGB() */ 
    104   public boolean isRGB() throws FormatException, IOException { 
    105     return false; 
    106   } 
    107  
    108   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    109   public boolean isLittleEndian() throws FormatException, IOException { 
    110     return little; 
    111   } 
    112  
    113   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    114   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    115     return false; 
     86    return (DataTools.bytesToShort(block, 0, 2, core.littleEndian[0]) ==  
     87      LITTLE_ENDIAN); 
    11688  } 
    11789 
    11890  /* @see loci.formats.IFormatReader#openBytes(int) */  
    119   public byte[] openBytes(int no) 
    120     throws FormatException, IOException 
    121   { 
     91  public byte[] openBytes(int no) throws FormatException, IOException { 
    12292    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * bytesPerPixel]; 
    12393    return openBytes(no, buf); 
     
    12898    throws FormatException, IOException 
    12999  { 
    130     if (no < 0 || no >= numImages) { 
     100    if (no < 0 || no >= core.imageCount[0]) { 
    131101      throw new FormatException("Invalid image number: " + no); 
    132102    } 
     
    146116  { 
    147117    return ImageTools.makeImage(openBytes(no), core.sizeX[0],  
    148       core.sizeY[0], 1, false, bytesPerPixel, little); 
     118      core.sizeY[0], 1, false, bytesPerPixel, core.littleEndian[0]); 
    149119  } 
    150120 
     
    155125  } 
    156126 
    157   /* @see loci.formats.IFormatReader#close() */  
    158   public void close() throws FormatException, IOException { 
    159     if (in != null) in.close(); 
    160     in = null; 
    161     currentId = null; 
    162   } 
    163  
    164127  /** Initializes the given Deltavision file. */ 
    165128  protected void initFile(String id) throws FormatException, IOException { 
     
    176139 
    177140    int endian = DataTools.bytesToShort(header, 96, 2, true); 
    178     little = endian == LITTLE_ENDIAN; 
    179     numImages = DataTools.bytesToInt(header, 8, 4, little); 
    180  
    181     int extSize = DataTools.bytesToInt(header, 92, 4, little); 
     141    core.littleEndian[0] = endian == LITTLE_ENDIAN; 
     142    RandomAccessStream hstream = new RandomAccessStream(header); 
     143    hstream.order(core.littleEndian[0]); 
     144 
     145    hstream.skipBytes(8); 
     146    core.imageCount[0] = hstream.readInt(); 
     147 
     148    hstream.seek(92); 
     149    int extSize = hstream.readInt(); 
    182150    extHeader = new byte[extSize]; 
    183151    in.read(extHeader); 
    184152 
    185     core.sizeX[0] = DataTools.bytesToInt(header, 0, 4, little); 
    186     core.sizeY[0] = DataTools.bytesToInt(header, 4, 4, little); 
     153    hstream.seek(0); 
     154    core.sizeX[0] = hstream.readInt(); 
     155    core.sizeY[0] = hstream.readInt(); 
    187156 
    188157    Integer xSize = new Integer(core.sizeX[0]); 
     
    190159    addMeta("ImageWidth", xSize); 
    191160    addMeta("ImageHeight", ySize); 
    192     addMeta("NumberOfImages", new Integer(DataTools.bytesToInt(header, 
    193       8, 4, little))); 
    194     int filePixelType = DataTools.bytesToInt(header, 12, 4, little); 
     161    addMeta("NumberOfImages", new Integer(hstream.readInt())); 
     162    int filePixelType = hstream.readInt(); 
    195163    String pixel; 
    196164 
     
    233201 
    234202    addMeta("PixelType", pixel); 
    235     addMeta("Sub-image starting point (X)", new Integer( 
    236       DataTools.bytesToInt(header, 16, 4, little))); 
    237     addMeta("Sub-image starting point (Y)", new Integer( 
    238       DataTools.bytesToInt(header, 20, 4, little))); 
    239     addMeta("Sub-image starting point (Z)", new Integer( 
    240       DataTools.bytesToInt(header, 24, 4, little))); 
    241     addMeta("Pixel sampling size (X)", new Integer( 
    242       DataTools.bytesToInt(header, 28, 4, little))); 
    243     addMeta("Pixel sampling size (Y)", new Integer( 
    244       DataTools.bytesToInt(header, 32, 4, little))); 
    245     addMeta("Pixel sampling size (Z)", new Integer( 
    246       DataTools.bytesToInt(header, 36, 4, little))); 
    247     addMeta("X element length (in um)", new Float(Float.intBitsToFloat( 
    248       DataTools.bytesToInt(header, 40, 4, little)))); 
    249     addMeta("Y element length (in um)", new Float(Float.intBitsToFloat( 
    250       DataTools.bytesToInt(header, 44, 4, little)))); 
    251     addMeta("Z element length (in um)", new Float(Float.intBitsToFloat( 
    252       DataTools.bytesToInt(header, 48, 4, little)))); 
    253     addMeta("X axis angle", new Float(Float.intBitsToFloat( 
    254       DataTools.bytesToInt(header, 52, 4, little)))); 
    255     addMeta("Y axis angle", new Float(Float.intBitsToFloat( 
    256       DataTools.bytesToInt(header, 56, 4, little)))); 
    257     addMeta("Z axis angle", new Float(Float.intBitsToFloat( 
    258       DataTools.bytesToInt(header, 60, 4, little)))); 
    259     addMeta("Column axis sequence", new Integer( 
    260       DataTools.bytesToInt(header, 64, 4, little))); 
    261     addMeta("Row axis sequence", new Integer( 
    262       DataTools.bytesToInt(header, 68, 4, little))); 
    263     addMeta("Section axis sequence", new Integer( 
    264       DataTools.bytesToInt(header, 72, 4, little))); 
    265     Float wave1Min = new Float(Float.intBitsToFloat( 
    266         DataTools.bytesToInt(header, 76, 4, little))); 
     203    addMeta("Sub-image starting point (X)", new Integer(hstream.readInt())); 
     204    addMeta("Sub-image starting point (Y)", new Integer(hstream.readInt())); 
     205    addMeta("Sub-image starting point (Z)", new Integer(hstream.readInt())); 
     206    addMeta("Pixel sampling size (X)", new Integer(hstream.readInt())); 
     207    addMeta("Pixel sampling size (Y)", new Integer(hstream.readInt())); 
     208    addMeta("Pixel sampling size (Z)", new Integer(hstream.readInt())); 
     209    addMeta("X element length (in um)", new Float(hstream.readFloat())); 
     210    addMeta("Y element length (in um)", new Float(hstream.readFloat())); 
     211    addMeta("Z element length (in um)", new Float(hstream.readFloat())); 
     212    addMeta("X axis angle", new Float(hstream.readFloat())); 
     213    addMeta("Y axis angle", new Float(hstream.readFloat())); 
     214    addMeta("Z axis angle", new Float(hstream.readFloat())); 
     215    addMeta("Column axis sequence", new Integer(hstream.readInt())); 
     216    addMeta("Row axis sequence", new Integer(hstream.readInt())); 
     217    addMeta("Section axis sequence", new Integer(hstream.readInt())); 
     218    Float wave1Min = new Float(hstream.readFloat()); 
    267219    addMeta("Wavelength 1 min. intensity", wave1Min); 
    268     Float wave1Max = new Float(Float.intBitsToFloat( 
    269         DataTools.bytesToInt(header, 80, 4, little))); 
     220    Float wave1Max = new Float(hstream.readFloat()); 
    270221    addMeta("Wavelength 1 max. intensity", wave1Max); 
    271     addMeta("Wavelength 1 mean intensity", new Float(Float.intBitsToFloat( 
    272       DataTools.bytesToInt(header, 84, 4, little)))); 
    273     addMeta("Space group number", new Integer( 
    274       DataTools.bytesToInt(header, 88, 4, little))); 
    275     addMeta("Number of Sub-resolution sets", new Integer( 
    276       DataTools.bytesToInt(header, 132, 2, little))); 
    277     addMeta("Z axis reduction quotient", new Integer( 
    278       DataTools.bytesToInt(header, 134, 2, little))); 
    279     Float wave2Min = new Float( 
    280       Float.intBitsToFloat(DataTools.bytesToInt(header, 136, 4, little))); 
     222    addMeta("Wavelength 1 mean intensity", new Float(hstream.readFloat())); 
     223    addMeta("Space group number", new Integer(hstream.readInt())); 
     224     
     225    hstream.seek(132);  
     226    addMeta("Number of Sub-resolution sets", new Integer(hstream.readShort())); 
     227    addMeta("Z axis reduction quotient", new Integer(hstream.readShort())); 
     228    Float wave2Min = new Float(hstream.readFloat()); 
    281229    addMeta("Wavelength 2 min. intensity", wave2Min); 
    282     Float wave2Max = new Float( 
    283       Float.intBitsToFloat(DataTools.bytesToInt(header, 140, 4, little))); 
     230    Float wave2Max = new Float(hstream.readFloat()); 
    284231    addMeta("Wavelength 2 max. intensity", wave2Max); 
    285232 
    286     Float wave3Min = new Float( 
    287       Float.intBitsToFloat(DataTools.bytesToInt(header, 144, 4, little))); 
     233    Float wave3Min = new Float(hstream.readFloat()); 
    288234    addMeta("Wavelength 3 min. intensity", wave3Min); 
    289235 
    290     Float wave3Max = new Float( 
    291       Float.intBitsToFloat(DataTools.bytesToInt(header, 148, 4, little))); 
     236    Float wave3Max = new Float(hstream.readFloat()); 
    292237    addMeta("Wavelength 3 max. intensity", wave3Max); 
    293238 
    294     Float wave4Min = new Float( 
    295       Float.intBitsToFloat(DataTools.bytesToInt(header, 152, 4, little))); 
     239    Float wave4Min = new Float(hstream.readFloat()); 
    296240    addMeta("Wavelength 4 min. intensity", wave4Min); 
    297241 
    298     Float wave4Max = new Float( 
    299       Float.intBitsToFloat(DataTools.bytesToInt(header, 156, 4, little))); 
     242    Float wave4Max = new Float(hstream.readFloat()); 
    300243    addMeta("Wavelength 4 max. intensity", wave4Max); 
    301244 
    302     int type = DataTools.bytesToShort(header, 160, 2, little); 
     245    int type = hstream.readShort(); 
    303246    String imageType; 
    304247    switch (type) { 
     
    323266 
    324267    addMeta("Image Type", imageType); 
    325     addMeta("Lens ID Number", new Integer(DataTools.bytesToShort( 
    326       header, 162, 2, little))); 
    327     Float wave5Min = new Float( 
    328       Float.intBitsToFloat(DataTools.bytesToInt(header, 172, 4, little))); 
     268    addMeta("Lens ID Number", new Integer(hstream.readShort())); 
     269     
     270    hstream.seek(172);  
     271    Float wave5Min = new Float(hstream.readFloat()); 
    329272    addMeta("Wavelength 5 min. intensity", wave5Min); 
    330273 
    331     Float wave5Max = new Float( 
    332       Float.intBitsToFloat(DataTools.bytesToInt(header, 176, 4, little))); 
     274    Float wave5Max = new Float(hstream.readFloat()); 
    333275    addMeta("Wavelength 5 max. intensity", wave5Max); 
    334276 
    335     core.sizeT[0] = DataTools.bytesToShort(header, 180, 2, little); 
     277    core.sizeT[0] = hstream.readShort(); 
    336278    addMeta("Number of timepoints", new Integer(core.sizeT[0])); 
    337279 
    338     int sequence = DataTools.bytesToInt(header, 182, 4, little); 
     280    int sequence = hstream.readShort(); 
    339281    String imageSequence; 
    340282    switch (sequence) { 
     
    356298    addMeta("Image sequence", imageSequence); 
    357299 
    358     addMeta("X axis tilt angle", new Float(Float.intBitsToFloat( 
    359       DataTools.bytesToInt(header, 184, 4, little)))); 
    360     addMeta("Y axis tilt angle", new Float(Float.intBitsToFloat( 
    361       DataTools.bytesToInt(header, 188, 4, little)))); 
    362     addMeta("Z axis tilt angle", new Float(Float.intBitsToFloat( 
    363       DataTools.bytesToInt(header, 192, 4, little)))); 
    364  
    365     core.sizeC[0] = DataTools.bytesToShort(header, 196, 2, little); 
     300    addMeta("X axis tilt angle", new Float(hstream.readFloat())); 
     301    addMeta("Y axis tilt angle", new Float(hstream.readFloat())); 
     302    addMeta("Z axis tilt angle", new Float(hstream.readFloat())); 
     303 
     304    core.sizeC[0] = hstream.readShort(); 
    366305    addMeta("Number of wavelengths", new Integer(core.sizeC[0])); 
    367     core.sizeZ[0] = numImages / (core.sizeC[0] * core.sizeT[0]); 
     306    core.sizeZ[0] = core.imageCount[0] / (core.sizeC[0] * core.sizeT[0]); 
    368307    addMeta("Number of focal planes", new Integer(core.sizeZ[0])); 
    369308 
    370     addMeta("Wavelength 1 (in nm)", new Integer(DataTools.bytesToShort( 
    371       header, 198, 2, little))); 
    372     addMeta("Wavelength 2 (in nm)", new Integer(DataTools.bytesToShort( 
    373       header, 200, 2, little))); 
    374     addMeta("Wavelength 3 (in nm)", new Integer(DataTools.bytesToShort( 
    375       header, 202, 2, little))); 
    376     addMeta("Wavelength 4 (in nm)", new Integer(DataTools.bytesToShort( 
    377       header, 204, 2, little))); 
    378     addMeta("Wavelength 5 (in nm)", new Integer(DataTools.bytesToShort( 
    379       header, 206, 2, little))); 
    380     addMeta("X origin (in um)", new Float(Float.intBitsToFloat( 
    381       DataTools.bytesToInt(header, 208, 4, little)))); 
    382     addMeta("Y origin (in um)", new Float(Float.intBitsToFloat( 
    383       DataTools.bytesToInt(header, 212, 4, little)))); 
    384     addMeta("Z origin (in um)", new Float(Float.intBitsToFloat( 
    385       DataTools.bytesToInt(header, 216, 4, little)))); 
     309    core.rgb[0] = false; 
     310    core.interleaved[0] = false; 
     311     
     312    addMeta("Wavelength 1 (in nm)", new Integer(hstream.readShort())); 
     313    addMeta("Wavelength 2 (in nm)", new Integer(hstream.readShort())); 
     314    addMeta("Wavelength 3 (in nm)", new Integer(hstream.readShort())); 
     315    addMeta("Wavelength 4 (in nm)", new Integer(hstream.readShort())); 
     316    addMeta("Wavelength 5 (in nm)", new Integer(hstream.readShort())); 
     317    addMeta("X origin (in um)", new Float(hstream.readFloat())); 
     318    addMeta("Y origin (in um)", new Float(hstream.readFloat())); 
     319    addMeta("Z origin (in um)", new Float(hstream.readFloat())); 
    386320 
    387321    // The metadata store we're working with. 
     
    399333    status("Reading extended header"); 
    400334 
    401     numIntsPerSection = DataTools.bytesToInt(header, 128, 2, little); 
    402     numFloatsPerSection = DataTools.bytesToInt(header, 130, 2, little); 
     335    hstream.seek(128); 
     336    numIntsPerSection = hstream.readShort(); 
     337    numFloatsPerSection = hstream.readShort(); 
    403338    setOffsetInfo(sequence, core.sizeZ[0], core.sizeC[0], core.sizeT[0]); 
    404339    extHdrFields =  
     
    408343      new Integer(core.sizeZ[0]), new Integer(core.sizeC[0]),  
    409344      new Integer(core.sizeT[0]), new Integer(core.pixelType[0]), 
    410       new Boolean(!little), core.currentOrder[0], null, null); 
     345      new Boolean(!core.littleEndian[0]), core.currentOrder[0], null, null); 
    411346 
    412347    store.setDimensions( 
     
    427362        for (int w = 0; w < core.sizeC[0]; w++) { 
    428363          extHdrFields[z][w][t] = new DVExtHdrFields(getTotalOffset(z, w, t), 
    429             numIntsPerSection, extHeader, little); 
     364            numIntsPerSection, extHeader, core.littleEndian[0]); 
    430365 
    431366          store.setPlaneInfo(z, w, t, 
  • trunk/loci/formats/in/DicomReader.java

    r2583 r2584  
    7575  // -- Fields -- 
    7676 
    77   /** Current file. */ 
    78   protected RandomAccessStream in; 
    79  
    80   /** Number of image planes in the file. */ 
    81   protected int numImages = 0; 
    82  
    8377  /** Bits per pixel. */ 
    8478  protected int bitsPerPixel; 
     
    8680  /** Offset to first plane. */ 
    8781  protected int offsets; 
    88  
    89   /** True if the data is little-endian. */ 
    90   protected boolean little; 
    9182 
    9283  private int location; 
     
    112103  } 
    113104 
    114   /* @see loci.formats.IFormatReader#getImageCount() */  
    115   public int getImageCount() throws FormatException, IOException { 
    116     return numImages; 
    117   } 
    118  
    119   /* @see loci.formats.IFormatReader#isRGB() */  
    120   public boolean isRGB() throws FormatException, IOException { 
    121     return false; 
    122   } 
    123  
    124   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    125   public boolean isLittleEndian() throws FormatException, IOException { 
    126     return little; 
    127   } 
    128  
    129   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    130   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    131     return false; 
    132   } 
    133  
    134105  /* @see loci.formats.IFormatReader#openBytes(int) */  
    135106  public byte[] openBytes(int no) throws FormatException, IOException { 
     
    160131  public BufferedImage openImage(int no) throws FormatException, IOException { 
    161132    return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    162       1, false, bitsPerPixel / 8, little); 
     133      1, false, bitsPerPixel / 8, core.littleEndian[0]); 
    163134  } 
    164135 
     
    167138    if (fileOnly && in != null) in.close(); 
    168139    else if (!fileOnly) close(); 
    169   } 
    170  
    171   /* @see loci.formats.IFormatReader#close() */  
    172   public void close() throws FormatException, IOException { 
    173     if (in != null) in.close(); 
    174     in = null; 
    175     currentId = null; 
    176140  } 
    177141 
     
    183147    in.order(true); 
    184148 
    185     little = true; 
     149    core.littleEndian[0] = true; 
    186150    location = 0; 
    187151 
     
    242206          addInfo(tag, s); 
    243207          double frames = Double.parseDouble(s); 
    244           if (frames > 1.0) numImages = (int) frames; 
     208          if (frames > 1.0) core.imageCount[0] = (int) frames; 
    245209          break; 
    246210        case SAMPLES_PER_PIXEL: 
     
    316280      } 
    317281    } 
    318     if (numImages == 0) numImages = 1; 
     282    if (core.imageCount[0] == 0) core.imageCount[0] = 1; 
    319283 
    320284    status("Populating metadata"); 
    321285 
    322     core.sizeZ[0] = numImages; 
     286    core.sizeZ[0] = core.imageCount[0]; 
    323287    core.sizeC[0] = 1; 
    324288    core.sizeT[0] = 1; 
    325289    core.currentOrder[0] = "XYZTC"; 
     290    core.rgb[0] = false; 
     291    core.interleaved[0] = false; 
    326292 
    327293    // The metadata store we're working with. 
     
    351317      new Integer(core.sizeT[0]), // SizeT 
    352318      new Integer(core.pixelType[0]),  // PixelType 
    353       new Boolean(!little),  // BigEndian 
     319      new Boolean(!core.littleEndian[0]),  // BigEndian 
    354320      core.currentOrder[0], // Dimension order 
    355321      null, // Use image index 0 
     
    502468        } 
    503469        vr = IMPLICIT_VR; 
    504         if (little) return (b[3] << 24) + (b[2] << 16) + (b[1] << 8) + b[0]; 
     470        if (core.littleEndian[0]) { 
     471          return (b[3] << 24) + (b[2] << 16) + (b[1] << 8) + b[0]; 
     472        }  
    505473        return (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + b[3]; 
    506474      case AE: 
     
    528496      case QQ: 
    529497        // Explicit VR with 16-bit length 
    530         if (little) return (b[3] << 8) + b[2]; 
     498        if (core.littleEndian[0]) return (b[3] << 8) + b[2]; 
    531499        else return (b[2] << 8) + b[3]; 
    532500      default: 
    533501        vr = IMPLICIT_VR; 
    534         if (little) return (b[3] << 24) + (b[2] << 16) + (b[1] << 8) + b[0]; 
     502        if (core.littleEndian[0]) { 
     503          return (b[3] << 24) + (b[2] << 16) + (b[1] << 8) + b[0]; 
     504        }  
    535505        return (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + b[3]; 
    536506    } 
     
    540510    int groupWord = in.readShort(); 
    541511    if (groupWord == 0x0800 && bigEndianTransferSyntax) { 
    542       little = false; 
     512      core.littleEndian[0] = false; 
    543513      groupWord = 0x0008; 
    544514      in.order(false); 
  • trunk/loci/formats/in/EPSReader.java

    r2583 r2584  
    4040  // -- Fields -- 
    4141 
    42   /** Current file. */ 
    43   protected RandomAccessStream in; 
    44  
    4542  /** Bits per sample. */ 
    4643  private int bps; 
     
    6461  public boolean isThisType(byte[] block) { 
    6562    return false; 
    66   } 
    67  
    68   /* @see loci.formats.IFormatReader#getImageCount() */  
    69   public int getImageCount() throws FormatException, IOException { 
    70     return 1; 
    71   } 
    72  
    73   /* @see loci.formats.IFormatReader#isRGB() */  
    74   public boolean isRGB() throws FormatException, IOException { 
    75     return core.sizeC[0] == 3; 
    76   } 
    77  
    78   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    79   public boolean isLittleEndian() throws FormatException, IOException { 
    80     return true; 
    81   } 
    82  
    83   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    84   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    85     return true; 
    8663  } 
    8764 
     
    146123    if (fileOnly && in != null) in.close(); 
    147124    else if (!fileOnly) close(); 
    148   } 
    149  
    150   /* @see loci.formats.IFormatReader#close() */  
    151   public void close() throws FormatException, IOException { 
    152     if (in != null) in.close(); 
    153     in = null; 
    154     currentId = null; 
    155125  } 
    156126 
     
    249219    core.currentOrder[0] = "XYCZT"; 
    250220    core.pixelType[0] = FormatTools.UINT8; 
     221    core.rgb[0] = core.sizeC[0] == 3; 
     222    core.interleaved[0] = true; 
     223    core.littleEndian[0] = true; 
     224    core.imageCount[0] = 1; 
    251225 
    252226    // Populate metadata store 
  • trunk/loci/formats/in/FluoviewReader.java

    r2583 r2584  
    261261    if (core.currentOrder[0].indexOf("C") == -1) core.currentOrder[0] += "C"; 
    262262 
    263     numImages = ifds.length; 
     263    core.imageCount[0] = ifds.length; 
    264264 
    265265    // cut up the comment, if necessary 
  • trunk/loci/formats/in/GIFReader.java

    r2583 r2584  
    5050  // -- Fields -- 
    5151 
    52   /** Current file. */ 
    53   protected RandomAccessStream in; 
    54  
    55   /** Number of frames. */ 
    56   private int numFrames; 
    57  
    5852  private int status; 
    5953 
     
    140134  /* @see loci.formats.IFormatReader#isThisType(byte[]) */  
    141135  public boolean isThisType(byte[] block) { return false; } 
    142  
    143   /* @see loci.formats.IFormatReader#getImageCount() */  
    144   public int getImageCount() throws FormatException, IOException { 
    145     return numFrames; 
    146   } 
    147  
    148   /* @see loci.formats.IFormatReader#isRGB() */  
    149   public boolean isRGB() throws FormatException, IOException { 
    150     return true; 
    151   } 
    152  
    153   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    154   public boolean isLittleEndian() throws FormatException, IOException { 
    155     return true; 
    156   } 
    157  
    158   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    159   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    160     return true; 
    161   } 
    162136 
    163137  /* @see loci.formats.IFormatReader#openBytes(int) */  
     
    203177  } 
    204178 
    205   /* @see loci.formats.IFormatReader#close() */  
    206   public void close() throws FormatException, IOException { 
    207     if (in != null) in.close(); 
    208     in = null; 
    209     currentId = null; 
    210     numFrames = 0; 
    211   } 
    212  
    213179  /** Initializes the given GIF file. */ 
    214180  protected void initFile(String id) throws FormatException, IOException { 
     
    218184    status("Verifying GIF format"); 
    219185 
    220     numFrames = 0; 
    221186    status = STATUS_OK; 
    222187    in = new RandomAccessStream(id); 
     
    321286          while (blockSize > 0 && check != -1); 
    322287 
    323           numFrames++; 
     288          core.imageCount[0]++; 
    324289 
    325290          if (transparency) act[transIndex] = save; 
     
    385350    core.sizeZ[0] = 1; 
    386351    core.sizeC[0] = 3; 
    387     core.sizeT[0] = numFrames; 
     352    core.sizeT[0] = core.imageCount[0]; 
    388353    core.currentOrder[0] = "XYCTZ"; 
     354    core.rgb[0] = true; 
     355    core.littleEndian[0] = true; 
     356    core.interleaved[0] = true; 
    389357 
    390358    // populate metadata store 
     
    546514    if (lastDispose > 0) { 
    547515      if (lastDispose == 3) { // use image before last 
    548         int n = numFrames - 2; 
     516        int n = core.imageCount[0] - 2; 
    549517        if (n > 0) lastImage = n - 1; 
    550518      } 
  • trunk/loci/formats/in/GatanReader.java

    r2583 r2584  
    4343  // -- Fields -- 
    4444 
    45   /** Current file. */ 
    46   protected RandomAccessStream in; 
    47  
    48   /** Flag indicating whether current file is little endian. */ 
    49   protected boolean littleEndian; 
    50  
    5145  /** Offset to pixel data. */ 
    5246  private long pixelOffset; 
     
    7670  } 
    7771 
    78   /* @see loci.formats.IFormatReader#getImageCount() */  
    79   public int getImageCount() throws FormatException, IOException { 
    80     return 1; 
    81   } 
    82  
    83   /* @see loci.formats.IFormatReader#isRGB() */  
    84   public boolean isRGB() throws FormatException, IOException { 
    85     return false; 
    86   } 
    87  
    88   /* @see loci.formats.IFormatReader#isLittleEndian() */   
    89   public boolean isLittleEndian() throws FormatException, IOException { 
    90     return littleEndian; 
    91   } 
    92  
    93   /* @see loci.formats.IFormatReader#isInterleaved(int) */ 
    94   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    95     return false; 
    96   } 
    97  
    9872  /* @see loci.formats.IFormatReader#openBytes(int) */  
    9973  public byte[] openBytes(int no) throws FormatException, IOException { 
     
    12498    } 
    12599 
    126     return ImageTools.makeImage(openBytes( no), core.sizeX[0], core.sizeY[0], 
    127       1, false, bytesPerPixel, littleEndian); 
     100    return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
     101      1, false, bytesPerPixel, core.littleEndian[0]); 
    128102  } 
    129103 
     
    132106    if (fileOnly && in != null) in.close(); 
    133107    else if (!fileOnly) close(); 
    134   } 
    135  
    136   /* @see loci.formats.IFormatReader#close() */  
    137   public void close() throws FormatException, IOException { 
    138     if (in != null) in.close(); 
    139     in = null; 
    140     currentId = null; 
    141     pixelOffset = 0; 
    142108  } 
    143109 
     
    147113    super.initFile(id); 
    148114    in = new RandomAccessStream(id); 
     115    pixelOffset = 0; 
    149116 
    150117    status("Verifying Gatan format"); 
    151118 
    152     littleEndian = false; 
     119    core.littleEndian[0] = false; 
    153120    pixelSizes = new Vector(); 
    154121 
    155     byte[] temp = new byte[4]; 
    156     in.read(temp); 
     122    byte[] tmp = new byte[4]; 
     123    in.read(tmp); 
    157124    // only support version 3 
    158     if (!isThisType(temp)) { 
     125    if (!isThisType(tmp)) { 
    159126      throw new FormatException("invalid header"); 
    160127    } 
     
    163130 
    164131    in.skipBytes(4); 
    165     in.read(temp); 
    166     littleEndian = DataTools.bytesToInt(temp, littleEndian) == 1; 
     132    in.read(tmp); 
     133    core.littleEndian[0] = DataTools.bytesToInt(tmp, core.littleEndian[0]) == 1; 
    167134 
    168135    // TagGroup instance 
    169136 
    170137    in.skipBytes(2); 
    171     in.read(temp); 
    172     parseTags(DataTools.bytesToInt(temp, !littleEndian), "initFile"); 
     138    in.read(tmp); 
     139    parseTags(DataTools.bytesToInt(tmp, !core.littleEndian[0]), "initFile"); 
    173140 
    174141    int datatype = Integer.parseInt((String) getMeta("DataType")); 
     
    227194    core.sizeT[0] = 1; 
    228195    core.currentOrder[0] = "XYZTC"; 
     196    core.imageCount[0] = 1; 
     197    core.rgb[0] = false; 
     198    core.interleaved[0] = false; 
    229199 
    230200    // The metadata store we're working with. 
     
    238208      new Integer(core.sizeT[0]), // SizeT 
    239209      new Integer(core.pixelType[0]), // PixelType 
    240       new Boolean(!littleEndian), // BigEndian 
     210      new Boolean(!core.littleEndian[0]), // BigEndian 
    241211      core.currentOrder[0], // DimensionOrder 
    242212      null, // Use image index 0 
     
    286256      byte[] twobytes = new byte[2]; 
    287257      in.read(twobytes); 
    288       int length = DataTools.bytesToInt(twobytes, !littleEndian); 
     258      int length = DataTools.bytesToInt(twobytes, !core.littleEndian[0]); 
    289259      byte[] label = new byte[length]; 
    290260      in.read(label); 
     
    298268        in.skipBytes(4);  // equal to '%%%%' 
    299269        in.read(temp); 
    300         int n = DataTools.bytesToInt(temp, !littleEndian); 
     270        int n = DataTools.bytesToInt(temp, !core.littleEndian[0]); 
    301271        int dataType = 0; 
    302272        if (n == 1) { 
    303273          in.read(temp); 
    304           dataType = DataTools.bytesToInt(temp, !littleEndian); 
     274          dataType = DataTools.bytesToInt(temp, !core.littleEndian[0]); 
    305275          String data; 
    306276          switch (dataType) { 
    307277            case 2: 
    308               data = "" + DataTools.read2SignedBytes(in, littleEndian); 
     278              data = "" + DataTools.read2SignedBytes(in, core.littleEndian[0]); 
    309279              break; 
    310280            case 3: 
    311               data = "" + DataTools.read4SignedBytes(in, littleEndian); 
     281              data = "" + DataTools.read4SignedBytes(in, core.littleEndian[0]); 
    312282              break; 
    313283            case 4: 
    314               data = "" + DataTools.read2UnsignedBytes(in, littleEndian); 
     284              data =  
     285                "" + DataTools.read2UnsignedBytes(in, core.littleEndian[0]); 
    315286              break; 
    316287            case 5: 
    317               data = "" + DataTools.read4UnsignedBytes(in, littleEndian); 
     288              data =  
     289                "" + DataTools.read4UnsignedBytes(in, core.littleEndian[0]); 
    318290              break; 
    319291            case 6: 
    320               data = "" + DataTools.readFloat(in, littleEndian); 
     292              data = "" + DataTools.readFloat(in, core.littleEndian[0]); 
    321293              break; 
    322294            case 7: 
    323               data = "" + DataTools.readFloat(in, littleEndian); 
     295              data = "" + DataTools.readFloat(in, core.littleEndian[0]); 
    324296              in.skipBytes(4); 
    325297              break; 
     
    350322        else if (n == 2) { 
    351323          in.read(temp); 
    352           dataType = DataTools.bytesToInt(temp, littleEndian); 
     324          dataType = DataTools.bytesToInt(temp, core.littleEndian[0]); 
    353325          if (dataType == 18) { // this should always be true 
    354326            in.read(temp); 
    355             length = DataTools.bytesToInt(temp, littleEndian); 
     327            length = DataTools.bytesToInt(temp, core.littleEndian[0]); 
    356328          } 
    357329          byte[] data = new byte[length]; 
     
    361333        else if (n == 3) { 
    362334          in.read(temp); 
    363           dataType = DataTools.bytesToInt(temp, !littleEndian); 
     335          dataType = DataTools.bytesToInt(temp, !core.littleEndian[0]); 
    364336          if (dataType == 20) { // this should always be true 
    365337            in.read(temp); 
    366             dataType = DataTools.bytesToInt(temp, !littleEndian); 
    367             in.read(temp); 
    368             length = DataTools.bytesToInt(temp, !littleEndian); 
     338            dataType = DataTools.bytesToInt(temp, !core.littleEndian[0]); 
     339            in.read(temp); 
     340            length = DataTools.bytesToInt(temp, !core.littleEndian[0]); 
    369341 
    370342            if ("Data".equals(labelString)) pixelDataNum++; 
     
    395367                  byte[] two = new byte[2]; 
    396368                  in.read(two); 
    397                   data[j] = (int) DataTools.bytesToShort(two, !littleEndian); 
     369                  data[j] = (int) DataTools.bytesToShort(two,  
     370                    !core.littleEndian[0]); 
    398371                } 
    399372                else if (dataType == 7) in.skipBytes(8); 
     
    401374                else { 
    402375                  in.read(temp); 
    403                   data[j] = DataTools.bytesToInt(temp, !littleEndian); 
     376                  data[j] = DataTools.bytesToInt(temp, !core.littleEndian[0]); 
    404377                } 
    405378              } 
     
    409382        else { 
    410383          in.read(temp); 
    411           dataType = DataTools.bytesToInt(temp, !littleEndian); 
     384          dataType = DataTools.bytesToInt(temp, !core.littleEndian[0]); 
    412385          // this is a normal struct of simple types 
    413386          if (dataType == 15) { 
    414387            int skip = 0; 
    415388            in.read(temp); 
    416             skip += DataTools.bytesToInt(temp, !littleEndian); 
    417             in.read(temp); 
    418             int numFields = DataTools.bytesToInt(temp, !littleEndian); 
     389            skip += DataTools.bytesToInt(temp, !core.littleEndian[0]); 
     390            in.read(temp); 
     391            int numFields = DataTools.bytesToInt(temp, !core.littleEndian[0]); 
    419392            for (int j=0; j<numFields; j++) { 
    420393              in.read(temp); 
    421               skip += DataTools.bytesToInt(temp, !littleEndian); 
     394              skip += DataTools.bytesToInt(temp, !core.littleEndian[0]); 
    422395              in.read(temp); 
    423               dataType = DataTools.bytesToInt(temp, !littleEndian); 
     396              dataType = DataTools.bytesToInt(temp, !core.littleEndian[0]); 
    424397 
    425398              switch (dataType) { 
     
    456429            int skip = 0; 
    457430            in.read(temp); 
    458             dataType = DataTools.bytesToInt(temp, !littleEndian); 
     431            dataType = DataTools.bytesToInt(temp, !core.littleEndian[0]); 
    459432            if (dataType == 15) { // should always be true 
    460433              in.read(temp); 
    461               skip += DataTools.bytesToInt(temp, !littleEndian); 
     434              skip += DataTools.bytesToInt(temp, !core.littleEndian[0]); 
    462435              in.read(temp); 
    463               int numFields = DataTools.bytesToInt(temp, !littleEndian); 
     436              int numFields = DataTools.bytesToInt(temp, !core.littleEndian[0]); 
    464437              for (int j=0; j<numFields; j++) { 
    465438                in.read(temp); 
    466                 skip += DataTools.bytesToInt(temp, !littleEndian); 
     439                skip += DataTools.bytesToInt(temp, !core.littleEndian[0]); 
    467440                in.read(temp); 
    468                 dataType = DataTools.bytesToInt(temp, !littleEndian); 
     441                dataType = DataTools.bytesToInt(temp, !core.littleEndian[0]); 
    469442 
    470443                switch (dataType) { 
     
    497470            } 
    498471            in.read(temp); 
    499             skip *= DataTools.bytesToInt(temp, !littleEndian); 
     472            skip *= DataTools.bytesToInt(temp, !core.littleEndian[0]); 
    500473            in.skipBytes(skip); 
    501474          } 
     
    505478        in.skipBytes(2); 
    506479        in.read(temp); 
    507         parseTags(DataTools.bytesToInt(temp, !littleEndian), labelString); 
     480        parseTags(DataTools.bytesToInt(temp, !core.littleEndian[0]),  
     481          labelString); 
    508482      } 
    509483    } 
  • trunk/loci/formats/in/GelReader.java

    r2583 r2584  
    6565    super.initStandardMetadata(); 
    6666 
    67     numImages--; 
     67    core.imageCount[0]--; 
    6868 
    6969    try { 
     
    9696    addMeta("File units", units == null ? "unknown" : units); 
    9797 
    98     core.sizeT[series] = numImages; 
     98    core.sizeT[series] = core.imageCount[series]; 
    9999 
    100100    MetadataStore store = getMetadataStore(); 
  • trunk/loci/formats/in/ICSReader.java

    r2583 r2584  
    6969  protected String currentIdsId; 
    7070 
    71   /** Current file. */ 
    72   protected RandomAccessStream idsIn; // IDS file 
    73   protected Location icsIn; // ICS file 
    74  
    75   /** Flag indicating whether current file is little endian. */ 
    76   protected boolean littleEndian; 
    77  
    78   /** Number of images. */ 
    79   protected int numImages; 
     71  /** Current ICS file. */ 
     72  protected Location icsIn; 
    8073 
    8174  /** Number of bits per pixel. */ 
     
    8780  /** Image data. */ 
    8881  protected byte[] data; 
    89  
    90   /** Flag indicating that the images are RGB. */ 
    91   private boolean rgb; 
    9282 
    9383  // -- Constructor -- 
     
    10393  public boolean isThisType(byte[] block) { 
    10494    return false; 
    105   } 
    106  
    107   /* @see loci.formats.IFormatReader#getImageCount() */  
    108   public int getImageCount() throws FormatException, IOException { 
    109     if (numImages == 1) return 1; 
    110     return numImages / (rgb ? core.sizeC[0] : 1); 
    111   } 
    112  
    113   /* @see loci.formats.IFormatReader#isRGB() */  
    114   public boolean isRGB() throws FormatException, IOException { 
    115     return rgb && core.sizeC[0] > 1; 
    116   } 
    117  
    118   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    119   public boolean isLittleEndian() throws FormatException, IOException { 
    120     return littleEndian; 
    121   } 
    122  
    123   /* @see loci.formats.IFormatReader#isInterleaved(int) */ 
    124   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    125     return !rgb; 
    12695  } 
    12796 
     
    150119    int len = core.sizeX[0] * core.sizeY[0] * bpp * getRGBChannelCount(); 
    151120    int offset = len * no; 
    152     if (!rgb && core.sizeC[0] > 4) { 
     121    if (!core.rgb[0] && core.sizeC[0] > 4) { 
    153122      int pt = 0; 
    154123      for (int i=no*bpp; i<data.length; i+=core.sizeC[0]*bpp) { 
     
    176145  public BufferedImage openImage(int no) throws FormatException, IOException { 
    177146    byte[] plane = openBytes(no); 
    178     int channels = rgb ? core.sizeC[0] : 1; 
     147    int channels = core.rgb[0] ? core.sizeC[0] : 1; 
    179148 
    180149    int bytes = bitsPerPixel / 8; 
     
    184153      int pt = 0; 
    185154      for (int i=0; i<f.length; i++) { 
    186         int p = DataTools.bytesToInt(plane, i*4, 4, littleEndian); 
     155        int p = DataTools.bytesToInt(plane, i*4, 4, core.littleEndian[0]); 
    187156        f[i] = Float.intBitsToFloat(p); 
    188157      } 
     
    195164 
    196165    return ImageTools.makeImage(plane, core.sizeX[0], core.sizeY[0], channels,  
    197       true, bytes, littleEndian); 
     166      true, bytes, core.littleEndian[0]); 
    198167  } 
    199168 
     
    208177  /* @see loci.formats.IFormatReader#close(boolean) */ 
    209178  public void close(boolean fileOnly) throws FormatException, IOException { 
    210     if (fileOnly && idsIn != null) idsIn.close(); 
     179    if (fileOnly && in != null) in.close(); 
    211180    else if (!fileOnly) close(); 
    212181  } 
     
    214183  /* @see loci.formats.IFormatReader#close() */  
    215184  public void close() throws FormatException, IOException { 
    216     if (idsIn != null) idsIn.close(); 
    217     idsIn = null; 
     185    super.close();  
    218186    icsIn = null; 
    219187    currentIcsId = null; 
     
    257225    f.close(); 
    258226    if (new String(b).trim().equals("ics_version\t2.0")) { 
    259       idsIn = new RandomAccessStream(icsId); 
     227      in = new RandomAccessStream(icsId); 
    260228      versionTwo = true; 
    261229    } 
     
    265233      if (!idsFile.exists()) throw new FormatException("IDS file not found."); 
    266234      currentIdsId = idsId; 
    267       idsIn = new RandomAccessStream(idsId); 
     235      in = new RandomAccessStream(idsId); 
    268236    } 
    269237 
     
    327295    StringTokenizer t2 = new StringTokenizer(ord); 
    328296 
    329     rgb = ord.indexOf("ch") >= 0 && ord.indexOf("ch") < ord.indexOf("x"); 
     297    core.rgb[0] =  
     298      ord.indexOf("ch") >= 0 && ord.indexOf("ch") < ord.indexOf("x"); 
    330299 
    331300    String imageToken; 
     
    348317      else if(orderToken.equals("ch")) { 
    349318        core.sizeC[0] = Integer.parseInt(imageToken); 
    350         if (core.sizeC[0] > 4) rgb = false; 
     319        if (core.sizeC[0] > 4) core.rgb[0] = false; 
    351320      } 
    352321      else { 
     
    355324    } 
    356325 
    357     numImages = core.sizeZ[0] * core.sizeC[0] * core.sizeT[0]; 
    358     if (numImages == 0) numImages++; 
     326    core.imageCount[0] = core.sizeZ[0] * core.sizeC[0] * core.sizeT[0]; 
     327    if (core.imageCount[0] == 0) core.imageCount[0] = 1; 
     328    core.rgb[0] = core.rgb[0] && core.sizeC[0] > 1; 
     329    core.interleaved[0] = !core.rgb[0]; 
    359330 
    360331    String endian = (String) getMeta("representation byte_order"); 
    361     littleEndian = true; 
     332    core.littleEndian[0] = true; 
    362333 
    363334    if (endian != null) { 
     
    365336      String firstByte = endianness.nextToken(); 
    366337      int first = Integer.parseInt(firstByte); 
    367       littleEndian = 
     338      core.littleEndian[0] = 
    368339        ((String) getMeta("representation format")).equals("real") ? 
    369340        first == 1 : first != 1; 
     
    374345 
    375346    if (versionTwo) { 
    376       s = idsIn.readLine(); 
    377       while(!s.trim().equals("end")) s = idsIn.readLine(); 
    378     } 
    379     data = new byte[(int) (idsIn.length() - idsIn.getFilePointer())]; 
     347      s = in.readLine(); 
     348      while(!s.trim().equals("end")) s = in.readLine(); 
     349    } 
     350    data = new byte[(int) (in.length() - in.getFilePointer())]; 
    380351 
    381352    // extra check is because some of our datasets are labeled as 'gzip', and 
    382353    // have a valid GZIP header, but are actually uncompressed 
    383     if (gzip && ((data.length / (numImages) <  
     354    if (gzip && ((data.length / (core.imageCount[0]) <  
    384355      (core.sizeX[0] * core.sizeY[0] * bitsPerPixel / 8)))) 
    385356    { 
    386357      status("Decompressing pixel data");  
    387       idsIn.read(data); 
     358      in.read(data); 
    388359      byte[] buf = new byte[8192]; 
    389360      ByteVector v = new ByteVector(); 
     
    402373      } 
    403374    } 
    404     else idsIn.readFully(data); 
     375    else in.readFully(data); 
    405376 
    406377    status("Populating metadata"); 
     
    432403    String sign = (String) getMeta("representation sign"); 
    433404 
    434     if (bitsPerPixel < 32) littleEndian = !littleEndian; 
     405    if (bitsPerPixel < 32) core.littleEndian[0] = !core.littleEndian[0]; 
    435406 
    436407    if (fmt.equals("real")) core.pixelType[0] = FormatTools.FLOAT; 
     
    464435      new Integer(core.sizeT[0]), // SizeT 
    465436      new Integer(core.pixelType[0]), // PixelType 
    466       new Boolean(!littleEndian), // BigEndian 
     437      new Boolean(!core.littleEndian[0]), // BigEndian 
    467438      core.currentOrder[0], // DimensionOrder 
    468439      null, // Use image index 0 
  • trunk/loci/formats/in/IPLabReader.java

    r2583 r2584  
    3838 
    3939  // -- Fields -- 
    40  
    41   /** Current file. */ 
    42   protected RandomAccessStream in; 
    43  
    44   /** Flag indicating whether current file is little endian. */ 
    45   protected boolean littleEndian; 
    46  
    47   /** Number of images in the file. */ 
    48   private int numImages; 
    4940 
    5041  /** Bytes per pixel. */ 
     
    7566  } 
    7667 
    77   /* @see loci.formats.IFormatReader#getImageCount() */  
    78   public int getImageCount() throws FormatException, IOException { 
    79     return numImages; 
    80   } 
    81  
    82   /* @see loci.formats.IFormatReader#isRGB() */  
    83   public boolean isRGB() throws FormatException, IOException { 
    84     return core.sizeC[0] > 1; 
    85   } 
    86  
    87   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    88   public boolean isLittleEndian() throws FormatException, IOException { 
    89     return littleEndian; 
    90   } 
    91  
    92   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    93   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    94     return true; 
    95   } 
    96  
    9768  /* @see loci.formats.IFormatReader#openBytes(int) */  
    9869  public byte[] openBytes(int no) throws FormatException, IOException { 
     
    12293  public BufferedImage openImage(int no) throws FormatException, IOException { 
    12394    return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    124       isRGB() ? core.sizeC[0] : 1, false, bps, littleEndian); 
     95      core.rgb[0] ? core.sizeC[0] : 1, false, bps, core.littleEndian[0]); 
    12596  } 
    12697 
     
    129100    if (fileOnly && in != null) in.close(); 
    130101    else if (!fileOnly) close(); 
    131   } 
    132  
    133   /* @see loci.formats.IFormatReader#close() */  
    134   public void close() throws FormatException, IOException { 
    135     if (in != null) in.close(); 
    136     in = null; 
    137     currentId = null; 
    138102  } 
    139103 
     
    148112    byte[] fourBytes = new byte[4]; 
    149113    in.read(fourBytes); 
    150     littleEndian = new String(fourBytes).equals("iiii"); 
    151  
    152     in.order(littleEndian); 
     114    core.littleEndian[0] = new String(fourBytes).equals("iiii"); 
     115 
     116    in.order(core.littleEndian[0]); 
    153117 
    154118    // populate standard metadata hashtable and OME root node 
     
    163127    int filePixelType = in.readInt(); 
    164128 
    165     numImages = core.sizeZ[0] * core.sizeT[0]; 
     129    core.imageCount[0] = core.sizeZ[0] * core.sizeT[0]; 
    166130 
    167131    addMeta("Width", new Long(core.sizeX[0])); 
     
    225189    else core.currentOrder[0] += "ZTC"; 
    226190 
     191    core.rgb[0] = core.sizeC[0] > 1; 
     192    core.interleaved[0] = true; 
     193 
    227194    // The metadata store we're working with. 
    228195    MetadataStore store = getMetadataStore(); 
     
    235202      new Integer(core.sizeT[0]), // SizeT 
    236203      new Integer(core.pixelType[0]), // PixelType 
    237       new Boolean(!littleEndian), // BigEndian 
     204      new Boolean(!core.littleEndian[0]), // BigEndian 
    238205      core.currentOrder[0], // DimensionOrder 
    239206      null, // Use image index 0 
  • trunk/loci/formats/in/IPWReader.java

    r2583 r2584  
    7070  private byte[] header;  // general image header data 
    7171  private byte[] tags; // tags data 
    72   private boolean rgb; 
    73   private boolean little; 
    7472 
    7573  // -- Constructor -- 
     
    8583    return (block[0] == 0xd0 && block[1] == 0xcf && 
    8684      block[2] == 0x11 && block[3] == 0xe0); 
    87   } 
    88  
    89   /* @see loci.formats.IFormatReader#getImageCount() */  
    90   public int getImageCount() throws FormatException, IOException { 
    91     return numImages; 
    92   } 
    93  
    94   /* @see loci.formats.IFormatReader#isRGB() */  
    95   public boolean isRGB() throws FormatException, IOException { 
    96     return rgb; 
    97   } 
    98  
    99   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    100   public boolean isLittleEndian() throws FormatException, IOException { 
    101     return little; 
    10285  } 
    10386 
     
    145128      RandomAccessStream stream = new RandomAccessStream(b); 
    146129      ifds = TiffTools.getIFDs(stream); 
    147       little = TiffTools.isLittleEndian(ifds[0]); 
     130      core.littleEndian[0] = TiffTools.isLittleEndian(ifds[0]); 
    148131      TiffTools.getSamples(ifds[0], stream, buf); 
    149132      stream.close(); 
     
    165148    int bytes = b.length / (core.sizeX[0] * core.sizeY[0]); 
    166149    return ImageTools.makeImage(b, core.sizeX[0], core.sizeY[0], 
    167       bytes == 3 ? 3 : 1, false, bytes == 3 ? 1 : bytes, little); 
     150      bytes == 3 ? 3 : 1, false, bytes == 3 ? 1 : bytes, core.littleEndian[0]); 
    168151  } 
    169152 
     
    176159  /* @see loci.formats.IFormatReader#close() */  
    177160  public void close() throws FormatException, IOException { 
    178     if (in != null) in.close(); 
    179     in = null; 
    180     currentId = null; 
     161    super.close(); 
    181162 
    182163    pixels = null; 
     
    201182    pixels = new Hashtable(); 
    202183    names = new Hashtable(); 
    203     numImages = 0; 
    204184 
    205185    try { 
     
    250230    catch (ReflectException e) { } 
    251231 
    252     rgb = (TiffTools.getIFDIntValue(ifds[0], 
     232    core.rgb[0] = (TiffTools.getIFDIntValue(ifds[0], 
    253233      TiffTools.SAMPLES_PER_PIXEL, false, 1) > 1); 
    254234 
    255     if (!rgb) { 
    256       rgb = TiffTools.getIFDIntValue(ifds[0], 
     235    if (!core.rgb[0]) { 
     236      core.rgb[0] = TiffTools.getIFDIntValue(ifds[0], 
    257237        TiffTools.PHOTOMETRIC_INTERPRETATION, false, 1) == 
    258238        TiffTools.RGB_PALETTE; 
    259239    } 
    260240 
    261     little = TiffTools.isLittleEndian(ifds[0]); 
     241    core.littleEndian[0] = TiffTools.isLittleEndian(ifds[0]); 
    262242 
    263243    // parse the image description 
     
    299279    core.currentOrder[0] = "XY"; 
    300280 
    301     if (rgb) core.sizeC[0] *= 3; 
     281    if (core.rgb[0]) core.sizeC[0] *= 3; 
    302282 
    303283    int maxNdx = 0, max = 0; 
     
    450430          pixels.put(imageNum, dirName); 
    451431          names.put(imageNum, entryName); 
    452           numImages++; 
     432          core.imageCount[0]++; 
    453433        } 
    454434        r.exec("dis.close()"); 
  • trunk/loci/formats/in/ImageIOReader.java

    r2583 r2584  
    4040public abstract class ImageIOReader extends FormatReader { 
    4141 
    42   // -- Fields -- 
    43  
    44   /** Flag indicating image is RGB. */ 
    45   private boolean rgb; 
    46  
    4742  // -- Constructors -- 
    4843 
     
    5954  /* @see loci.formats.IFormatReader#isThisType(byte[]) */  
    6055  public boolean isThisType(byte[] block) { return false; } 
    61  
    62   /* @see loci.formats.IFormatReader#getImageCount() */  
    63   public int getImageCount() throws FormatException, IOException { 
    64     return 1; 
    65   } 
    66  
    67   /* @see loci.formats.IFormatReader#isRGB() */  
    68   public boolean isRGB() throws FormatException, IOException { 
    69     return rgb; 
    70   } 
    71  
    72   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    73   public boolean isLittleEndian() throws FormatException, IOException { 
    74     return false; 
    75   } 
    76  
    77   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    78   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    79     return true; 
    80   } 
    8156 
    8257  /* @see loci.formats.IFormatReader#openBytes(int) */  
     
    129104    core.sizeY[0] = img.getHeight(); 
    130105 
    131     rgb = img.getRaster().getNumBands() > 1; 
     106    core.rgb[0] = img.getRaster().getNumBands() > 1; 
    132107 
    133108    core.sizeZ[0] = 1; 
    134     core.sizeC[0] = rgb ? 3 : 1; 
     109    core.sizeC[0] = core.rgb[0] ? 3 : 1; 
    135110    core.sizeT[0] = 1; 
    136111    core.currentOrder[0] = "XYCZT"; 
    137112    core.pixelType[0] = ImageTools.getPixelType(img); 
     113    core.imageCount[0] = 1; 
     114    core.interleaved[0] = true; 
     115    core.littleEndian[0] = false; 
    138116 
    139117    // populate the metadata store 
     
    148126      new Integer(core.sizeT[0]), 
    149127      new Integer(core.pixelType[0]), 
    150       new Boolean(false), 
     128      new Boolean(!core.littleEndian[0]),  
    151129      core.currentOrder[0],  
    152130      null, 
  • trunk/loci/formats/in/ImarisReader.java

    r2583 r2584  
    4747 
    4848  // -- Fields -- 
    49  
    50   /** Current file. */ 
    51   protected RandomAccessStream in; 
    52  
    53   /** Number of image planes in the file. */ 
    54   protected int numImages = 0; 
    5549 
    5650  /** Offsets to each image. */ 
     
    118112    status("Calculating image offsets"); 
    119113 
    120     numImages = core.sizeZ[0] * core.sizeC[0];  
    121     offsets = new int[numImages]; 
     114    core.imageCount[0] = core.sizeZ[0] * core.sizeC[0];  
     115    offsets = new int[core.imageCount[0]]; 
    122116 
    123117    for (int i=0; i<core.sizeC[0]; i++) { 
     
    132126    status("Populating metadata"); 
    133127 
    134     core.sizeT[0] = numImages / (core.sizeC[0] * core.sizeZ[0]); 
     128    core.sizeT[0] = core.imageCount[0] / (core.sizeC[0] * core.sizeZ[0]); 
    135129    core.currentOrder[0] = "XYZCT"; 
     130    core.rgb[0] = false; 
     131    core.interleaved[0] = false; 
     132    core.littleEndian[0] = IS_LITTLE; 
    136133 
    137134    // The metadata store we're working with. 
     
    179176  } 
    180177 
    181   /* @see loci.formats.IFormatReader#getImageCount() */  
    182   public int getImageCount() throws FormatException, IOException { 
    183     return numImages; 
    184   } 
    185  
    186   /* @see loci.formats.IFormatReader#isRGB() */  
    187   public boolean isRGB() throws FormatException, IOException { 
    188     return false; 
    189   } 
    190  
    191   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    192   public boolean isLittleEndian() throws FormatException, IOException { 
    193     return IS_LITTLE; 
    194   } 
    195  
    196   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    197   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    198     return false; 
    199   } 
    200  
    201178  /* @see loci.formats.IFormatReader#openBytes(int) */  
    202179  public byte[] openBytes(int no) throws FormatException, IOException { 
     
    235212    if (fileOnly && in != null) in.close(); 
    236213    else if (!fileOnly) close(); 
    237   } 
    238  
    239   /* @see loci.formats.IFormatReader#close() */  
    240   public void close() throws FormatException, IOException { 
    241     if (in != null) in.close(); 
    242     in = null; 
    243     currentId = null; 
    244214  } 
    245215 
  • trunk/loci/formats/in/ImarisTiffReader.java

    r2583 r2584  
    9090  // -- Internal BaseTiffReader API methods -- 
    9191 
    92   /* @see BaseTiffReader#getImageCount() */ 
    93   public int getImageCount() throws FormatException, IOException { 
    94     return numImages; 
    95   } 
    96  
    97   /* @see BaseTiffReader#isInterleaved() */ 
    98   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    99     return false; 
    100   } 
    101  
    10292  /* @see BaseTiffReader#initFile(String) */ 
    10393  protected void initFile(String id) throws FormatException, IOException { 
     
    145135 
    146136    ifds = (Hashtable[]) tmp.toArray(new Hashtable[0]); 
    147     numImages = core.sizeC[0] * core.sizeZ[0]; 
     137    core.imageCount[0] = core.sizeC[0] * core.sizeZ[0]; 
    148138    core.currentOrder[0] = "XYZCT"; 
     139    core.interleaved[0] = false; 
    149140 
    150141    int bitsPerSample = TiffTools.getIFDIntValue(ifds[0], 
  • trunk/loci/formats/in/LIFReader.java

    r2583 r2584  
    3939  // -- Fields -- 
    4040 
    41   /** Current file. */ 
    42   protected RandomAccessStream in; 
    43  
    44   /** Flag indicating whether current file is little endian. */ 
    45   protected boolean littleEndian; 
    46  
    47   /** Number of image planes in the file. */ 
    48   protected int numImages = 0; 
    49  
    5041  /** Offsets to memory blocks, paired with their corresponding description. */ 
    5142  protected Vector offsets; 
    5243 
    53   /** 
    54    * Dimension information for each image. 
    55    * The first index specifies the image number, and the second specifies 
    56    * the dimension from the following list: 
    57    * 0) width 
    58    * 1) height 
    59    * 2) Z 
    60    * 3) T 
    61    * 4) channels (1 or 3) 
    62    * 5) bits per pixel 
    63    * 6) extra dimensions 
    64    */ 
    65   protected int[][] dims; 
    66  
     44  /** Bits per pixel. */ 
     45  private int[] bitsPerPixel; 
     46 
     47  /** Extra dimensions. */ 
     48  private int[] extraDimensions; 
     49   
    6750  /** Number of valid bits per pixel */ 
    6851  private int[][] validBits; 
    6952 
    70   private int width; 
    71   private int height; 
    72   private int c; 
    7353  private int bpp; 
    7454  private Vector xcal; 
     
    9272  } 
    9373 
    94   /* @see loci.formats.IFormatReader#getImageCount() */  
    95   public int getImageCount() throws FormatException, IOException { 
    96     numImages = dims[series][2] * dims[series][3]; 
    97     return numImages * (isRGB() ? 1 : dims[series][4]); 
    98   } 
    99  
    100   /* @see loci.formats.IFormatReader#isRGB() */  
    101   public boolean isRGB() throws FormatException, IOException { 
    102     return dims[series][4] > 1 && dims[series][4] < 4; 
    103   } 
    104  
    105   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    106   public boolean isLittleEndian() throws FormatException, IOException { 
    107     return littleEndian; 
    108   } 
    109  
    110   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    111   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    112     return true; 
    113   } 
    114  
    11574  /* @see loci.formats.IFormatReader#getSeriesCount() */  
    11675  public int getSeriesCount() throws FormatException, IOException { 
    117     return dims.length; 
     76    return core.sizeX.length; 
    11877  } 
    11978 
    12079  /* @see loci.formats.IFormatReader#openBytes(int) */  
    12180  public byte[] openBytes(int no) throws FormatException, IOException { 
    122     bpp = dims[series][5]; 
     81    bpp = bitsPerPixel[series]; 
    12382    while (bpp % 8 != 0) bpp++; 
    12483    byte[] buf = new byte[core.sizeX[series] * core.sizeY[series] * 
     
    13493      throw new FormatException("Invalid image number: " + no); 
    13594    } 
    136     bpp = dims[series][5]; 
     95    bpp = bitsPerPixel[series];  
    13796    while (bpp % 8 != 0) bpp++; 
    13897    int bytes = bpp / 8; 
     
    155114    return ImageTools.makeImage(openBytes(no), core.sizeX[series], 
    156115      core.sizeY[series], isRGB() ? core.sizeC[series] : 1, false, bpp / 8, 
    157       littleEndian, validBits[series]); 
     116      core.littleEndian[series], validBits[series]); 
    158117  } 
    159118 
     
    162121    if (fileOnly && in != null) in.close(); 
    163122    else if (!fileOnly) close(); 
    164   } 
    165  
    166   /* @see loci.formats.IFormatReader#close() */  
    167   public void close() throws FormatException, IOException { 
    168     if (in != null) in.close(); 
    169     in = null; 
    170     currentId = null; 
    171123  } 
    172124 
     
    178130    offsets = new Vector(); 
    179131 
    180     littleEndian = true; 
     132    core.littleEndian[0] = true; 
    181133 
    182134    xcal = new Vector(); 
     
    207159    // number of Unicode characters in the XML block 
    208160 
    209     int nc = DataTools.read4SignedBytes(in, littleEndian); 
     161    int nc = DataTools.read4SignedBytes(in, core.littleEndian[0]); 
    210162    byte[] s = new byte[nc * 2]; 
    211163    in.read(s); 
     
    215167 
    216168    while (in.getFilePointer() < in.length()) { 
    217       if (DataTools.read4SignedBytes(in, littleEndian) != 0x70) { 
     169      if (DataTools.read4SignedBytes(in, core.littleEndian[0]) != 0x70) { 
    218170        throw new FormatException("Invalid Memory Block"); 
    219171      } 
     
    224176      } 
    225177 
    226       int blockLength = DataTools.read4SignedBytes(in, littleEndian); 
     178      int blockLength = DataTools.read4SignedBytes(in, core.littleEndian[0]); 
    227179      if (in.read() != 0x2a) { 
    228180        throw new FormatException("Invalid Memory Description"); 
    229181      } 
    230182 
    231       int descrLength = DataTools.read4SignedBytes(in, littleEndian); 
     183      int descrLength = DataTools.read4SignedBytes(in, core.littleEndian[0]); 
    232184      byte[] memDescr = new byte[2*descrLength]; 
    233185      in.read(memDescr); 
     
    239191      in.skipBytes(blockLength); 
    240192    } 
    241     numImages = offsets.size(); 
    242193    initMetadata(xml); 
    243194  } 
     
    271222 
    272223    int ndx = 1; 
    273     numImages = 0; 
    274224 
    275225    // the image data we need starts with the token "ElementName='blah'" and 
     
    450400 
    451401    numDatasets = widths.size(); 
    452     dims = new int[numDatasets][7]; 
    453  
    454     for (int i=0; i<numDatasets; i++) { 
    455       dims[i][0] = ((Integer) widths.get(i)).intValue(); 
    456       dims[i][1] = ((Integer) heights.get(i)).intValue(); 
    457       dims[i][2] = ((Integer) zs.get(i)).intValue(); 
    458       dims[i][3] = ((Integer) ts.get(i)).intValue(); 
    459       dims[i][4] = ((Integer) channels.get(i)).intValue(); 
    460       dims[i][5] = ((Integer) bps.get(i)).intValue(); 
    461       dims[i][6] = ((Integer) extraDims.get(i)).intValue(); 
    462  
    463       if (dims[i][6] > 1) { 
    464         if (dims[i][2] == 1) dims[i][2] = dims[i][6]; 
    465         else dims[i][3] *= dims[i][6]; 
    466         dims[i][6] = 1; 
    467       } 
    468  
    469       numImages += (dims[i][2] * dims[i][3] * dims[i][6]); 
    470     } 
     402 
     403    bitsPerPixel = new int[numDatasets]; 
     404    extraDimensions = new int[numDatasets]; 
    471405 
    472406    // Populate metadata store 
     
    482416 
    483417    for (int i=0; i<numDatasets; i++) { 
    484       core.sizeX[i] = dims[i][0]; 
    485       core.sizeY[i] = dims[i][1]; 
    486       core.sizeZ[i] = dims[i][2]; 
    487       core.sizeC[i] = dims[i][4]; 
    488       core.sizeT[i] = dims[i][3]; 
     418      core.sizeX[i] = ((Integer) widths.get(i)).intValue(); 
     419      core.sizeY[i] = ((Integer) heights.get(i)).intValue(); 
     420      core.sizeZ[i] = ((Integer) zs.get(i)).intValue(); 
     421      core.sizeC[i] = ((Integer) channels.get(i)).intValue(); 
     422      core.sizeT[i] = ((Integer) ts.get(i)).intValue(); 
    489423      core.currentOrder[i] =  
    490424        (core.sizeZ[i] > core.sizeT[i]) ? "XYCZT" : "XYCTZ"; 
    491425 
     426      bitsPerPixel[i] = ((Integer) bps.get(i)).intValue(); 
     427      extraDimensions[i] = ((Integer) extraDims.get(i)).intValue(); 
     428 
     429      if (extraDimensions[i] > 1) { 
     430        if (core.sizeZ[i] == 1) core.sizeZ[i] = extraDimensions[i]; 
     431        else core.sizeT[i] *= extraDimensions[i]; 
     432        extraDimensions[i] = 1;  
     433      } 
     434 
     435      core.littleEndian[i] = true; 
     436      core.rgb[i] = core.sizeC[i] > 1 && core.sizeC[i] < 4; 
     437      core.interleaved[i] = true; 
     438      core.imageCount[i] = core.sizeZ[i] * core.sizeT[i]; 
     439      if (core.rgb[i]) core.imageCount[i] *= core.sizeC[i]; 
     440 
    492441      validBits[i] = new int[core.sizeC[i] != 2 ? core.sizeC[i] : 3]; 
    493442      for (int j=0; j<validBits[i].length; j++) { 
    494         validBits[i][j] = dims[i][5]; 
    495       } 
    496  
    497       while (dims[i][5] % 8 != 0) dims[i][5]++; 
    498       switch (dims[i][5]) { 
     443        validBits[i][j] = bitsPerPixel[i]; 
     444      } 
     445 
     446      while (bitsPerPixel[i] % 8 != 0) bitsPerPixel[i]++; 
     447      switch (bitsPerPixel[i]) { 
    499448        case 8: 
    500449          core.pixelType[i] = FormatTools.UINT8; 
     
    513462 
    514463      store.setPixels( 
    515         new Integer(core.sizeX[0]), // SizeX 
    516         new Integer(core.sizeY[0]), // SizeY 
    517         new Integer(core.sizeZ[0]), // SizeZ 
    518         new Integer(core.sizeC[0]), // SizeC 
    519         new Integer(core.sizeT[0]), // SizeT 
     464        new Integer(core.sizeX[i]), // SizeX 
     465        new Integer(core.sizeY[i]), // SizeY 
     466        new Integer(core.sizeZ[i]), // SizeZ 
     467        new Integer(core.sizeC[i]), // SizeC 
     468        new Integer(core.sizeT[i]), // SizeT 
    520469        new Integer(core.pixelType[i]), // PixelType 
    521         new Boolean(!littleEndian), // BigEndian 
     470        new Boolean(!core.littleEndian[i]), // BigEndian 
    522471        core.currentOrder[i], // DimensionOrder 
    523472        ii, // Image index 
  • trunk/loci/formats/in/LegacyPictReader.java

    r2583 r2584  
    5252  } 
    5353 
    54   /* @see loci.formats.IFormatReader#getImageCount() */  
    55   public int getImageCount() throws FormatException, IOException { 
    56     return 1; 
    57   } 
    58  
    59   /* @see loci.formats.IFormatReader#isRGB() */  
    60   public boolean isRGB() throws FormatException, IOException { 
    61     return core.sizeC[0] > 1; 
    62   } 
    63  
    64   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    65   public boolean isLittleEndian() throws FormatException, IOException { 
    66     return false; 
    67   } 
    68  
    69   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    70   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    71     return false; 
    72   } 
    73  
    7454  /* @see loci.formats.IFormatReader#openBytes(int) */  
    7555  public byte[] openBytes(int no) throws FormatException, IOException { 
     
    11292    core.pixelType[0] = FormatTools.INT8; 
    11393    core.currentOrder[0] = "XYCZT"; 
     94    core.rgb[0] = core.sizeC[0] > 1; 
     95    core.interleaved[0] = false; 
     96    core.imageCount[0] = 1; 
     97    core.littleEndian[0] = false; 
    11498 
    11599    MetadataStore store = getMetadataStore(); 
     
    127111  public void close(boolean fileOnly) throws FormatException, IOException { } 
    128112 
    129   /* @see loci.formats.IFormatReader#close() */  
    130   public void close() throws FormatException, IOException { } 
    131  
    132113} 
  • trunk/loci/formats/in/LegacyQTReader.java

    r2583 r2584  
    5050  protected ReflectedUniverse r; 
    5151 
    52   /** Number of images in current QuickTime movie. */ 
    53   protected int numImages; 
    54  
    5552  /** Time offset for each frame. */ 
    5653  protected int[] times; 
     
    7370  /* @see loci.formats.IFormatReader#isThisType(byte[]) */  
    7471  public boolean isThisType(byte[] block) { return false; } 
    75  
    76   /* @see loci.formats.IFormatReader#getImageCount() */  
    77   public int getImageCount() throws FormatException, IOException { 
    78     return numImages; 
    79   } 
    80  
    81   /* @see loci.formats.IFormatReader#isRGB() */  
    82   public boolean isRGB() throws FormatException, IOException { 
    83     return true; 
    84   } 
    85  
    86   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    87   public boolean isLittleEndian() throws FormatException, IOException { 
    88     return false; 
    89   } 
    90  
    91   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    92   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    93     return false; 
    94   } 
    9572 
    9673  /* @see loci.formats.IFormatReader#openBytes(int) */  
     
    219196      } 
    220197      while (time >= 0); 
    221       numImages = v.size(); 
    222       times = new int[numImages]; 
     198      core.imageCount[0] = v.size(); 
     199      times = new int[core.imageCount[0]]; 
    223200      for (int i=0; i<times.length; i++) { 
    224201        q = (Integer) v.elementAt(i); 
     
    234211      core.sizeZ[0] = 1; 
    235212      core.sizeC[0] = img.getRaster().getNumBands(); 
    236       core.sizeT[0] = numImages; 
     213      core.sizeT[0] = core.imageCount[0]; 
    237214      core.pixelType[0] = ImageTools.getPixelType(img); 
    238215      core.currentOrder[0] = "XYCTZ"; 
     216      core.rgb[0] = true; 
     217      core.interleaved[0] = false; 
     218      core.littleEndian[0] = false; 
    239219 
    240220      MetadataStore store = getMetadataStore(); 
  • trunk/loci/formats/in/LegacyZVIReader.java

    r2583 r2584  
    6666  // -- Fields -- 
    6767 
    68   /** Current file. */ 
    69   protected RandomAccessStream in; 
    70  
    7168  /** List of image blocks. */ 
    7269  private Vector blockList; 
     
    9794  } 
    9895 
    99   /* @see loci.formats.IFormatReader#isRGB() */  
    100   public boolean isRGB() throws FormatException, IOException { 
    101     return (bytesPerPixel == 3) || (bytesPerPixel > 4); 
    102   } 
    103  
    104   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    105   public boolean isLittleEndian() throws FormatException, IOException { 
    106     return true; 
    107   } 
    108  
    109   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    110   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    111     return false; 
    112   } 
    113  
    11496  /* @see loci.formats.IFormatReader#openBytes(int) */  
    11597  public byte[] openBytes(int no) throws FormatException, IOException { 
     
    152134    if (fileOnly && in != null) in.close(); 
    153135    else if (!fileOnly) close(); 
    154   } 
    155  
    156   /* @see loci.formats.IFormatReader#close() */  
    157   public void close() throws FormatException, IOException { 
    158     if (in != null) in.close(); 
    159     in = null; 
    160     currentId = null; 
    161136  } 
    162137 
     
    420395      core.sizeC[0] = cSet.size(); 
    421396      core.sizeT[0] = tSet.size(); 
     397      core.rgb[0] = bytesPerPixel == 3 || bytesPerPixel > 4; 
     398      core.interleaved[0] = false; 
     399      core.imageCount[0] = blockList.size(); 
     400      core.littleEndian[0] = true; 
    422401 
    423402      // Populate metadata store 
  • trunk/loci/formats/in/LeicaReader.java

    r2583 r2584  
    4545  // -- Fields -- 
    4646 
    47   /** Current file. */ 
    48   protected RandomAccessStream in; 
    49  
    5047  protected Hashtable[] ifds; 
    51  
    52   /** Flag indicating whether current file is little endian. */ 
    53   protected boolean littleEndian; 
    5448 
    5549  /** Array of IFD-like structures containing metadata. */ 
     
    6458  /** Number of series in the file. */ 
    6559  private int numSeries; 
    66  
    67   /** Total number of planes in each series. */ 
    68   private int[] numPlanes; 
    6960 
    7061  /** Number of significant bits per pixel. */ 
     
    114105  } 
    115106 
    116   /* @see loci.formats.IFormatReader#getImageCount() */  
    117   public int getImageCount() throws FormatException, IOException { 
    118     return numPlanes[series]; 
    119   } 
    120  
    121   /* @see loci.formats.IFormatReader#getSeriesCount() */  
    122   public int getSeriesCount() throws FormatException, IOException { 
    123     return numSeries; 
    124   } 
    125  
    126   /* @see loci.formats.IFormatReader#isRGB() */  
    127   public boolean isRGB() throws FormatException, IOException { 
    128     return false;  
    129   } 
    130  
    131   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    132   public boolean isLittleEndian() throws FormatException, IOException { 
    133     return littleEndian; 
    134   } 
    135  
    136   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    137   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    138     return true; 
    139   } 
    140  
    141107  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    142108  public byte[] openBytes(int no) throws FormatException, IOException { 
     
    145111    } 
    146112    int ndx = no % channelIndices.length;  
     113    tiff[series][no].setId((String) files[series].get(no)); 
    147114    byte[] b = tiff[series][no].openBytes(0); 
    148115    b = ImageTools.splitChannels(b, core.sizeC[series], false,  
     
    159126      throw new FormatException("Invalid image number: " + no); 
    160127    } 
     128    tiff[series][no].setId((String) files[series].get(no)); 
    161129    tiff[series][no].openBytes(0, buf); 
    162130    tiff[series][no].close(); 
     
    174142    } 
    175143 
     144    tiff[series][no].setId((String) files[series].get(no)); 
    176145    BufferedImage b = tiff[series][no].openImage(0); 
    177146 
     
    214183  /* @see loci.formats.IFormatReader#close() */  
    215184  public void close() throws FormatException, IOException { 
    216     if (in != null) in.close(); 
    217     in = null; 
    218     currentId = null; 
     185    super.close();  
    219186    leiFilename = null; 
    220187    files = null; 
     
    326293      byte[] fourBytes = new byte[4]; 
    327294      in.read(fourBytes); 
    328       littleEndian = (fourBytes[0] == TiffTools.LITTLE && 
     295      core.littleEndian[0] = (fourBytes[0] == TiffTools.LITTLE && 
    329296        fourBytes[1] == TiffTools.LITTLE && 
    330297        fourBytes[2] == TiffTools.LITTLE && 
    331298        fourBytes[3] == TiffTools.LITTLE); 
    332299 
    333       in.order(littleEndian); 
     300      in.order(core.littleEndian[0]); 
    334301 
    335302      status("Reading metadata blocks"); 
     
    370337      headerIFDs = new Hashtable[numSeries]; 
    371338      files = new Vector[numSeries]; 
    372       numPlanes = new int[numSeries]; 
    373339 
    374340      v.copyInto(headerIFDs); 
     
    381347 
    382348      status("Parsing metadata blocks"); 
     349 
     350      core.littleEndian[0] = !core.littleEndian[0]; 
    383351 
    384352      for (int i=0; i<headerIFDs.length; i++) { 
    385353        if (headerIFDs[i].get(new Integer(10)) != null) { 
    386354          byte[] temp = (byte[]) headerIFDs[i].get(new Integer(10)); 
    387           nameLength = DataTools.bytesToInt(temp, 8, 4, littleEndian); 
     355          nameLength = DataTools.bytesToInt(temp, 8, 4, core.littleEndian[0]); 
    388356        } 
    389357 
    390358        Vector f = new Vector(); 
    391359        byte[] tempData = (byte[]) headerIFDs[i].get(new Integer(15)); 
    392         int tempImages = DataTools.bytesToInt(tempData, 0, 4, littleEndian); 
     360        int tempImages = DataTools.bytesToInt(tempData, 0, 4,  
     361          core.littleEndian[0]); 
    393362        String dirPrefix = 
    394363          new Location(id).getAbsoluteFile().getParent(); 
     
    555524        } 
    556525        else files[i] = f; 
    557         numPlanes[i] = files[i].size(); 
    558         if (numPlanes[i] > maxPlanes) maxPlanes = numPlanes[i]; 
     526        core.imageCount[i] = files[i].size(); 
     527        if (core.imageCount[i] > maxPlanes) maxPlanes = core.imageCount[i]; 
    559528      } 
    560529 
     
    627596        // ID_SERIES 
    628597        addMeta("Version", 
    629           new Integer(DataTools.bytesToInt(temp, 0, 4, littleEndian))); 
     598          new Integer(DataTools.bytesToInt(temp, 0, 4, core.littleEndian[0]))); 
    630599        addMeta("Number of Series", 
    631           new Integer(DataTools.bytesToInt(temp, 4, 4, littleEndian))); 
     600          new Integer(DataTools.bytesToInt(temp, 4, 4, core.littleEndian[0]))); 
    632601        addMeta("Length of filename", 
    633           new Integer(DataTools.bytesToInt(temp, 8, 4, littleEndian))); 
     602          new Integer(DataTools.bytesToInt(temp, 8, 4, core.littleEndian[0]))); 
    634603        addMeta("Length of file extension", 
    635           new Integer(DataTools.bytesToInt(temp, 12, 4, littleEndian))); 
     604          new Integer(DataTools.bytesToInt(temp, 12, 4, core.littleEndian[0]))); 
    636605        Integer fileExtLen = (Integer) getMeta("Length of file extension"); 
    637606        addMeta("Image file extension", 
     
    644613        // ID_IMAGES 
    645614 
    646         core.sizeZ[i] = DataTools.bytesToInt(temp, 0, 4, littleEndian); 
    647         core.sizeX[i] = DataTools.bytesToInt(temp, 4, 4, littleEndian); 
    648         core.sizeY[i] = DataTools.bytesToInt(temp, 8, 4, littleEndian); 
     615        core.sizeZ[i] = DataTools.bytesToInt(temp, 0, 4, core.littleEndian[0]); 
     616        core.sizeX[i] = DataTools.bytesToInt(temp, 4, 4, core.littleEndian[0]); 
     617        core.sizeY[i] = DataTools.bytesToInt(temp, 8, 4, core.littleEndian[0]); 
    649618 
    650619        addMeta("Number of images", new Integer(core.sizeZ[i])); 
     
    652621        addMeta("Image height", new Integer(core.sizeY[i])); 
    653622        addMeta("Bits per Sample", 
    654           new Integer(DataTools.bytesToInt(temp, 12, 4, littleEndian))); 
     623          new Integer(DataTools.bytesToInt(temp, 12, 4, core.littleEndian[0]))); 
    655624        addMeta("Samples per pixel", 
    656           new Integer(DataTools.bytesToInt(temp, 16, 4, littleEndian))); 
     625          new Integer(DataTools.bytesToInt(temp, 16, 4, core.littleEndian[0]))); 
    657626      } 
    658627 
     
    663632        int pt = 0; 
    664633        addMeta("Voxel Version", new Integer( 
    665           DataTools.bytesToInt(temp, 0, 4, littleEndian))); 
    666         int voxelType = DataTools.bytesToInt(temp, 4, 4, littleEndian); 
     634          DataTools.bytesToInt(temp, 0, 4, core.littleEndian[0]))); 
     635        int voxelType = DataTools.bytesToInt(temp, 4, 4, core.littleEndian[0]); 
    667636        String type = ""; 
    668637        switch (voxelType) { 
     
    681650 
    682651        addMeta("Bytes per pixel", 
    683           new Integer(DataTools.bytesToInt(temp, 8, 4, littleEndian))); 
     652          new Integer(DataTools.bytesToInt(temp, 8, 4, core.littleEndian[0]))); 
    684653        addMeta("Real world resolution", 
    685           new Integer(DataTools.bytesToInt(temp, 12, 4, littleEndian))); 
    686         int length = DataTools.bytesToInt(temp, 16, 4, littleEndian); 
     654          new Integer(DataTools.bytesToInt(temp, 12, 4, core.littleEndian[0]))); 
     655        int length = DataTools.bytesToInt(temp, 16, 4, core.littleEndian[0]); 
    687656        addMeta("Maximum voxel intensity", 
    688657          DataTools.stripString(new String(temp, 20, length))); 
     
    692661          DataTools.stripString(new String(temp, pt, length))); 
    693662        pt += length; 
    694         length = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     663        length = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    695664        pt += 4 + length + 4; 
    696665 
    697         length = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     666        length = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    698667        for (int j=0; j<length; j++) { 
    699           int dimId = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     668          int dimId = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    700669          String dimType = ""; 
    701670          switch (dimId) { 
     
    787756          pt += 4; 
    788757          addMeta("Dim" + j + " size", new Integer( 
    789             DataTools.bytesToInt(temp, pt, 4, littleEndian))); 
     758            DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]))); 
    790759          pt += 4; 
    791760          addMeta("Dim" + j + " distance between sub-dimensions", 
    792             new Integer(DataTools.bytesToInt(temp, pt, 4, littleEndian))); 
    793           pt += 4; 
    794  
    795           int len = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     761            new Integer(DataTools.bytesToInt(temp, pt, 4,  
     762            core.littleEndian[0]))); 
     763          pt += 4; 
     764 
     765          int len = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    796766          pt += 4; 
    797767          addMeta("Dim" + j + " physical length", 
     
    799769          pt += len; 
    800770 
    801           len = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     771          len = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    802772          pt += 4; 
    803773          addMeta("Dim" + j + " physical origin", 
     
    805775          pt += len; 
    806776 
    807           len = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     777          len = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    808778          pt += 4; 
    809779          addMeta("Dim" + j + " name", 
     
    811781          pt += len; 
    812782 
    813           len = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     783          len = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    814784          pt += 4; 
    815785          addMeta("Dim" + j + " description", 
     
    831801        // time data 
    832802        // ID_TIMEINFO 
    833         int nDims = DataTools.bytesToInt(temp, 0, 4, littleEndian); 
     803        int nDims = DataTools.bytesToInt(temp, 0, 4, core.littleEndian[0]); 
    834804        addMeta("Number of time-stamped dimensions", new Integer(nDims)); 
    835805        addMeta("Time-stamped dimension", 
    836           new Integer(DataTools.bytesToInt(temp, 4, 4, littleEndian))); 
     806          new Integer(DataTools.bytesToInt(temp, 4, 4, core.littleEndian[0]))); 
    837807 
    838808        int pt = 8; 
     
    840810        for (int j=0; j < nDims; j++) { 
    841811          addMeta("Dimension " + j + " ID", 
    842             new Integer(DataTools.bytesToInt(temp, pt, 4, littleEndian))); 
     812            new Integer(DataTools.bytesToInt(temp, pt, 4,  
     813            core.littleEndian[0]))); 
    843814          pt += 4; 
    844815          addMeta("Dimension " + j + " size", 
    845             new Integer(DataTools.bytesToInt(temp, pt, 4, littleEndian))); 
     816            new Integer(DataTools.bytesToInt(temp, pt, 4, 
     817            core.littleEndian[0]))); 
    846818          pt += 4; 
    847819          addMeta("Dimension " + j + " distance between dimensions", 
    848             new Integer(DataTools.bytesToInt(temp, pt, 4, littleEndian))); 
    849           pt += 4; 
    850         } 
    851  
    852         int numStamps = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     820            new Integer(DataTools.bytesToInt(temp, pt, 4, 
     821            core.littleEndian[0]))); 
     822          pt += 4; 
     823        } 
     824 
     825        int numStamps = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    853826        pt += 4; 
    854827        addMeta("Number of time-stamps", new Integer(numStamps)); 
     
    859832        } 
    860833 
    861         int numTMs = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     834        int numTMs = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    862835        pt += 4; 
    863836        addMeta("Number of time-markers", new Integer(numTMs)); 
    864837        for (int j=0; j<numTMs; j++) { 
    865           int numDims = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     838          int numDims = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    866839          pt += 4; 
    867840 
     
    869842            addMeta("Time-marker " + j + 
    870843              " Dimension " + k + " coordinate", 
    871               new Integer(DataTools.bytesToInt(temp, pt, 4, littleEndian))); 
     844              new Integer(DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]))); 
    872845            pt += 4; 
    873846          } 
     
    891864        // ID_EXPERIMENT 
    892865        int pt = 8; 
    893         int len = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     866        int len = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    894867        pt += 4; 
    895868 
     
    897870          DataTools.stripString(new String(temp, pt, 2*len))); 
    898871        pt += 2*len; 
    899         len = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     872        len = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    900873        pt += 4; 
    901874 
     
    904877        pt += 2*len; 
    905878 
    906         len = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     879        len = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    907880        pt += 4; 
    908881        addMeta("Single image format identifier", 
     
    910883        pt += 2*len; 
    911884 
    912         len = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     885        len = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    913886        pt += 4; 
    914887        addMeta("Single image extension", 
     
    921894        // ID_LUTDESC 
    922895        int pt = 0; 
    923         int nChannels = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     896        int nChannels = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    924897        pt += 4; 
    925898        addMeta("Number of LUT channels", new Integer(nChannels)); 
    926899        addMeta("ID of colored dimension", 
    927           new Integer(DataTools.bytesToInt(temp, pt, 4, littleEndian))); 
     900          new Integer(DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]))); 
    928901        pt += 4; 
    929902 
     
    934907        for (int j=0; j<nChannels; j++) { 
    935908          addMeta("LUT Channel " + j + " version", 
    936             new Integer(DataTools.bytesToInt(temp, pt, 4, littleEndian))); 
    937           pt += 4; 
    938  
    939           int invert = DataTools.bytesToInt(temp, pt, 1, littleEndian); 
     909            new Integer(DataTools.bytesToInt(temp, pt, 4,  
     910            core.littleEndian[0]))); 
     911          pt += 4; 
     912 
     913          int invert = DataTools.bytesToInt(temp, pt, 1, core.littleEndian[0]); 
    940914          pt += 1; 
    941915          boolean inverted = invert == 1; 
     
    943917            new Boolean(inverted).toString()); 
    944918 
    945           int length = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     919          int length = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    946920          pt += 4; 
    947921          addMeta("LUT Channel " + j + " description", 
     
    949923 
    950924          pt += length; 
    951           length = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     925          length = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    952926          pt += 4; 
    953927          addMeta("LUT Channel " + j + " filename", 
    954928            DataTools.stripString(new String(temp, pt, length))); 
    955929          pt += length; 
    956           length = DataTools.bytesToInt(temp, pt, 4, littleEndian); 
     930          length = DataTools.bytesToInt(temp, pt, 4, core.littleEndian[0]); 
    957931          pt += 4; 
    958932 
     
    1023997    } 
    1024998 
     999    byte[] f = new byte[4]; 
    10251000    for (int i=0; i<numSeries; i++) { 
    10261001      core.orderCertain[i] = true; 
     1002      core.rgb[i] = false; 
     1003      core.interleaved[i] = true; 
     1004      try {  
     1005        in.seek(0); 
     1006        in.read(f); 
     1007        core.littleEndian[i] = (f[0] == TiffTools.LITTLE && 
     1008          f[1] == TiffTools.LITTLE && f[2] == TiffTools.LITTLE && 
     1009          f[3] == TiffTools.LITTLE); 
     1010      } 
     1011      catch (Exception e) { 
     1012        if (debug) e.printStackTrace();  
     1013      }  
    10271014 
    10281015      if (core.sizeC[i] == 0) core.sizeC[i] = 1; 
     
    10621049        new Integer(core.sizeT[i]), // SizeT 
    10631050        new Integer(core.pixelType[i]), // PixelType 
    1064         new Boolean(!littleEndian), // BigEndian 
     1051        new Boolean(!core.littleEndian[i]), // BigEndian 
    10651052        core.currentOrder[i], // DimensionOrder 
    10661053        ii, null); 
  • trunk/loci/formats/in/MNGReader.java

    r2583 r2584  
    3939  // -- Fields -- 
    4040 
    41   /** Current file. */ 
    42   protected RandomAccessStream in; 
    43  
    44   /** Number of image planes in the file. */ 
    45   protected int numImages = 0; 
    46  
    4741  /** Offsets to each plane. */ 
    4842  private Vector offsets; 
     
    6458      block[3] == 0x47 && block[4] == 0x0d && block[5] == 0x0a && 
    6559      block[6] == 0x1a && block[7] == 0x0a; 
    66   } 
    67  
    68   /* @see loci.formats.IFormatReader#getImageCount() */  
    69   public int getImageCount() throws FormatException, IOException { 
    70     return numImages; 
    71   } 
    72  
    73   /* @see loci.formats.IFormatReader#isRGB() */  
    74   public boolean isRGB() throws FormatException, IOException { 
    75     return core.sizeC[0] > 1; 
    76   } 
    77  
    78   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    79   public boolean isLittleEndian() throws FormatException, IOException { 
    80     return false; 
    81   } 
    82  
    83   /* @see loci.formats.IFormatReader#isInterleaved() */  
    84   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    85     return false; 
    8660  } 
    8761 
     
    11892    if (fileOnly && in != null) in.close(); 
    11993    else if (!fileOnly) close(); 
    120   } 
    121  
    122   /* @see loci.formats.IFormatReader#close() */  
    123   public void close() throws FormatException, IOException { 
    124     if (in != null) in.close(); 
    125     in = null; 
    126     currentId = null; 
    12794  } 
    12895 
     
    175142      if (code.equals("IHDR")) { 
    176143        offsets.add(new Integer((int) in.getFilePointer() - 8)); 
    177         numImages++; 
     144        core.imageCount[0]++; 
    178145      } 
    179146      else if (code.equals("IEND")) { 
     
    205172    core.sizeZ[0] = 1; 
    206173    core.sizeC[0] = openImage(0).getRaster().getNumBands(); 
    207     core.sizeT[0] = numImages; 
     174    core.sizeT[0] = core.imageCount[0]; 
    208175    core.currentOrder[0] = "XYCZT"; 
    209176    core.pixelType[0] = FormatTools.UINT8; 
     177    core.rgb[0] = core.sizeC[0] > 1; 
     178    core.interleaved[0] = false; 
     179    core.littleEndian[0] = false; 
    210180 
    211181    MetadataStore store = getMetadataStore(); 
  • trunk/loci/formats/in/MRCReader.java

    r2583 r2584  
    3838  // -- Fields -- 
    3939 
    40   /** Current file. */ 
    41   protected RandomAccessStream in; 
    42  
    43   /** Number of image planes in the file. */ 
    44   protected int numImages = 0; 
    45  
    4640  /** Number of bytes per pixel */ 
    4741  private int bpp = 0; 
     
    5246  /** Flag set to true if we are using float data. */ 
    5347  private boolean isFloat = false; 
    54  
    55   /** Flag set to true if data is little-endian. */ 
    56   private boolean little; 
    5748 
    5849  // -- Constructor -- 
     
    6859  public boolean isThisType(byte[] block) { 
    6960    return false; // no way to tell if this is an MRC file or not 
    70   } 
    71  
    72   /* @see loci.formats.IFormatReader#getImageCount() */  
    73   public int getImageCount() throws FormatException, IOException { 
    74     return numImages; 
    75   } 
    76  
    77   /* @see loci.formats.IFormatReader#isRGB() */  
    78   public boolean isRGB() throws FormatException, IOException { 
    79     return false; 
    80   } 
    81  
    82   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    83   public boolean isLittleEndian() throws FormatException, IOException { 
    84     return little; 
    85   } 
    86  
    87   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    88   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    89     return true; 
    9061  } 
    9162 
     
    11485  public BufferedImage openImage(int no) throws FormatException, IOException { 
    11586    return ImageTools.makeImage(openBytes(no), core.sizeX[0], 
    116       core.sizeY[0], 1, true, bpp, little); 
     87      core.sizeY[0], 1, true, bpp, core.littleEndian[0]); 
    11788  } 
    11889 
     
    12192    if (fileOnly && in != null) in.close(); 
    12293    else if (!fileOnly) close(); 
    123   } 
    124  
    125   /* @see loci.formats.IFormatReader#close() */  
    126   public void close() throws FormatException, IOException { 
    127     if (in != null) in.close(); 
    128     in = null; 
    129     currentId = null; 
    13094  } 
    13195 
     
    141105 
    142106    in.seek(213); 
    143     little = in.read() == 68; 
     107    core.littleEndian[0] = in.read() == 68; 
    144108 
    145109    // read 1024 byte header 
    146110 
    147111    in.seek(0); 
    148     byte[] b = new byte[4]; 
    149  
    150     in.read(b); 
    151     core.sizeX[0] = DataTools.bytesToInt(b, little); 
    152     in.read(b); 
    153     core.sizeY[0] = DataTools.bytesToInt(b, little); 
    154     in.read(b); 
    155     core.sizeZ[0] = DataTools.bytesToInt(b, little); 
     112    in.order(core.littleEndian[0]);  
     113 
     114    core.sizeX[0] = in.readInt(); 
     115    core.sizeY[0] = in.readInt(); 
     116    core.sizeZ[0] = in.readInt(); 
    156117 
    157118    core.sizeC[0] = 1; 
    158119 
    159     in.read(b); 
    160     int mode = DataTools.bytesToInt(b, little); 
     120    int mode = in.readInt(); 
    161121    switch (mode) { 
    162122      case 0: 
     
    193153    } 
    194154 
    195     in.read(b); 
    196     int thumbX = DataTools.bytesToInt(b, little); 
    197     in.read(b); 
    198     int thumbY = DataTools.bytesToInt(b, little); 
    199     in.read(b); 
    200     int thumbZ = DataTools.bytesToInt(b, little); 
     155    int thumbX = in.readInt(); 
     156    int thumbY = in.readInt(); 
     157    int thumbZ = in.readInt(); 
    201158 
    202159    // pixel size = xlen / mx 
    203160 
    204     in.read(b); 
    205     int mx = DataTools.bytesToInt(b, little); 
    206     in.read(b); 
    207     int my = DataTools.bytesToInt(b, little); 
    208     in.read(b); 
    209     int mz = DataTools.bytesToInt(b, little); 
    210  
    211     in.read(b); 
    212     float xlen = Float.intBitsToFloat(DataTools.bytesToInt(b, little)); 
    213     in.read(b); 
    214     float ylen = Float.intBitsToFloat(DataTools.bytesToInt(b, little)); 
    215     in.read(b); 
    216     float zlen = Float.intBitsToFloat(DataTools.bytesToInt(b, little)); 
     161    int mx = in.readInt(); 
     162    int my = in.readInt(); 
     163    int mz = in.readInt(); 
     164 
     165    float xlen = in.readFloat(); 
     166    float ylen = in.readFloat(); 
     167    float zlen = in.readFloat(); 
    217168 
    218169    addMeta("Pixel size (X)", "" + (xlen / mx)); 
     
    220171    addMeta("Pixel size (Z)", "" + (zlen / mz)); 
    221172 
    222     in.read(b); 
    223     float alpha = Float.intBitsToFloat(DataTools.bytesToInt(b, little)); 
    224     in.read(b); 
    225     float beta = Float.intBitsToFloat(DataTools.bytesToInt(b, little)); 
    226     in.read(b); 
    227     float gamma = Float.intBitsToFloat(DataTools.bytesToInt(b, little)); 
     173    float alpha = in.readFloat(); 
     174    float beta = in.readFloat(); 
     175    float gamma = in.readFloat(); 
    228176 
    229177    addMeta("Alpha angle", "" + alpha); 
     
    235183    // min, max and mean pixel values 
    236184 
    237     in.read(b); 
    238     float min = Float.intBitsToFloat(DataTools.bytesToInt(b, little)); 
    239     in.read(b); 
    240     float max = Float.intBitsToFloat(DataTools.bytesToInt(b, little)); 
    241     in.read(b); 
    242     float mean = Float.intBitsToFloat(DataTools.bytesToInt(b, little)); 
     185    float min = in.readFloat(); 
     186    float max = in.readFloat(); 
     187    float mean = in.readFloat(); 
    243188 
    244189    addMeta("Minimum pixel value", "" + min); 
     
    247192 
    248193    in.skipBytes(4); 
    249     in.read(b); 
    250  
    251     extHeaderSize = DataTools.bytesToInt(b, little); 
    252     b = new byte[2]; 
    253     in.read(b); 
    254     int creator = DataTools.bytesToInt(b, little); 
     194 
     195    extHeaderSize = in.readInt(); 
     196    int creator = in.readShort(); 
    255197 
    256198    in.skipBytes(30); 
    257199 
    258     in.read(b); 
    259     int nint = DataTools.bytesToInt(b, little); 
    260     in.read(b); 
    261     int nreal = DataTools.bytesToInt(b, little); 
     200    int nint = in.readShort(); 
     201    int nreal = in.readShort(); 
    262202 
    263203    in.skipBytes(28); 
    264204 
    265     in.read(b); 
    266     int idtype = DataTools.bytesToInt(b, little); 
    267     in.read(b); 
    268     int lens = DataTools.bytesToInt(b, little); 
    269     in.read(b); 
    270     int nd1 = DataTools.bytesToInt(b, little); 
    271     in.read(b); 
    272     int nd2 = DataTools.bytesToInt(b, little); 
    273     in.read(b); 
    274     int vd1 = DataTools.bytesToInt(b, little); 
    275     in.read(b); 
    276     int vd2 = DataTools.bytesToInt(b, little); 
     205    int idtype = in.readShort(); 
     206    int lens = in.readShort(); 
     207    int nd1 = in.readShort(); 
     208    int nd2 = in.readShort(); 
     209    int vd1 = in.readShort(); 
     210    int vd2 = in.readShort(); 
    277211 
    278212    String type = ""; 
     
    304238    addMeta("VD2", "" + vd2); 
    305239 
    306     b = new byte[4]; 
    307240    float[] angles = new float[6]; 
    308241    for (int i=0; i<angles.length; i++) { 
    309       in.read(b); 
    310       angles[i] = Float.intBitsToFloat(DataTools.bytesToInt(b, little)); 
     242      angles[i] = in.readFloat(); 
    311243      addMeta("Angle " + (i+1), "" + angles[i]); 
    312244    } 
     
    314246    in.skipBytes(24); 
    315247 
    316     in.read(b); 
    317     int nUsefulLabels = DataTools.bytesToInt(b, little); 
     248    int nUsefulLabels = in.readInt(); 
    318249    addMeta("Number of useful labels", "" + nUsefulLabels); 
    319250 
    320     b = new byte[80]; 
     251    byte[] b = new byte[80]; 
    321252    for (int i=0; i<10; i++) { 
    322253      in.read(b); 
     
    330261    core.sizeT[0] = 1; 
    331262    core.currentOrder[0] = "XYZTC"; 
    332     numImages = core.sizeZ[0]; 
     263    core.imageCount[0] = core.sizeZ[0]; 
     264    core.rgb[0] = false; 
     265    core.interleaved[0] = true; 
    333266 
    334267    MetadataStore store = getMetadataStore(); 
     
    340273      new Integer(core.sizeT[0]), 
    341274      new Integer(core.pixelType[0]), 
    342       new Boolean(!little), 
     275      new Boolean(!core.littleEndian[0]), 
    343276      core.currentOrder[0], 
    344277      null, 
  • trunk/loci/formats/in/MetamorphReader.java

    r2583 r2584  
    154154      // additional image planes 
    155155      long[] uic2 = TiffTools.getIFDLongArray(ifds[0], UIC2TAG, true); 
    156       numImages = uic2.length; 
     156      core.imageCount[0] = uic2.length; 
    157157 
    158158      long[] uic3 = TiffTools.getIFDLongArray(ifds[0], UIC3TAG, true); 
     
    162162      } 
    163163 
    164       Hashtable[] tempIFDs = new Hashtable[numImages]; 
     164      Hashtable[] tempIFDs = new Hashtable[core.imageCount[0]]; 
    165165 
    166166      long[] oldOffsets = TiffTools.getIFDLongArray(ifds[0], 
     
    186186 
    187187      Hashtable temp; 
    188       for(int i=0; i<numImages; i++) { 
     188      for(int i=0; i<core.imageCount[0]; i++) { 
    189189        temp = new Hashtable(); 
    190190 
  • trunk/loci/formats/in/MicromanagerReader.java

    r2583 r2584  
    3333public class MicromanagerReader extends FormatReader { 
    3434 
     35  // -- Constants -- 
     36 
     37  /** File containing extra metadata. */ 
     38  private static final String METADATA = "metadata.txt"; 
     39 
    3540  // -- Fields -- 
    3641 
     
    5358  public boolean isThisType(byte[] b) { 
    5459    return tiffReader.isThisType(b); 
    55   } 
    56  
    57   /* @see loci.formats.IFormatReader#getImageCount() */ 
    58   public int getImageCount() throws FormatException, IOException { 
    59     return tiffs.size(); 
    60   } 
    61  
    62   /* @see loci.formats.IFormatReader#isLittleEndian() */ 
    63   public boolean isLittleEndian() throws FormatException, IOException { 
    64     return tiffReader.isLittleEndian(); 
    65   } 
    66  
    67   /* @see loci.formats.IFormatReader#isInterleaved() */ 
    68   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    69     return false; 
    7060  } 
    7161 
     
    9888  /* @see loci.formats.IFormatReader#close() */ 
    9989  public void close() throws FormatException, IOException { 
     90    super.close();  
    10091    if (tiffReader != null) tiffReader.close(); 
    10192    tiffReader = null; 
    102     currentId = null; 
    10393    tiffs = null; 
    10494  } 
     
    120110 
    121111    Location parent = new Location(currentId).getAbsoluteFile().getParentFile(); 
    122     RandomAccessStream ras = new RandomAccessStream( 
    123       new Location(parent, "metadata.txt").getAbsolutePath()); 
     112    in = new RandomAccessStream(new Location(parent,  
     113      METADATA).getAbsolutePath()); 
    124114 
    125115    // usually a small file, so we can afford to read it into memory 
    126116 
    127     byte[] meta = new byte[(int) ras.length()]; 
    128     ras.read(meta); 
     117    byte[] meta = new byte[(int) in.length()]; 
     118    in.read(meta); 
    129119    String s = new String(meta); 
    130120    meta = null; 
     
    137127    while (true) { 
    138128      pos = s.indexOf("FileName", pos); 
    139       if (pos == -1 || pos >= ras.length()) break; 
     129      if (pos == -1 || pos >= in.length()) break; 
    140130      String name = s.substring(s.indexOf(":", pos), s.indexOf(",", pos)); 
    141131      tiffs.add(0, name.substring(3, name.length() - 1)); 
     
    192182    core.currentOrder[0] = "XYCTZ"; 
    193183    core.pixelType[0] = tiffReader.getPixelType(); 
     184    core.rgb[0] = tiffReader.isRGB(); 
     185    core.interleaved[0] = false; 
     186    core.littleEndian[0] = tiffReader.isLittleEndian(); 
     187    core.imageCount[0] = tiffs.size(); 
    194188 
    195189    MetadataStore store = getMetadataStore(); 
     
    202196      new Integer(core.sizeT[0]), 
    203197      new Integer(core.pixelType[0]), 
    204       new Boolean(isLittleEndian()), 
     198      new Boolean(!core.littleEndian[0]), 
    205199      core.currentOrder[0], 
    206200      null, null); 
  • trunk/loci/formats/in/ND2Reader.java

    r2583 r2584  
    112112  // -- Fields -- 
    113113 
    114   /** Current file */ 
    115   private RandomAccessStream in; 
    116  
    117   /** Number of image planes in the file. */ 
    118   protected int numImages = 0; 
    119  
    120114  /** Array of image offsets. */ 
    121115  private long[] offsets; 
     
    123117  /** Number of valid bits per pixel */ 
    124118  private int[] validBits; 
    125  
    126   private boolean rgb; 
    127119 
    128120  // -- Constructor -- 
     
    138130    return block[4] == 0x6a && block[5] == 0x50 && block[6] == 0x20 && 
    139131      block[7] == 0x20; 
    140   } 
    141  
    142   /* @see loci.formats.IFormatReader#getImageCount() */  
    143   public int getImageCount() throws FormatException, IOException { 
    144     return numImages; 
    145   } 
    146  
    147   /* @see loci.formats.IFormatReader#isRGB() */  
    148   public boolean isRGB() throws FormatException, IOException { 
    149     return rgb; 
    150   } 
    151  
    152   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    153   public boolean isLittleEndian() throws FormatException, IOException { 
    154     return false; 
    155   } 
    156  
    157   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    158   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    159     return true; 
    160132  } 
    161133 
     
    292264    status("Finding XML metadata"); 
    293265 
    294     numImages = offsets.length; 
     266    core.imageCount[0] = offsets.length; 
    295267 
    296268    core.pixelType[0] = FormatTools.UINT8; 
     
    418390    } 
    419391 
    420     long[] tempOffsets = new long[numImages - numInvalid]; 
     392    long[] tempOffsets = new long[core.imageCount[0] - numInvalid]; 
    421393    int pt = 0; 
    422394    for (int i=0; i<offsets.length; i++) { 
     
    427399    } 
    428400    offsets = tempOffsets; 
    429     numImages = offsets.length; 
     401    core.imageCount[0] = offsets.length; 
    430402 
    431403    String sigBits = 
     
    458430    if (core.sizeC[0] == 2) core.sizeC[0] = 1; 
    459431 
    460     long[] timestamps = new long[numImages]; 
    461     long[] zstamps = new long[numImages]; 
    462  
    463     for (int i=0; i<numImages; i++) { 
     432    long[] timestamps = new long[core.imageCount[0]]; 
     433    long[] zstamps = new long[core.imageCount[0]]; 
     434 
     435    for (int i=0; i<core.imageCount[0]; i++) { 
    464436      String pre = "MetadataSeq _SEQUENCE_INDEX=\"" + i + "\" "; 
    465437      String tstamp = (String) getMeta(pre + "dTimeMSec value"); 
     
    471443    Vector zs = new Vector(); 
    472444    Vector ts = new Vector(); 
    473     for (int i=0; i<numImages; i++) { 
     445    for (int i=0; i<core.imageCount[0]; i++) { 
    474446      if (!zs.contains(new Long(zstamps[i]))) { 
    475447        core.sizeZ[0]++; 
     
    493465    int effectiveC = (core.sizeC[0] / 3) + 1; 
    494466 
    495     if (numImages < core.sizeZ[0] * core.sizeT[0]) { 
    496       if (core.sizeT[0] == numImages) { 
     467    if (core.imageCount[0] < core.sizeZ[0] * core.sizeT[0]) { 
     468      if (core.sizeT[0] == core.imageCount[0]) { 
    497469        core.sizeT[0] /= core.sizeZ[0] * effectiveC; 
    498         while (numImages > core.sizeZ[0] * core.sizeT[0] * effectiveC) { 
     470        while (core.imageCount[0] > core.sizeZ[0] * core.sizeT[0] * effectiveC) 
     471        { 
    499472          core.sizeT[0]++; 
    500473        } 
    501474      } 
    502       else if (core.sizeZ[0] == numImages) { 
     475      else if (core.sizeZ[0] == core.imageCount[0]) { 
    503476        core.sizeZ[0] /= core.sizeT[0] * effectiveC; 
    504         while (numImages > core.sizeZ[0] * core.sizeT[0] * effectiveC) { 
     477        while (core.imageCount[0] > core.sizeZ[0] * core.sizeT[0] * effectiveC) 
     478        { 
    505479          core.sizeZ[0]++; 
    506480        } 
    507481      } 
    508482 
    509       if (numImages < core.sizeZ[0] * core.sizeT[0] * effectiveC) { 
     483      if (core.imageCount[0] < core.sizeZ[0] * core.sizeT[0] * effectiveC) { 
    510484        if (core.sizeZ[0] < core.sizeT[0]) { 
    511485          core.sizeZ[0]--; 
    512           while (numImages > core.sizeZ[0] * core.sizeT[0] * effectiveC) { 
     486          while (core.imageCount[0] >  
     487            core.sizeZ[0] * core.sizeT[0] * effectiveC)  
     488          { 
    513489            core.sizeT[0]++; 
    514490          } 
    515           while (numImages < core.sizeZ[0] * core.sizeT[0] * effectiveC) { 
     491          while (core.imageCount[0] <  
     492            core.sizeZ[0] * core.sizeT[0] * effectiveC)  
     493          { 
    516494            core.sizeT[0]--; 
    517495          } 
     
    519497        else { 
    520498          core.sizeT[0]--; 
    521           while (numImages > core.sizeZ[0] * core.sizeT[0] * effectiveC) { 
     499          while (core.imageCount[0] >  
     500            core.sizeZ[0] * core.sizeT[0] * effectiveC)  
     501          { 
    522502            core.sizeZ[0]++; 
    523503          } 
    524           if (numImages < core.sizeZ[0] * core.sizeT[0] * effectiveC) { 
     504          if (core.imageCount[0] < core.sizeZ[0] * core.sizeT[0] * effectiveC) { 
    525505            core.sizeZ[0]--; 
    526506          } 
    527507        } 
    528         while (numImages > core.sizeZ[0] * core.sizeT[0] * effectiveC) { 
    529           numImages--; 
     508        while (core.imageCount[0] > core.sizeZ[0] * core.sizeT[0] * effectiveC) 
     509        { 
     510          core.imageCount[0]--; 
    530511        } 
    531512      } 
     
    558539    } 
    559540 
    560     rgb = core.sizeC[0] == 3; 
     541    core.rgb[0] = core.sizeC[0] == 3; 
     542    core.interleaved[0] = true; 
     543    core.littleEndian[0] = false; 
    561544 
    562545    MetadataStore store = getMetadataStore(); 
  • trunk/loci/formats/in/NikonReader.java

    r2557 r2584  
    105105  // -- Fields -- 
    106106 
    107   /** True if the data is little endian. */ 
    108   protected boolean littleEndian; 
    109  
    110107  /** Offset to the Nikon Maker Note. */ 
    111108  protected int makerNoteOffset; 
     
    202199    original = ifds[0]; 
    203200    ifds[0] = realImage; 
    204     numImages = 1; 
     201    core.imageCount[0] = 1; 
    205202 
    206203    Object pattern = getMeta("CFA pattern"); 
     
    223220    addMeta("Version", v); 
    224221 
    225     littleEndian = true; 
     222    core.littleEndian[0] = true; 
    226223    try { 
    227       littleEndian = TiffTools.isLittleEndian(ifds[0]); 
     224      core.littleEndian[0] = TiffTools.isLittleEndian(ifds[0]); 
    228225    } 
    229226    catch (FormatException f) { } 
  • trunk/loci/formats/in/OIBReader.java

    r2583 r2584  
    6767  // -- Fields -- 
    6868 
    69   /** Current file */ 
    70   private RandomAccessStream in; 
    71  
    7269  /** Number of images. */ 
    7370  private Vector nImages; 
     
    118115  private int[][] validBits; 
    119116 
    120   private boolean[] littleEndian; 
    121117  private Vector rgb; 
    122118 
     
    132128    return (block[0] == 0xd0 && block[1] == 0xcf && 
    133129      block[2] == 0x11 && block[3] == 0xe0); 
    134   } 
    135  
    136   /* @see loci.formats.IFormatReader#getImageCount() */  
    137   public int getImageCount() throws FormatException, IOException { 
    138     return ((Integer) nImages.get(series)).intValue(); 
    139   } 
    140  
    141   /* @see loci.formats.IFormatReader#isRGB() */  
    142   public boolean isRGB() throws FormatException, IOException { 
    143     return ((Boolean) rgb.get(series)).booleanValue(); 
    144   } 
    145  
    146   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    147   public boolean isLittleEndian() throws FormatException, IOException { 
    148     return false; 
    149   } 
    150  
    151   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    152   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    153     return false; 
    154   } 
    155  
    156   /* @see loci.formats.IFormatReader#getSeriesCount() */ 
    157   public int getSeriesCount() throws FormatException, IOException { 
    158     return width.size(); 
    159130  } 
    160131 
     
    194165      RandomAccessStream stream = new RandomAccessStream(b); 
    195166      Hashtable[] ifds = TiffTools.getIFDs(stream); 
    196       littleEndian[series] = TiffTools.isLittleEndian(ifds[0]); 
     167      core.littleEndian[series] = TiffTools.isLittleEndian(ifds[0]); 
    197168      TiffTools.getSamples(ifds[0], stream, buf); 
    198169      stream.close(); 
     
    215186 
    216187    return ImageTools.makeImage(b, core.sizeX[series], core.sizeY[series],  
    217       getRGBChannelCount(), false, bytes, !littleEndian[series],  
     188      getRGBChannelCount(), false, bytes, !core.littleEndian[series],  
    218189      validBits[series]); 
    219190  } 
     
    227198  /* @see loci.formats.IFormatReader#close() */  
    228199  public void close() throws FormatException, IOException { 
    229     if (in != null) in.close(); 
    230     in = null; 
    231     currentId = null; 
    232  
     200    super.close(); 
    233201    String[] vars = {"dirName", "root", "dir", "document", "dis", 
    234202      "numBytes", "data", "fis", "fs", "iter", "isInstance", "isDocument", 
     
    352320      } 
    353321 
    354       littleEndian = new boolean[numSeries]; 
    355  
    356322      core = new CoreMetadata(numSeries); 
    357323 
     
    383349          (core.sizeZ[i] > core.sizeT[i]) ? "XYCZT" : "XYCTZ"; 
    384350 
    385         int numImages = ((Integer) nImages.get(i)).intValue(); 
    386  
    387         if (numImages > core.sizeZ[i] * core.sizeT[i] * core.sizeC[i]) { 
    388           int diff = numImages -  
     351        core.imageCount[i] = ((Integer) nImages.get(i)).intValue(); 
     352 
     353        if (core.imageCount[i] > core.sizeZ[i] * core.sizeT[i] * core.sizeC[i]) 
     354        { 
     355          int diff = core.imageCount[i] -  
    389356            (core.sizeZ[i] * core.sizeT[i] * core.sizeC[i]); 
    390357 
    391358          if (diff % core.sizeZ[i] == 0 && core.sizeZ[i] > 1) { 
    392             while (numImages > core.sizeZ[i] * core.sizeT[i] * core.sizeC[i]) { 
     359            while (core.imageCount[i] >  
     360              core.sizeZ[i] * core.sizeT[i] * core.sizeC[i])  
     361            { 
    393362              core.sizeT[i]++; 
    394363            }  
    395364          } 
    396365          else if (diff % core.sizeT[i] == 0 && core.sizeT[i] > 1) { 
    397             while (numImages > core.sizeZ[i] * core.sizeT[i] * core.sizeC[i]) { 
     366            while (core.imageCount[i] >  
     367              core.sizeZ[i] * core.sizeT[i] * core.sizeC[i])  
     368            { 
    398369              core.sizeZ[i]++; 
    399370            }  
     
    401372          else if (diff % core.sizeC[i] == 0) { 
    402373            if (core.sizeZ[i] > core.sizeT[i]) { 
    403               while (numImages > core.sizeZ[i] * core.sizeC[i] * core.sizeT[i]) 
     374              while (core.imageCount[i] >  
     375                core.sizeZ[i] * core.sizeC[i] * core.sizeT[i]) 
    404376              { 
    405377                core.sizeZ[i]++; 
     
    407379            } 
    408380            else { 
    409               while (numImages > core.sizeZ[i] * core.sizeC[i] * core.sizeT[i])  
     381              while (core.imageCount[i] >  
     382                core.sizeZ[i] * core.sizeC[i] * core.sizeT[i])  
    410383              {  
    411384                core.sizeT[i]++; 
     
    417390        int oldSeries = getSeries(); 
    418391        setSeries(i); 
    419         while (numImages < core.sizeZ[i] * core.sizeT[i] * getEffectiveSizeC())  
     392        while (core.imageCount[i] <  
     393          core.sizeZ[i] * core.sizeT[i] * getEffectiveSizeC())  
    420394        { 
    421           numImages++; 
    422         } 
    423         nImages.setElementAt(new Integer(numImages), i); 
     395          core.imageCount[i]++; 
     396        } 
     397        nImages.setElementAt(new Integer(core.imageCount[i]), i); 
    424398        setSeries(oldSeries); 
    425399 
     
    437411        } 
    438412        else validBits[i] = null; 
     413       
     414        core.rgb[i] = ((Boolean) rgb.get(i)).booleanValue(); 
     415        core.interleaved[i] = false; 
    439416      } 
    440417    } 
  • trunk/loci/formats/in/OIFReader.java

    r2583 r2584  
    4040  // -- Fields -- 
    4141 
    42   /** Current file. */ 
    43   protected RandomAccessStream reader; 
    44  
    45   /** Number of image planes in the file. */ 
    46   protected int numImages = 0; 
    47  
    4842  /** Names of every TIFF file to open. */ 
    4943  protected Vector tiffs; 
     
    7367  /* @see loci.formats.IFormatReader#isThisType(byte[]) */  
    7468  public boolean isThisType(byte[] block) { 
    75     return false; 
    76   } 
    77  
    78   /* @see loci.formats.IFormatReader#getImageCount() */  
    79   public int getImageCount() throws FormatException, IOException { 
    80     return isRGB() ? 3*numImages : numImages; 
    81   } 
    82  
    83   /* @see loci.formats.IFormatReader#isRGB() */  
    84   public boolean isRGB() throws FormatException, IOException { 
    85     return tiffReader[0].isRGB(); 
    86   } 
    87  
    88   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    89   public boolean isLittleEndian() throws FormatException, IOException { 
    90     return true; 
    91   } 
    92  
    93   /* @see loci.formats.IFormatReader#isInterleaved() */  
    94   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    9569    return false; 
    9670  } 
     
    167141  public void close(boolean fileOnly) throws FormatException, IOException { 
    168142    if (fileOnly) { 
    169       if (reader != null) reader.close(); 
     143      if (in != null) in.close(); 
    170144      if (thumbReader != null) thumbReader.close(fileOnly); 
    171145      if (tiffReader != null) { 
     
    180154  /* @see loci.formats.IFormatReader#close() */  
    181155  public void close() throws FormatException, IOException { 
    182     if (reader != null) reader.close(); 
    183     reader = null; 
    184     currentId = null; 
     156    super.close();  
    185157    if (thumbReader != null) thumbReader.close(); 
    186158    if (tiffReader != null) { 
     
    227199 
    228200    super.initFile(oifFile); 
    229     reader = new RandomAccessStream(oifFile); 
     201    in = new RandomAccessStream(oifFile); 
    230202 
    231203    usedFiles = new Vector(); 
     
    239211    status("Parsing metadata values"); 
    240212 
    241     byte[] b = new byte[(int) reader.length()]; 
    242     reader.read(b); 
     213    byte[] b = new byte[(int) in.length()]; 
     214    in.read(b); 
    243215    String s = new String(b); 
    244216    StringTokenizer st = new StringTokenizer(s, "\r\n"); 
     
    268240 
    269241    thumbReader = new BMPReader(); 
    270     numImages = filenames.size(); 
    271     tiffs = new Vector(numImages); 
    272  
    273     tiffReader = new TiffReader[numImages]; 
    274     for (int i=0; i<numImages; i++) { 
     242    core.imageCount[0] = filenames.size(); 
     243    tiffs = new Vector(core.imageCount[0]); 
     244 
     245    tiffReader = new TiffReader[core.imageCount[0]]; 
     246    for (int i=0; i<core.imageCount[0]; i++) { 
    275247      tiffReader[i] = new TiffReader(); 
    276248    } 
     
    283255    RandomAccessStream ptyReader; 
    284256 
    285     for (int i=0; i<numImages; i++) { 
     257    for (int i=0; i<core.imageCount[0]; i++) { 
    286258      String file = (String) filenames.get(new Integer(i)); 
    287259      file = file.substring(1, file.length() - 1); 
     
    339311    if (core.sizeT[0] == 0) core.sizeT[0] = 1; 
    340312 
    341     while (numImages > core.sizeZ[0] * core.sizeT[0] * getEffectiveSizeC()) { 
     313    while (core.imageCount[0] >  
     314      core.sizeZ[0] * core.sizeT[0] * getEffectiveSizeC())  
     315    { 
    342316      if (core.sizeZ[0] == 1) core.sizeT[0]++; 
    343317      else if (core.sizeT[0] == 1) core.sizeZ[0]++; 
     
    395369    } 
    396370 
     371    core.rgb[0] = tiffReader[0].isRGB(); 
     372    core.littleEndian[0] = true; 
     373    core.interleaved[0] = false; 
     374 
    397375    store.setPixels( 
    398376      new Integer(core.sizeX[0]), 
  • trunk/loci/formats/in/OMEXMLReader.java

    r2583 r2584  
    6060  // -- Fields -- 
    6161 
    62   /** Current file. */ 
    63   protected RandomAccessStream in; 
    64  
    65   /** Flag indicating whether current file is little endian. */ 
    66   protected boolean[] littleEndian; 
    67  
    68   /** Number of image planes in the file. */ 
    69   protected int[] numImages; 
    70  
    7162  /** Number of bits per pixel. */ 
    7263  protected int[] bpp; 
     
    9081  } 
    9182 
    92   /* @see loci.formats.IFormatReader#getSeriesCount() */  
    93   public int getSeriesCount() throws FormatException, IOException { 
    94     return core.sizeX.length;  
    95   } 
    96  
    97   /* @see loci.formats.IFormatReader#getImageCount() */  
    98   public int getImageCount() throws FormatException, IOException { 
    99     return numImages[series]; 
    100   } 
    101  
    102   /* @see loci.formats.IFormatReader#isRGB() */  
    103   public boolean isRGB() throws FormatException, IOException { 
    104     return false; 
    105   } 
    106  
    107   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    108   public boolean isLittleEndian() throws FormatException, IOException { 
    109     return littleEndian[series]; 
    110   } 
    111  
    112   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    113   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    114     return false; 
    115   } 
    116  
    11783  /* @see loci.formats.IFormatReader#openBytes(int) */  
    11884  public byte[] openBytes(int no) throws FormatException, IOException { 
    119     if (no < 0 || no >= numImages[series]) { 
     85    if (no < 0 || no >= core.imageCount[series]) { 
    12086      throw new FormatException("Invalid image number: " + no); 
    12187    } 
     
    184150  public BufferedImage openImage(int no) throws FormatException, IOException { 
    185151    return ImageTools.makeImage(openBytes(no), core.sizeX[series], 
    186       core.sizeY[series], 1, false, bpp[series], littleEndian[series]); 
     152      core.sizeY[series], 1, false, bpp[series], core.littleEndian[series]); 
    187153  } 
    188154 
     
    191157    if (fileOnly && in != null) in.close(); 
    192158    else close(); 
    193   } 
    194  
    195   /* @see loci.formats.IFormatReader#close() */  
    196   public void close() throws FormatException, IOException { 
    197     if (in != null) in.close(); 
    198     in = null; 
    199     currentId = null; 
    200159  } 
    201160 
     
    252211    } 
    253212 
    254     littleEndian = new boolean[numDatasets]; 
    255213    offsets = new Vector[numDatasets]; 
    256214 
    257     for (int i=0; i<littleEndian.length; i++) { 
    258       littleEndian[i] = ((Boolean) endianness.get(i)).booleanValue(); 
     215    for (int i=0; i<numDatasets; i++) { 
    259216      offsets[i] = new Vector(); 
    260217    } 
     
    376333    core = new CoreMetadata(numDatasets); 
    377334 
    378     numImages = new int[numDatasets]; 
    379335    bpp = new int[numDatasets]; 
    380336    compression = new String[numDatasets]; 
     
    390346    for (int i=0; i<numDatasets; i++) { 
    391347      setSeries(i); 
     348       
     349      core.littleEndian[i] = ((Boolean) endianness.get(i)).booleanValue(); 
     350       
    392351      Integer ndx = new Integer(i); 
    393352      Integer w = null, h = null, t = null, z = null, c = null; 
     
    412371      core.sizeZ[i] = z.intValue(); 
    413372      core.sizeC[i] = c.intValue(); 
     373      core.rgb[i] = false; 
     374      core.interleaved[i] = false; 
    414375 
    415376      String type = pixType.toLowerCase(); 
     
    454415 
    455416      searchForData(expected, planes); 
    456       numImages[i] = offsets[i].size(); 
    457       if (numImages[i] < planes) { 
     417      core.imageCount[i] = offsets[i].size(); 
     418      if (core.imageCount[i] < planes) { 
    458419        // hope this doesn't happen too often 
    459420        in.seek(((Integer) offsets[i].get(0)).intValue()); 
    460421        searchForData(0, planes); 
    461         numImages[i] = offsets[i].size(); 
     422        core.imageCount[i] = offsets[i].size(); 
    462423      } 
    463424      buf = null; 
  • trunk/loci/formats/in/OpenlabRawReader.java

    r2583 r2584  
    4343  // -- Fields -- 
    4444 
    45   /** Current file. */ 
    46   protected RandomAccessStream in; 
    47  
    48   /** Number of image planes in the file. */ 
    49   protected int numImages = 0; 
    50  
    5145  /** Offset to each image's pixel data. */ 
    5246  protected int[] offsets; 
     
    6660    return (block[0] == 'O') && (block[1] == 'L') && (block[2] == 'R') && 
    6761      (block[3] == 'W'); 
    68   } 
    69  
    70   /* @see loci.formats.IFormatReader#getImageCount() */  
    71   public int getImageCount() throws FormatException, IOException { 
    72     return numImages; 
    73   } 
    74  
    75   /* @see loci.formats.IFormatReader#isRGB() */  
    76   public boolean isRGB() throws FormatException, IOException { 
    77     return core.sizeC[0] > 1; 
    78   } 
    79  
    80   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    81   public boolean isLittleEndian() throws FormatException, IOException { 
    82     return false; 
    83   } 
    84  
    85   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    86   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    87     return false; 
    8862  } 
    8963 
     
    158132    addMeta("Version", new Integer(version)); 
    159133 
    160     numImages = in.readInt(); 
    161     offsets = new int[numImages]; 
     134    core.imageCount[0] = in.readInt(); 
     135    offsets = new int[core.imageCount[0]]; 
    162136    offsets[0] = 12; 
    163137 
     
    184158    addMeta("Bytes per pixel", new Integer(bytesPerPixel)); 
    185159 
    186     for (int i=1; i<numImages; i++) { 
     160    for (int i=1; i<core.imageCount[0]; i++) { 
    187161      offsets[i] =  
    188162        offsets[i-1] + 288 + core.sizeX[0] * core.sizeY[0] * bytesPerPixel; 
     
    191165    bytesPerPixel = ((Integer) getMeta("Bytes per pixel")).intValue(); 
    192166 
    193     core.sizeZ[0] = numImages; 
     167    core.sizeZ[0] = core.imageCount[0]; 
    194168    core.sizeT[0] = 1; 
    195169    core.currentOrder[0] = "XYZTC"; 
     170    core.rgb[0] = core.sizeC[0] > 1; 
     171    core.interleaved[0] = false; 
     172    core.littleEndian[0] = false; 
    196173 
    197174    // The metadata store we're working with. 
  • trunk/loci/formats/in/OpenlabReader.java

    r2583 r2584  
    5757  // -- Fields -- 
    5858 
    59   /** Current file. */ 
    60   private RandomAccessStream in; 
    61  
    6259  /** LIFF version (should be 2 or 5). */ 
    6360  private int version; 
    64  
    65   /** Number of images in the file. */ 
    66   private int[] numImages; 
    6761 
    6862  /** Number of series. */ 
     
    8882      block[2] == -1 && block[3] == -1 && block[4] == 105 && 
    8983      block[5] == 109 && block[6] == 112 && block[7] == 114; 
    90   } 
    91  
    92   /* @see loci.formats.IFormatReader#getImageCount() */  
    93   public int getImageCount() throws FormatException, IOException { 
    94     return numImages[series]; 
    95   } 
    96  
    97   /* @see loci.formats.IFormatReader#isRGB() */  
    98   public boolean isRGB() throws FormatException, IOException { 
    99     return core.sizeC[series] > 1; 
    100   } 
    101  
    102   /* @see loci.formats.IFormatReader#getSeriesCount() */  
    103   public int getSeriesCount() throws FormatException, IOException { 
    104     return numSeries; 
    105   } 
    106  
    107   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    108   public boolean isLittleEndian() throws FormatException, IOException { 
    109     return false; 
    110   } 
    111  
    112   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    113   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    114     return true; 
    11584  } 
    11685 
     
    521490    core = new CoreMetadata(2); 
    522491 
    523     numImages = new int[2]; 
    524     numImages[0] = tmp.size(); 
     492    core.imageCount[0] = tmp.size(); 
    525493 
    526494    // determine if we have a multi-series file 
     
    602570      if (core.sizeC[0] == 1 && oldChannels == 1) core.sizeC[0] = 3; 
    603571 
    604       int oldImages = numImages[0]; 
    605       numImages = new int[1]; 
    606       numImages[0] = oldImages; 
     572      int oldImages = core.imageCount[0]; 
     573      core.imageCount = new int[1]; 
     574      core.imageCount[0] = oldImages; 
    607575      if (layerInfoList[0].size() == 0) layerInfoList[0] = layerInfoList[1]; 
    608576    } 
    609577    else { 
    610       numImages[0] = layerInfoList[0].size(); 
    611       numImages[1] = layerInfoList[1].size(); 
     578      core.imageCount[0] = layerInfoList[0].size(); 
     579      core.imageCount[1] = layerInfoList[1].size(); 
    612580      core.sizeC[0] = 1; 
    613581      core.sizeC[1] = 3; 
     
    624592    status("Populating metadata"); 
    625593 
    626     numSeries = numImages.length; 
     594    numSeries = core.imageCount.length; 
    627595 
    628596    int[] bpp = new int[numSeries]; 
     
    651619        new Integer(core.sizeC[i])); 
    652620      addMeta("Number of images (Series " + i + ")", 
    653         new Integer(numImages[i])); 
     621        new Integer(core.imageCount[i])); 
    654622    } 
    655623 
     
    661629      core.sizeT[i] += 1; 
    662630      core.currentOrder[i] = isRGB() ? "XYCZT" : "XYZCT"; 
     631      core.rgb[i] = core.sizeC[i] > 1; 
     632      core.interleaved[i] = true; 
     633      core.littleEndian[i] = false; 
    663634 
    664635      try { 
  • trunk/loci/formats/in/PerkinElmerReader.java

    r2583 r2584  
    4141  // -- Fields -- 
    4242 
    43   /** Number of images. */ 
    44   protected int numImages; 
    45  
    4643  /** Helper reader. */ 
    4744  protected TiffReader[] tiff; 
     
    6865  /* @see loci.formats.IFormatReader#isThisType(byte[]) */  
    6966  public boolean isThisType(byte[] block) { return false; } 
    70  
    71   /* @see loci.formats.IFormatReader#getImageCount() */  
    72   public int getImageCount() throws FormatException, IOException { 
    73     return numImages; 
    74   } 
    75  
    76   /* @see loci.formats.IFormatReader#isRGB() */  
    77   public boolean isRGB() throws FormatException, IOException { 
    78     return isTiff ? tiff[0].isRGB() : false;  
    79   } 
    80  
    81   /* @see loci.formats.IFormatReader#isLittleEndian() */  
    82   public boolean isLittleEndian() throws FormatException, IOException { 
    83     return isTiff ? tiff[0].isLittleEndian() : true; 
    84   } 
    85  
    86   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    87   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    88     return false; 
    89   } 
    9067 
    9168  /* @see loci.formats.IFormatReader#openBytes(int) */  
     
    348325    for (int i=0; i<files.length; i++) allFiles.add(files[i]); 
    349326 
    350     numImages = files.length; 
     327    core.imageCount[0] = files.length; 
    351328    RandomAccessStream read; 
    352329    byte[] data; 
    353330    StringTokenizer t; 
    354331 
    355     tiff = new TiffReader[numImages]; 
     332    tiff = new TiffReader[core.imageCount[0]]; 
    356333    for (int i=0; i<tiff.length; i++) { 
    357334      tiff[i] = new TiffReader(); 
     
    556533    else core.currentOrder[0] += "ZT"; // doesn't matter, since Z = T = 1 
    557534 
     535    core.rgb[0] = isTiff ? tiff[0].isRGB() : false; 
     536    core.interleaved[0] = false; 
     537    core.littleEndian[0] = isTiff ? tiff[0].isLittleEndian() : true; 
     538 
    558539    // Populate metadata store 
    559540 
  • trunk/loci/formats/in/PictReader.java

    r2583 r2584  
    7979  // -- Fields -- 
    8080 
    81   /** Current file. */ 
    82   protected RandomAccessStream in; 
    83  
    84   /** Flag indicating whether current file is little endian. */ 
    85   protected boolean little; 
    86  
    8781  /** Pixel bytes. */ 
    8882  protected byte[] bytes; 
    8983 
    90   /** Width of the image. */ 
    91   protected int width; 
    92  
    93   /** Height of the image. */ 
    94   protected int height; 
    95  
    9684  /** Number of bytes in a row of pixel data (variable). */ 
    9785  protected int rowBytes; 
     
    125113  // -- FormatReader API methods -- 
    126114 
    127   /** Checks if the given block is a valid header for a PICT file. */ 
     115  /* @see loci.formats.IFormatReader#isThisType(byte[]) */  
    128116  public boolean isThisType(byte[] block) { 
    129117    if (block.length < 528) return false; 
    130     return true; 
    131   } 
    132  
    133   /** Determines the number of images in the given PICT file. */ 
    134   public int getImageCount() throws FormatException, IOException { 
    135     return 1; 
    136   } 
    137  
    138   /** Checks if the images in the file are RGB. */ 
    139   public boolean isRGB() throws FormatException, IOException { 
    140     return true; 
    141   } 
    142  
    143   /** Return true if the data is in little-endian format. */ 
    144   public boolean isLittleEndian() throws FormatException, IOException { 
    145     return little; 
    146   } 
    147  
    148   /** Returns whether or not the channels are interleaved. */ 
    149   public boolean isInterleaved(int subC) 
    150     throws FormatException, IOException 
    151   { 
    152118    return true; 
    153119  } 
     
    188154    status("Populating metadata"); 
    189155 
    190     little = false; 
     156    core.littleEndian[0] = false; 
    191157 
    192158    // skip the header and read in the remaining bytes 
     
    208174    core.sizeT[0] = 1; 
    209175    core.currentOrder[0] = "XYCZT"; 
     176    core.rgb[0] = true; 
     177    core.interleaved[0] = true; 
     178    core.imageCount[0] = 1; 
    210179 
    211180    // The metadata store we're working with. 
     
    217186      new Integer(core.sizeZ[0]), new Integer(core.sizeC[0]), 
    218187      new Integer(core.sizeT[0]), new Integer(core.pixelType[0]),  
    219       new Boolean(!little), core.currentOrder[0], null, null); 
     188      new Boolean(!core.littleEndian[0]), core.currentOrder[0], null, null); 
    220189    for (int i=0; i<core.sizeC[0]; i++) { 
    221190      store.setLogicalChannel(i, null, null, null, null, null, null, null); 
     
    230199      throw new FormatException("Need 10 bytes to calculate dimension"); 
    231200    } 
    232     int w = DataTools.bytesToInt(stuff, 6, 2, little); 
    233     int h = DataTools.bytesToInt(stuff, 8, 2, little); 
     201    int w = DataTools.bytesToInt(stuff, 6, 2, core.littleEndian[0]); 
     202    int h = DataTools.bytesToInt(stuff, 8, 2, core.littleEndian[0]); 
    234203    if (debug) debug("getDimensions: " + w + " x " + h); 
    235204    return new Dimension(h, w); 
     
    259228    // combine everything in the strips Vector 
    260229 
    261     if ((height*4 < strips.size()) && (((strips.size() / 3) % height) != 0)) { 
    262       height = strips.size(); 
     230    if ((core.sizeY[0]*4 < strips.size()) && (((strips.size() / 3) %  
     231      core.sizeY[0]) != 0))  
     232    { 
     233      core.sizeY[0] = strips.size(); 
    263234    } 
    264235 
     
    269240    if (lookup != null) { 
    270241      // 8 bit data 
    271       short[][] data = new short[3][height * width]; 
     242      short[][] data = new short[3][core.sizeY[0] * core.sizeX[0]]; 
    272243 
    273244      byte[] row; 
    274245 
    275       for (int i=0; i<height; i++) { 
     246      for (int i=0; i<core.sizeY[0]; i++) { 
    276247        row = (byte[]) strips.get(i); 
    277248 
    278249        for (int j=0; j<row.length; j++) { 
    279           if (j < width) { 
     250          if (j < core.sizeX[0]) { 
    280251            int ndx = row[j]; 
    281252            if (ndx < 0) ndx += lookup[0].length; 
    282253            ndx = ndx % lookup[0].length; 
    283254 
    284             int outIndex = i*width + j; 
     255            int outIndex = i*core.sizeX[0] + j; 
    285256            if (outIndex >= data[0].length) outIndex = data[0].length - 1; 
    286257 
     
    294265 
    295266      if (debug) { 
    296         debug("openBytes: 8-bit data, " + width + " x " + height + 
    297           ", length=" + data.length + "x" + data[0].length); 
    298       } 
    299       return ImageTools.makeImage(data, width, height); 
    300     } 
    301     else if (height*3 == strips.size()) { 
     267        debug("openBytes: 8-bit data, " + core.sizeX[0] + " x " +  
     268          core.sizeY[0] + ", length=" + data.length + "x" + data[0].length); 
     269      } 
     270      return ImageTools.makeImage(data, core.sizeX[0], core.sizeY[0]); 
     271    } 
     272    else if (core.sizeY[0]*3 == strips.size()) { 
    302273      // 24 bit data 
    303       byte[][] data = new byte[3][width * height]; 
     274      byte[][] data = new byte[3][core.sizeX[0] * core.sizeY[0]]; 
    304275 
    305276      int outIndex = 0; 
    306       for (int i=0; i<3*height; i+=3) { 
     277      for (int i=0; i<3*core.sizeY[0]; i+=3) { 
    307278        byte[] c0 = (byte[]) strips.get(i); 
    308279        byte[] c1 = (byte[]) strips.get(i+1); 
     
    311282        System.arraycopy(c1, 0, data[1], outIndex, c1.length); 
    312283        System.arraycopy(c2, 0, data[2], outIndex, c2.length); 
    313         outIndex += width; 
     284        outIndex += core.sizeX[0]; 
    314285      } 
    315286 
    316287      if (debug) { 
    317         debug("openBytes: 24-bit data, " + width + " x " + height + 
    318           ", length=" + data.length + "x" + data[0].length); 
    319       } 
    320       return ImageTools.makeImage(data, width, height); 
    321     } 
    322     else if (height*4 == strips.size()) { 
     288        debug("openBytes: 24-bit data, " + core.sizeX[0] + " x " +  
     289          core.sizeY[0] + ", length=" + data.length + "x" + data[0].length); 
     290      } 
     291      return ImageTools.makeImage(data, core.sizeX[0], core.sizeY[0]); 
     292    } 
     293    else if (core.sizeY[0]*4 == strips.size()) { 
    323294      // 32 bit data 
    324       byte[][] data = new byte[3][width * height]; 
     295      byte[][] data = new byte[3][core.sizeX[0] * core.sizeY[0]]; 
    325296 
    326297      int outIndex = 0; 
    327       for (int i=0; i<4*height; i+=4) { 
     298      for (int i=0; i<4*core.sizeY[0]; i+=4) { 
    328299        //byte[] a = (byte[]) strips.get(i); 
    329300        byte[] r = (byte[]) strips.get(i+1); 
     
    334305        System.arraycopy(b, 0, data[2], outIndex, b.length); 
    335306        //System.arraycopy(a, 0, data[3], outIndex, a.length); 
    336         outIndex += width; 
     307        outIndex += core.sizeX[0]; 
    337308      } 
    338309 
    339310      if (debug) { 
    340         debug("openBytes: 32-bit data, " + width + " x " + height + 
    341           ", length=" + data.length + "x" + data[0].length); 
    342       } 
    343       return ImageTools.makeImage(data, width, height); 
     311        debug("openBytes: 32-bit data, " + core.sizeX[0] + " x " +  
     312          core.sizeY[0] + ", length=" + data.length + "x" + data[0].length); 
     313      } 
     314      return ImageTools.makeImage(data, core.sizeX[0], core.sizeY[0]); 
    344315    } 
    345316    else { 
    346317      // 16 bit data 
    347       short[] data = new short[3 * height * width]; 
     318      short[] data = new short[3 * core.sizeY[0] * core.sizeX[0]]; 
    348319 
    349320      int outIndex = 0; 
    350       for (int i=0; i<height; i++) { 
     321      for (int i=0; i<core.sizeY[0]; i++) { 
    351322        int[] row = (int[]) strips.get(i); 
    352323 
    353324        for (int j=0; j<row.length; j++, outIndex+=3) { 
    354           if (j < width) { 
     325          if (j < core.sizeX[0]) { 
    355326            if (outIndex >= data.length - 2) break; 
    356327            int s0 = (row[j] & 0x1f); 
     
    366337 
    367338      if (debug) { 
    368         debug("openBytes: 16-bit data, " + width + " x " + height + 
    369           ", length=" + data.length); 
    370       } 
    371       return ImageTools.makeImage(data, width, height, 3, true); 
     339        debug("openBytes: 16-bit data, " + core.sizeX[0] + " x " +  
     340          core.sizeY[0] + ", length=" + data.length); 
     341      } 
     342      return ImageTools.makeImage(data, core.sizeX[0], core.sizeY[0], 3, true); 
    372343    } 
    373344  } 
     
    385356        // skip over frame 
    386357        pt += 8; 
    387         int verOpcode = DataTools.bytesToInt(bytes, pt, 1, little); 
     358        int verOpcode =  
     359          DataTools.bytesToInt(bytes, pt, 1, core.littleEndian[0]); 
    388360        pt++; 
    389         int verNumber = DataTools.bytesToInt(bytes, pt, 1, little); 
     361        int verNumber =  
     362          DataTools.bytesToInt(bytes, pt, 1, core.littleEndian[0]); 
    390363        pt++; 
    391364 
     
    393366        else if (verOpcode == 0x00 && verNumber == 0x11) { 
    394367          versionOne = false; 
    395           int verNumber2 = DataTools.bytesToInt(bytes, pt, 2, little); 
     368          int verNumber2 =  
     369            DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    396370          pt += 2; 
    397371 
     
    411385      case STATE2: 
    412386        if (versionOne) { 
    413           opcode = DataTools.bytesToInt(bytes, pt, 1, little); 
     387          opcode = DataTools.bytesToInt(bytes, pt, 1, core.littleEndian[0]); 
    414388          pt++; 
    415389        } 
     
    420394            pt++; 
    421395          } 
    422           opcode = DataTools.bytesToInt(bytes, pt, 2, little); 
     396          opcode = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    423397          pt += 2; 
    424398        } 
     
    441415        break; 
    442416      case PICT_CLIP_RGN: 
    443         int x = DataTools.bytesToInt(bytes, pt, 2, little); 
     417        int x = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    444418        pt += x; 
    445419        break; 
    446420      case PICT_LONGCOMMENT: 
    447421        pt += 2; 
    448         x = DataTools.bytesToInt(bytes, pt, 2, little); 
     422        x = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    449423        pt += x + 2; 
    450424        break; 
     
    465439    } 
    466440    else { 
    467       rowBytes = DataTools.bytesToInt(bytes, pt, 2, little); 
     441      rowBytes = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    468442      pt += 2; 
    469443      if (versionOne || (rowBytes & 0x8000) == 0) handleBitmap(opcode); 
     
    484458    // read the bitmap data -- 3 rectangles + mode 
    485459 
    486     int tlY = DataTools.bytesToInt(bytes, pt, 2, little); 
     460    int tlY = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    487461    pt += 2; 
    488     int tlX = DataTools.bytesToInt(bytes, pt, 2, little); 
     462    int tlX = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    489463    pt += 2; 
    490     int brY = DataTools.bytesToInt(bytes, pt, 2, little); 
     464    int brY = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    491465    pt += 2; 
    492     int brX = DataTools.bytesToInt(bytes, pt, 2, little); 
     466    int brX = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    493467    pt += 2; 
    494468 
     
    496470    pt += 18; 
    497471 
    498     width = brX - tlX; 
    499     height = brY - tlY; 
     472    core.sizeX[0] = brX - tlX; 
     473    core.sizeY[0] = brY - tlY; 
    500474 
    501475    // allocate enough space to handle compressed data length for rowBytes 
     
    504478      buf = new byte[rowBytes + 1 + rowBytes/128]; 
    505479      uBuf = new byte[rowBytes]; 
    506       outBuf = new byte[width]; 
     480      outBuf = new byte[core.sizeX[0]]; 
    507481    } 
    508482    catch (NegativeArraySizeException n) { 
     
    510484    } 
    511485 
    512     for (row=0; row < height; ++row) { 
     486    for (row=0; row < core.sizeY[0]; ++row) { 
    513487      if (rowBytes < 8) {  // data is not compressed 
    514488        System.arraycopy(bytes, pt, buf, 0, rowBytes); 
     
    522496        int rawLen; 
    523497        if (rowBytes > 250) { 
    524           rawLen = DataTools.bytesToInt(bytes, pt, 2, little); 
     498          rawLen = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    525499          pt += 2; 
    526500        } 
    527501        else { 
    528           rawLen = DataTools.bytesToInt(bytes, pt, 1, little); 
     502          rawLen = DataTools.bytesToInt(bytes, pt, 1, core.littleEndian[0]); 
    529503          pt++; 
    530504        } 
     
    568542 
    569543      // read the bounding box 
    570       int tlY = DataTools.bytesToInt(bytes, pt, 2, little); 
    571       pt += 2; 
    572       int tlX = DataTools.bytesToInt(bytes, pt, 2, little); 
    573       pt += 2; 
    574       int brY = DataTools.bytesToInt(bytes, pt, 2, little); 
    575       pt += 2; 
    576       int brX = DataTools.bytesToInt(bytes, pt, 2, little); 
     544      int tlY = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
     545      pt += 2; 
     546      int tlX = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
     547      pt += 2; 
     548      int brY = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
     549      pt += 2; 
     550      int brX = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    577551      pt += 2; 
    578552 
     
    581555      pt += 16; 
    582556 
    583       pixelSize = DataTools.bytesToInt(bytes, pt, 2, little); 
    584       pt += 2; 
    585       compCount = DataTools.bytesToInt(bytes, pt, 2, little); 
     557      pixelSize = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
     558      pt += 2; 
     559      compCount = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    586560      pt += 16; // reserved 
    587561 
    588       width = brX - tlX; 
    589       height = brY - tlY; 
     562      core.sizeX[0] = brX - tlX; 
     563      core.sizeY[0] = brY - tlY; 
    590564 
    591565      // rowBytes doesn't exist, so set it to its logical value 
    592566      switch (pixelSize) { 
    593567        case 32: 
    594           rowBytes = width * compCount; 
     568          rowBytes = core.sizeX[0] * compCount; 
    595569          break; 
    596570        case 16: 
    597           rowBytes = width * 2; 
     571          rowBytes = core.sizeX[0] * 2; 
    598572          break; 
    599573        default: 
     
    604578      rowBytes &= 0x3fff;  // mask off flags 
    605579 
    606       int tlY = DataTools.bytesToInt(bytes, pt, 2, little); 
    607       pt += 2; 
    608       int tlX = DataTools.bytesToInt(bytes, pt, 2, little); 
    609       pt += 2; 
    610       int brY = DataTools.bytesToInt(bytes, pt, 2, little); 
    611       pt += 2; 
    612       int brX = DataTools.bytesToInt(bytes, pt, 2, little); 
     580      int tlY = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
     581      pt += 2; 
     582      int tlX = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
     583      pt += 2; 
     584      int brY = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
     585      pt += 2; 
     586      int brX = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    613587      pt += 2; 
    614588 
     
    616590      pt += 18; 
    617591 
    618       pixelSize = DataTools.bytesToInt(bytes, pt, 2, little); 
    619       pt += 2; 
    620       compCount = DataTools.bytesToInt(bytes, pt, 2, little); 
     592      pixelSize = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
     593      pt += 2; 
     594      compCount = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    621595      pt += 2; 
    622596 
     
    627601 
    628602      pt += 4; 
    629       int flags = DataTools.bytesToInt(bytes, pt, 2, little); 
    630       pt += 2; 
    631       int count = DataTools.bytesToInt(bytes, pt, 2, little); 
     603      int flags = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
     604      pt += 2; 
     605      int count = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    632606      pt += 2; 
    633607 
     
    636610 
    637611      for (int i=0; i<count; i++) { 
    638         int index = DataTools.bytesToInt(bytes, pt, 2, little); 
     612        int index = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    639613        pt += 2; 
    640614        if ((flags & 0x8000) != 0) index = i; 
    641         lookup[0][index] = DataTools.bytesToShort(bytes, pt, 2, little); 
     615        lookup[0][index] =  
     616          DataTools.bytesToShort(bytes, pt, 2, core.littleEndian[0]); 
    642617        pt += 2; 
    643         lookup[1][index] = DataTools.bytesToShort(bytes, pt, 2, little); 
     618        lookup[1][index] =  
     619          DataTools.bytesToShort(bytes, pt, 2, core.littleEndian[0]); 
    644620        pt += 2; 
    645         lookup[2][index] = DataTools.bytesToShort(bytes, pt, 2, little); 
     621        lookup[2][index] =  
     622          DataTools.bytesToShort(bytes, pt, 2, core.littleEndian[0]); 
    646623        pt += 2; 
    647624      } 
    648625 
    649       width = brX - tlX; 
    650       height = brY - tlY; 
     626      core.sizeX[0] = brX - tlX; 
     627      core.sizeY[0] = brY - tlY; 
    651628    } 
    652629 
     
    679656    bufSize = rBytes; 
    680657 
    681     outBufSize = width; 
     658    outBufSize = core.sizeX[0]; 
    682659 
    683660    // allocate buffers 
     
    685662    switch (pixelSize) { 
    686663      case 32: 
    687         if (!compressed) uBufI = new int[width]; 
     664        if (!compressed) uBufI = new int[core.sizeX[0]]; 
    688665        else uBuf = new byte[bufSize]; 
    689666        break; 
    690667      case 16: 
    691         uBufI = new int[width]; 
     668        uBufI = new int[core.sizeX[0]]; 
    692669        break; 
    693670      case 8: 
     
    705682      } 
    706683      buf = new byte[bufSize]; 
    707       for (int row=0; row<height; row++) { 
     684      for (int row=0; row<core.sizeY[0]; row++) { 
    708685        System.arraycopy(bytes, pt, buf, 0, rBytes); 
    709686 
    710687        switch (pixelSize) { 
    711688          case 16: 
    712             for (int i=0; i<width; i++) { 
     689            for (int i=0; i<core.sizeX[0]; i++) { 
    713690              uBufI[i] = ((buf[i*2] & 0xff) << 8) + (buf[i*2+1] & 0xff); 
    714691            } 
     
    730707      } 
    731708      buf = new byte[bufSize + 1 + bufSize / 128]; 
    732       for (int row=0; row<height; row++) { 
     709      for (int row=0; row<core.sizeY[0]; row++) { 
    733710        if (rBytes > 250) { 
    734           rawLen = DataTools.bytesToInt(bytes, pt, 2, little); 
     711          rawLen = DataTools.bytesToInt(bytes, pt, 2, core.littleEndian[0]); 
    735712          pt += 2; 
    736713        } 
    737714        else { 
    738           rawLen = DataTools.bytesToInt(bytes, pt, 1, little); 
     715          rawLen = DataTools.bytesToInt(bytes, pt, 1, core.littleEndian[0]); 
    739716          pt++; 
    740717        } 
     
    755732 
    756733        if (pixelSize == 16) { 
    757           uBufI = new int[width]; 
     734          uBufI = new int[core.sizeX[0]]; 
    758735          unpackBits(buf, uBufI); 
    759736          strips.add(uBufI); 
     
    779756            //System.arraycopy(uBuf, offset, newBuf, 0, width); 
    780757            strips.add(newBuf); 
    781             offset += width; 
     758            offset += core.sizeX[0]; 
    782759          } 
    783760 
    784761          // red channel 
    785           newBuf = new byte[width]; 
    786           System.arraycopy(uBuf, offset, newBuf, 0, width); 
     762          newBuf = new byte[core.sizeX[0]]; 
     763          System.arraycopy(uBuf, offset, newBuf, 0, core.sizeX[0]); 
    787764          strips.add(newBuf); 
    788           offset += width; 
     765          offset += core.sizeX[0]; 
    789766 
    790767          // green channel 
    791           newBuf = new byte[width]; 
    792           System.arraycopy(uBuf, offset, newBuf, 0, width); 
     768          newBuf = new byte[core.sizeX[0]]; 
     769          System.arraycopy(uBuf, offset, newBuf, 0, core.sizeX[0]); 
    793770          strips.add(newBuf); 
    794           offset += width; 
     771          offset += core.sizeX[0]; 
    795772 
    796773          // blue channel 
    797           newBuf = new byte[width]; 
    798           System.arraycopy(uBuf, offset, newBuf, 0, width); 
     774          newBuf = new byte[core.sizeX[0]]; 
     775          System.arraycopy(uBuf, offset, newBuf, 0, core.sizeX[0]); 
    799776          strips.add(newBuf); 
    800777        } 
  • trunk/loci/formats/in/PrairieReader.java

    r2583 r2584  
    4848 
    4949  // -- Fields -- 
    50  
    51   /** Number of images */ 
    52   private int numImages; 
    5350 
    5451  /** List of files in the current dataset */ 
     
    137134  } 
    138135 
    139   /* @see loci.formats.IFormatReader#getImageCount(String) */ 
    140   public int getImageCount() throws FormatException, IOException { 
    141     return numImages; 
    142   } 
    143  
    144   /* @see loci.formats.IFormatReader#isRGB(String) */ 
    145   public boolean isRGB() throws FormatException, IOException { 
    146     return false; 
    147   } 
    148  
    149   /* @see loci.formats.IFormatReader#isLittleEndian(String) */ 
    150   public boolean isLittleEndian() throws FormatException, IOException { 
    151     return tiff.isLittleEndian(); 
    152   } 
    153  
    154   /* @see loci.formats.IFormatReader#isInterleaved(String) */ 
    155   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    156     return false; 
    157   } 
    158  
    159136  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    160137  public byte[] openBytes(int no) throws FormatException, IOException { 
     
    245222      Vector f = new Vector(); 
    246223      int fileIndex = 1; 
    247       if (id.endsWith(".xml")) numImages = 0; 
     224      if (id.endsWith(".xml")) core.imageCount[0] = 0; 
    248225 
    249226      String pastPrefix = ""; 
     
    254231 
    255232          String prefix = el.substring(0, el.indexOf(" ")); 
    256           if (prefix.equals("File")) numImages++; 
     233          if (prefix.equals("File")) core.imageCount[0]++; 
    257234          if (prefix.equals("Frame")) { 
    258235            zt++; 
     
    313290        core.sizeZ[0] = isZ ? zt : 1; 
    314291        core.sizeT[0] = isZ ? 1 : zt; 
    315         core.sizeC[0] = numImages / (core.sizeZ[0] * core.sizeT[0]); 
     292        core.sizeC[0] = core.imageCount[0] / (core.sizeZ[0] * core.sizeT[0]); 
    316293        core.currentOrder[0] = "XYC" + (isZ ? "ZT" : "TZ"); 
    317294        core.pixelType[0] = FormatTools.UINT16; 
     295        core.rgb[0] = false; 
     296        core.interleaved[0] = false; 
     297        core.littleEndian[0] = tiff.isLittleEndian(); 
    318298 
    319299        float pixSizeX = 
  • trunk/loci/formats/in/QTReader.java

    r2583 r2584  
    3131import loci.formats.*; 
    3232import loci.formats.codec.ByteVector; 
     33 
     34// TODO : move decompression logic to loci.formats.codec 
    3335 
    3436/** 
     
    177179  // -- Fields -- 
    178180 
    179   /** Current file. */ 
    180   private RandomAccessStream in; 
    181  
    182   /** Flag indicating whether the current file is little endian. */ 
    183   private boolean little = false; 
    184  
    185   /** Number of images in the file. */ 
    186   private int numImages; 
    187  
    188181  /** Offset to start of pixel data. */ 
    189182  private int pixelOffset; 
     
    257250  public boolean isThisType(byte[] block) { 
    258251    return false; 
    259   } 
    260  
    261   /* @see loci.formats.IFormatReader#getImageCount(String) */  
    262   public int getImageCount() throws FormatException, IOException { 
    263     return numImages; 
    264   } 
    265  
    266   /* @see loci.formats.IFormatReader#isRGB(String) */  
    267   public boolean isRGB() throws FormatException, IOException { 
    268     return bitsPerPixel < 40; 
    269   } 
    270  
    271   /* @see loci.formats.IFormatReader#isLittleEndian(String) */  
    272   public boolean isLittleEndian() throws FormatException, IOException { 
    273     return little; 
    274   } 
    275  
    276   /* @see loci.formats.IFormatReader#isInterleaved(String, int) */  
    277   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    278     return true; 
    279252  } 
    280253 
     
    530503      if (bpp == 3 || bpp == 4 || bpp == 5) bpp = 1; 
    531504      b = ImageTools.makeImage(openBytes(no), core.sizeX[0], 
    532         core.sizeY[0], core.sizeC[0], false, bpp, little); 
     505        core.sizeY[0], core.sizeC[0], false, bpp, core.littleEndian[0]); 
    533506    } 
    534507    return b; 
     
    543516  /* @see loci.formats.IFormatReader#close() */  
    544517  public void close() throws FormatException, IOException { 
    545     if (in != null) in.close(); 
    546     in = null; 
    547     currentId = null; 
     518    super.close();  
    548519    prevPixels = null; 
    549520  } 
     
    560531    status("Parsing tags");  
    561532    parse(0, 0, in.length()); 
    562     numImages = offsets.size(); 
     533    core.imageCount[0] = offsets.size(); 
    563534 
    564535    status("Populating metadata"); 
     
    588559    core.sizeZ[0] = 1; 
    589560    core.sizeC[0] = bitsPerPixel < 40 ? 3 : 1; 
    590     core.sizeT[0] = numImages; 
     561    core.sizeT[0] = core.imageCount[0]; 
    591562    core.currentOrder[0] = "XYCZT"; 
     563    core.rgb[0] = bitsPerPixel < 40; 
     564    core.interleaved[0] = true; 
     565    core.littleEndian[0] = false; 
    592566 
    593567    // The metadata store we're working with. 
     
    601575      new Integer(core.sizeT[0]), 
    602576      new Integer(core.pixelType[0]), 
    603       new Boolean(!little), 
     577      new Boolean(!core.littleEndian[0]), 
    604578      core.currentOrder[0],  
    605579      null, 
     
    629603        stripHeader(); 
    630604        parse(0, 0, in.length()); 
    631         numImages = offsets.size(); 
     605        core.imageCount[0] = offsets.size(); 
    632606        return; 
    633607      } 
     
    640614          stripHeader(); 
    641615          parse(0, 0, in.length()); 
    642           numImages = offsets.size(); 
     616          core.imageCount[0] = offsets.size(); 
    643617          return; 
    644618        } 
     
    649623            stripHeader(); 
    650624            parse(0, 0, in.length()); 
    651             numImages = offsets.size(); 
     625            core.imageCount[0] = offsets.size(); 
    652626            return; 
    653627          } 
     
    787761          in.readInt(); 
    788762          int numPlanes = in.readInt(); 
    789           if (numPlanes != numImages) { 
     763          if (numPlanes != core.imageCount[0]) { 
    790764            in.seek(in.getFilePointer() - 4); 
    791765            int off = in.readInt(); 
    792766            offsets.add(new Integer(off)); 
    793             for (int i=1; i<numImages; i++) { 
     767            for (int i=1; i<core.imageCount[0]; i++) { 
    794768              if ((chunkSizes.size() > 0) && (i < chunkSizes.size())) { 
    795769                rawSize = ((Integer) chunkSizes.get(i)).intValue(); 
    796770              } 
    797               else i = numImages; 
     771              else i = core.imageCount[0]; 
    798772              off += rawSize; 
    799773              offsets.add(new Integer(off)); 
     
    841815          in.readInt(); 
    842816          rawSize = in.readInt(); 
    843           numImages = in.readInt(); 
     817          core.imageCount[0] = in.readInt(); 
    844818 
    845819          if (rawSize == 0) { 
    846820            in.seek(in.getFilePointer() - 4); 
    847             for (int b=0; b<numImages; b++) { 
     821            for (int b=0; b<core.imageCount[0]; b++) { 
    848822              chunkSizes.add(new Integer(in.readInt())); 
    849823            } 
     
    10871061 
    10881062  /** Uncompresses a MJPEG-B compressed image plane. */ 
    1089   public BufferedImage mjpbUncompress(byte[] input) throws FormatException { 
     1063  public BufferedImage mjpbUncompress(byte[] input)  
     1064    throws FormatException, IOException 
     1065  { 
    10901066    byte[] raw = null; 
    10911067    byte[] raw2 = null; 
    1092     int pt = 16; // pointer into the compressed data 
     1068 
     1069    RandomAccessStream stream = new RandomAccessStream(input); 
     1070    stream.skipBytes(16); 
    10931071 
    10941072    // official documentation at 
     
    11181096    // contains some interesting notes on why Apple chose to define this codec 
    11191097 
    1120     pt += 4; 
    1121     if (pt >= input.length) pt = 0; 
     1098    stream.skipBytes(4);  
     1099    if (stream.getFilePointer() >= stream.length()) stream.seek(0); 
     1100 
     1101    boolean hasID = stream.readChar() == 'm' && stream.readChar() == 'j' && 
     1102      stream.readChar() == 'p' && stream.readChar() == 'g'; 
     1103    stream.seek(stream.getFilePointer() - 20); 
     1104    if (!hasID) { 
     1105      hasID = stream.readChar() == 'm' && stream.readChar() == 'j' && 
     1106        stream.readChar() == 'p' && stream.readChar() == 'g';  
     1107    } 
     1108    stream.skipBytes(12); 
     1109    stream.order(core.littleEndian[0]); 
    11221110 
    11231111    // most MJPEG-B planes don't have this identifier 
    1124     if (!(input[pt] != 'm' || input[pt+1] != 'j' || input[pt+2] != 'p' || 
    1125       input[pt+3] != 'g') || !(input[pt-16] != 'm' || input[pt-15] != 'j' || 
    1126       input[pt-14] != 'p' || input[pt-13] != 'g')) 
    1127     { 
     1112    if (hasID) {  
    11281113      int extra = 16; 
    1129       if (input[pt-16] == 'm') { 
    1130         pt = 4; 
     1114      stream.seek(stream.getFilePointer() - 16);  
     1115      if (stream.readChar() == 'm') { 
     1116        stream.seek(4);  
    11311117        extra = 0; 
    11321118      } 
    1133       pt += 4; 
    1134  
    1135       // number of compressed bytes (minus padding) 
    1136       pt += 4; 
    1137  
    1138       // number of compressed bytes (including padding) 
    1139       pt += 4; 
     1119      else stream.skipBytes(16); 
     1120      stream.skipBytes(12); 
    11401121 
    11411122      // offset to second field 
    1142       int offset = DataTools.bytesToInt(input, pt, 4, little) + extra; 
    1143       pt += 4; 
     1123      int offset = stream.readInt() + extra; 
    11441124 
    11451125      // offset to quantization table 
    1146       int quantOffset = DataTools.bytesToInt(input, pt, 4, little) + extra; 
    1147       pt += 4; 
     1126      int quantOffset = stream.readInt() + extra; 
    11481127 
    11491128      // offset to Huffman table 
    1150       int huffmanOffset = DataTools.bytesToInt(input, pt, 4, little) + extra; 
    1151       pt += 4; 
     1129      int huffmanOffset = stream.readInt() + extra; 
    11521130 
    11531131      // offset to start of frame 
    1154       int sof = DataTools.bytesToInt(input, pt, 4, little) + extra; 
    1155       pt += 4; 
     1132      int sof = stream.readInt() + extra; 
    11561133 
    11571134      // offset to start of scan 
    1158       int sos = DataTools.bytesToInt(input, pt, 4, little) + extra; 
    1159       pt += 4; 
     1135      int sos = stream.readInt() + extra; 
    11601136 
    11611137      // offset to start of data 
    1162       int sod = DataTools.bytesToInt(input, pt, 4, little) + extra; 
    1163       pt += 4; 
     1138      int sod = stream.readInt() + extra; 
    11641139 
    11651140      // skip over the quantization table, if it exists 
    11661141      if (quantOffset != 0) { 
    1167         pt = quantOffset; 
    1168         int length = DataTools.bytesToInt(input, pt, 2, little); 
    1169         pt += length; 
     1142        stream.seek(quantOffset);  
     1143        int length = stream.readShort(); 
     1144        stream.skipBytes(length - 2); 
    11701145      } 
    11711146 
    11721147      // skip over the Huffman table, if it exists 
    11731148      if (huffmanOffset != 0) { 
    1174         pt = huffmanOffset; 
    1175         int length = DataTools.bytesToInt(input, pt, 2, little); 
    1176         pt += length; 
     1149        stream.seek(huffmanOffset);  
     1150        int length = stream.readShort(); 
     1151        stream.skipBytes(length - 2);  
    11771152      } 
    11781153 
    11791154      // skip to the frame header 
    1180       pt = sof; 
    1181  
    1182       // read sof header 
    1183       // we can skip over the first 7 bytes (length, bps, height, width) 
    1184       pt += 7; 
     1155      stream.seek(sof + 7); 
    11851156 
    11861157      // number of channels 
    1187       int channels = DataTools.bytesToInt(input, pt, 1, little); 
    1188       pt++; 
     1158      int channels = stream.read(); 
    11891159 
    11901160      int[] sampling = new int[channels]; 
    11911161      for (int i=0; i<channels; i++) { 
    1192         pt++; 
    1193         sampling[i] = DataTools.bytesToInt(input, pt, 1, little); 
    1194         pt += 2; 
     1162        stream.read();  
     1163        sampling[i] = stream.read();  
    11951164      } 
    11961165 
    11971166      // skip to scan header 
    1198       pt = sos; 
    1199  
    1200       // we can skip over the first 3 bytes (length, number of channels) 
    1201       pt += 3; 
     1167      stream.seek(sos + 3);  
     1168 
    12021169      int[] tables = new int[channels]; 
    12031170      for (int i=0; i<channels; i++) { 
    1204         pt++; 
    1205         tables[i] = DataTools.bytesToInt(input, pt, 1, little); 
    1206         pt++; 
    1207       } 
    1208       pt += 3; 
    1209  
     1171        stream.read();  
     1172        tables[i] = stream.read(); 
     1173      } 
     1174       
    12101175      // now we can finally read this field's data 
    1211       pt = sod; 
    1212  
    1213       int numBytes = offset - pt; 
    1214       if (offset == 0) numBytes = input.length - pt; 
     1176      stream.seek(sod + 3); 
     1177 
     1178      int numBytes = offset - stream.getFilePointer(); 
     1179      if (offset == 0) numBytes = input.length - stream.getFilePointer(); 
    12151180      raw = new byte[numBytes]; 
    1216       System.arraycopy(input, pt, raw, 0, raw.length); 
     1181      System.arraycopy(input, stream.getFilePointer(), raw, 0, raw.length); 
    12171182 
    12181183      // get the second field 
     
    12261191 
    12271192      if (offset != 0) { 
    1228         pt = offset; 
    1229  
    1230         pt += 4; // reserved = 0 
    1231         pt += 4; // 'mjpg' tag 
    1232         pt += 4; // field size 
    1233         pt += 4; // padded field size 
    1234         pt += 4; // offset to next field = 0 
    1235         pt += 4; // quantization table offset 
    1236         pt += 4; // Huffman table offset 
    1237         pt += 4; // sof offset 
    1238         pt += 4; // sos offset 
    1239  
    1240         pt += DataTools.bytesToInt(input, pt, 4, little); 
    1241         pt -= 36; // HACK 
    1242  
    1243         numBytes = input.length - pt; 
     1193        stream.seek(offset); 
     1194        stream.skipBytes(36); 
     1195 
     1196        stream.skipBytes(stream.readInt() - 36); 
     1197 
     1198        numBytes = input.length - stream.getFilePointer(); 
    12441199        raw2 = new byte[numBytes]; 
    1245         System.arraycopy(input, pt, raw2, 0, raw2.length); 
     1200        System.arraycopy(input, stream.getFilePointer(), raw2, 0, raw2.length); 
    12461201      } 
    12471202    } 
     
    14871442    // scanlines to uncompress 
    14881443 
    1489     int header = DataTools.bytesToInt(input, 4, 2, little); 
     1444    int header = DataTools.bytesToInt(input, 4, 2, core.littleEndian[0]); 
    14901445    int off = 0; // offset into output 
    14911446    int start = 0; 
     
    14981453 
    14991454    if ((header & 0x0008) == 0x0008) { 
    1500       start = DataTools.bytesToInt(input, pt, 2, little); 
     1455      start = DataTools.bytesToInt(input, pt, 2, core.littleEndian[0]); 
    15011456      // skip 2 bytes 
    15021457      pt += 4; 
    1503       numLines = DataTools.bytesToInt(input, pt, 2, little); 
     1458      numLines = DataTools.bytesToInt(input, pt, 2, core.littleEndian[0]); 
    15041459      // skip 2 bytes 
    15051460      pt += 4; 
  • trunk/loci/formats/in/SDTReader.java

    r2583 r2584  
    3939  // -- Fields -- 
    4040 
    41   /** Current file. */ 
    42   protected RandomAccessStream in; 
    43  
    4441  /** Object containing SDT header information. */ 
    4542  protected SDTInfo info; 
     
    9996  public boolean isThisType(byte[] block) { return false; } 
    10097 
    101   /* @see loci.formats.IFormatReader#getImageCount(String) */  
    102   public int getImageCount() throws FormatException, IOException { 
    103     return channels; 
    104   } 
    105  
    106   /* @see loci.formats.IFormatReader#getSizeC(String) */  
    107   public int getSizeC() throws FormatException, IOException { 
    108     return intensity ? channels : (timeBins * channels); 
    109   } 
    110  
    11198  /* @see loci.formats.IFormatReader#getRGBChannelCount(String) */ 
    11299  public int getRGBChannelCount() throws FormatException, IOException { 
     
    123110    return intensity ? new String[] {FormatTools.SPECTRA} : 
    124111      new String[] {FormatTools.LIFETIME, FormatTools.SPECTRA}; 
    125   } 
    126  
    127   /* @see loci.formats.IFormatReader#isLittleEndian(String) */  
    128   public boolean isLittleEndian() throws FormatException, IOException { 
    129     return true; 
    130112  } 
    131113 
     
    199181  } 
    200182 
    201   /* @see loci.formats.IFormatReader#close() */  
    202   public void close() throws FormatException, IOException { 
    203     if (in != null) in.close(); 
    204     in = null; 
    205     currentId = null; 
    206   } 
    207  
    208183  // -- FormatReader API methods -- 
    209184 
     
    234209    core.currentOrder[0] = "XYZTC"; 
    235210    core.pixelType[0] = FormatTools.UINT16; 
     211    core.rgb[0] = getRGBChannelCount() > 1; 
     212    core.littleEndian[0] = true; 
     213    core.imageCount[0] = channels; 
    236214 
    237215    MetadataStore store = getMetadataStore(); 
  • trunk/loci/formats/in/SlidebookReader.java

    r2583 r2584  
    4141  // -- Fields -- 
    4242 
    43   /** Current file. */ 
    44   protected RandomAccessStream in; 
    45  
    46   /** Number of image planes in the file. */ 
    47   protected int numImages = 0; 
    48  
    4943  /** Offset to pixel data. */ 
    5044  private int offset = 1792; 
     
    5246  /** Number of bytes per pixel. */ 
    5347  private int bpp; 
    54  
    55   /** Flag is true if the data is in little-endian order. */ 
    56   private boolean little; 
    5748 
    5849  // -- Constructor -- 
     
    6859    return block[0] == 0x6c && block[1] == 0 && block[2] == 0 && 
    6960      block[3] == 1 && block[4] == 0x49 && block[5] == 0x49 && block[6] == 0; 
    70   } 
    71  
    72   /* @see loci.formats.IFormatReader#getImageCount(String) */  
    73   public int getImageCount() throws FormatException, IOException { 
    74     return numImages; 
    75   } 
    76  
    77   /* @see loci.formats.IFormatReader#isRGB(String) */  
    78   public boolean isRGB() throws FormatException, IOException { 
    79     return false; 
    80   } 
    81  
    82   /* @see loci.formats.IFormatReader#isLittleEndian(String) */  
    83   public boolean isLittleEndian() throws FormatException, IOException { 
    84     return little; 
    85   } 
    86  
    87   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    88   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    89     return false; 
    9061  } 
    9162 
     
    12394  } 
    12495 
    125   /* @see loci.formats.IFormatReader#close() */  
    126   public void close() throws FormatException, IOException { 
    127     if (in != null) in.close(); 
    128     in = null; 
    129     currentId = null; 
    130   } 
    131  
    13296  /** Initializes the given Slidebook file. */ 
    13397  protected void initFile(String id) throws FormatException, IOException { 
     
    139103 
    140104    in.skipBytes(4); 
    141     little = in.read() == 0x49; 
     105    core.littleEndian[0] = in.read() == 0x49; 
    142106 
    143107    bpp = 2; // this is a major assumption 
     
    223187    } 
    224188 
    225     numImages = count / (core.sizeX[0] * core.sizeY[0] * bpp); 
     189    core.imageCount[0] = count / (core.sizeX[0] * core.sizeY[0] * bpp); 
    226190 
    227191    float planes = (float) count / (float) (core.sizeX[0]*core.sizeY[0] * bpp); 
    228     numImages = (int) planes; 
    229  
    230     core.sizeZ[0] = numImages / (core.sizeC[0] * core.sizeT[0]); 
     192    core.imageCount[0] = (int) planes; 
     193 
     194    core.sizeZ[0] = core.imageCount[0] / (core.sizeC[0] * core.sizeT[0]); 
    231195 
    232196    core.pixelType[0] = FormatTools.UINT16; 
    233197    core.currentOrder[0] = "XY"; 
    234  
    235     if (numImages != (core.sizeZ[0] * core.sizeC[0] * core.sizeT[0])) { 
     198    core.rgb[0] = false; 
     199    core.interleaved[0] = false; 
     200 
     201    if (core.imageCount[0] != (core.sizeZ[0] * core.sizeC[0] * core.sizeT[0])) { 
    236202      core.sizeZ[0] = 1; 
    237       core.sizeT[0] = numImages / core.sizeC[0]; 
     203      core.sizeT[0] = core.imageCount[0] / core.sizeC[0]; 
    238204    } 
    239205 
     
    269235      new Integer(core.sizeZ[0]), new Integer(core.sizeC[0]),  
    270236      new Integer(core.sizeT[0]), new Integer(core.pixelType[0]),  
    271       new Boolean(!little), core.currentOrder[0], null, null); 
     237      new Boolean(!core.littleEndian[0]), core.currentOrder[0], null, null); 
    272238    for (int i=0; i<core.sizeC[0]; i++) { 
    273239      store.setLogicalChannel(i, null, null, null, null, null, null, null); 
  • trunk/loci/formats/in/TiffReader.java

    r2583 r2584  
    154154          // MAJOR HACK : adjust SizeT to match the number of IFDs, if this 
    155155          // file was written by a buggy version of WiscScan 
    156           if (isWiscScan) core.sizeT[i] = numImages; 
     156          if (isWiscScan) core.sizeT[i] = core.imageCount[0]; 
    157157 
    158158          core.currentOrder[i] = pixels[i].getAttribute("DimensionOrder"); 
     
    177177            int firstC = nullFirstC ? 0 : Integer.parseInt(aFirstC); 
    178178            int numPlanes = nullNumPlanes ? 
    179               (nullIfd ? numImages : 1) : Integer.parseInt(aNumPlanes); 
     179              (nullIfd ? core.imageCount[0] : 1) : Integer.parseInt(aNumPlanes); 
    180180 
    181181            // populate ZCT matrix 
  • trunk/loci/formats/in/ZeissLSMReader.java

    r2583 r2584  
    211211 
    212212    // reset numImages and ifds 
    213     numImages = tempIFDs.length; 
     213    core.imageCount[0] = tempIFDs.length; 
    214214    ifds = tempIFDs; 
    215215    initMetadata(); 
     
    254254      if (core.sizeC[0] == 0) core.sizeC[0]++; 
    255255 
    256       while (numImages > core.sizeZ[0] * core.sizeC[0] * core.sizeT[0]) { 
     256      while (core.imageCount[0] > core.sizeZ[0] * core.sizeC[0] * core.sizeT[0]) 
     257      { 
    257258        if (core.sizeZ[0] > core.sizeT[0]) core.sizeZ[0]++; 
    258259        else core.sizeT[0]++; 
    259260      } 
    260261 
    261       while (numImages > core.sizeZ[0] * core.sizeT[0] * getEffectiveSizeC()) { 
    262         numImages--; 
     262      while (core.imageCount[0] > core.sizeZ[0] * core.sizeT[0] *  
     263        getEffectiveSizeC())  
     264      { 
     265        core.imageCount[0]--; 
    263266      } 
    264267 
  • trunk/loci/formats/in/ZeissZVIReader.java

    r2583 r2584  
    6767  // -- Fields -- 
    6868 
    69   /** Current file. */ 
    70   private RandomAccessStream in; 
    71  
    7269  /** Flag set to true if we need to use the legacy reader. */ 
    7370  private boolean needLegacy = false; 
    74  
    75   /** Number of images. */ 
    76   private int nImages; 
    7771 
    7872  /** Number of bytes per pixel. */ 
     
    120114    return (block[0] == 0xd0 && block[1] == 0xcf && 
    121115      block[2] == 0x11 && block[3] == 0xe0); 
    122   } 
    123  
    124   /* @see loci.formats.IFormatReader#getImageCount(String) */  
    125   public int getImageCount() throws FormatException, IOException { 
    126     if (noPOI || needLegacy) return legacy.getImageCount(); 
    127     return nImages; 
    128   } 
    129  
    130   /* @see loci.formats.IFormatReader#getSizeX(String) */  
    131   public int getSizeX() throws FormatException, IOException { 
    132     if (noPOI || needLegacy) return legacy.getSizeX(); 
    133     return super.getSizeX(); 
    134   } 
    135  
    136   /* @see loci.formats.IFormatReader#getSizeY() */  
    137   public int getSizeY() throws FormatException, IOException { 
    138     if (noPOI || needLegacy) return legacy.getSizeY(); 
    139     return super.getSizeY(); 
    140   } 
    141  
    142   /* @see loci.formats.IFormatReader#getSizeZ() */  
    143   public int getSizeZ() throws FormatException, IOException { 
    144     if (noPOI || needLegacy) return legacy.getSizeZ(); 
    145     return super.getSizeZ(); 
    146   } 
    147  
    148   /* @see loci.formats.IFormatReader#getSizeC(String) */  
    149   public int getSizeC() throws FormatException, IOException { 
    150     if (noPOI || needLegacy) return legacy.getSizeC(); 
    151     return super.getSizeC(); 
    152   } 
    153  
    154   /* @see loci.formats.IFormatReader#getSizeT(String) */  
    155   public int getSizeT() throws FormatException, IOException { 
    156     if (noPOI || needLegacy) return legacy.getSizeT(); 
    157     return super.getSizeT(); 
    158   } 
    159  
    160   /* @see loci.formats.IFormatReader#getPixelType(String) */ 
    161   public int getPixelType() throws FormatException, IOException { 
    162     if (noPOI || needLegacy) return legacy.getPixelType(); 
    163     return super.getPixelType(); 
    164   } 
    165  
    166   /* @see loci.formats.IFormatReader#getDimensionOrder(String) */  
    167   public String getDimensionOrder() 
    168     throws FormatException, IOException 
    169   { 
    170     if (noPOI || needLegacy) return legacy.getDimensionOrder(); 
    171     return super.getDimensionOrder(); 
    172   } 
    173  
    174   /* @see loci.formats.IFormatReader#isRGB(String) */  
    175   public boolean isRGB() throws FormatException, IOException { 
    176     if (noPOI || needLegacy) return legacy.isRGB(); 
    177     return core.sizeC[0] > 1 &&  
    178       (core.sizeZ[0] * core.sizeC[0] * core.sizeT[0] != nImages); 
    179   } 
    180  
    181   /* @see loci.formats.IFormatReader#isLittleEndian(String) */  
    182   public boolean isLittleEndian() throws FormatException, IOException { 
    183     return true; 
    184   } 
    185  
    186   /* @see loci.formats.IFormatReader#isInterleaved(int) */  
    187   public boolean isInterleaved(int subC) throws FormatException, IOException { 
    188     return false; 
    189116  } 
    190117 
     
    215142 
    216143    try { 
    217       Object directory = pixels.get(new Integer(no)); 
    218       String name = (String) names.get(new Integer(no)); 
     144      Integer ii = new Integer(no);  
     145      Object directory = pixels.get(ii); 
     146      String name = (String) names.get(ii); 
    219147 
    220148      r.setVar("dir", directory);