Package loci.common

Examples of loci.common.IRandomAccess


   *         if, for some incomprehensible reason, the DATA
   *         block was missing.
   * @throws IOException
   */
  public byte [] openRaw() throws IOException {
    IRandomAccess is = Location.getHandle(getCurrentFile(), false);
    is.setOrder(ByteOrder.LITTLE_ENDIAN);
    final ContainerRecord dataSet = dataSets.get(getSeries());
    for (IM3Record subRec:dataSet.parseChunks(is)){
      if (subRec.name.equals(FIELD_DATA)) {
        is.seek(subRec.offset+4);
        int width = is.readInt();
        int height = is.readInt();
        int channels = is.readInt();
        final byte [] result = new byte [width * height * channels * 2];
        is.read(result);
        return result;
      }
    }
    return null;
  }
View Full Code Here


   * @see loci.formats.FormatReader#initFile(java.lang.String)
   */
  @Override
  protected void initFile(String id) throws FormatException, IOException {
    super.initFile(id);
    IRandomAccess is = Location.getHandle(id, false);
    is.setOrder(ByteOrder.LITTLE_ENDIAN);
    final int cookie = is.readInt();
    if (cookie != COOKIE) {
      throw new FormatException(String.format("Expected file cookie of %d, but got %d.", COOKIE, cookie));
    }
    long fileLength = is.length();
    records = new ArrayList<IM3Record>();
    dataSets = new ArrayList<ContainerRecord>();
    spectra = new ArrayList<Spectrum>();
    core = new ArrayList<CoreMetadata>();

    while (is.getFilePointer() < fileLength) {
      final IM3Record rec = parseRecord(is);
      if (rec == null) {
        if (is.getFilePointer() > fileLength-16) break;
        /*
         * # of bytes in chunk.
         */
        @SuppressWarnings("unused")
        final int chunkLength = is.readInt();
        /*
         * Is always zero? Chunk #?
         */
        @SuppressWarnings("unused")
        final int unknown = is.readInt();
        /*
         * Is always one? Chunk #?
         */
        @SuppressWarnings("unused")
        final int unknown1 = is.readInt();
        /*
         * # of records to follow
         */
        @SuppressWarnings("unused")
        final int nRecords = is.readInt();
      } else {
        if (rec instanceof ContainerRecord) {
          final ContainerRecord bRec = (ContainerRecord)rec;
          for (IM3Record subDS:bRec.parseChunks(is)) {
            if ((subDS instanceof ContainerRecord) && (subDS.name.equals(FIELD_DATA_SET))) {
View Full Code Here

  /**
   * Write a summary of each field in the IM3 file to the writer
   * @throws IOException
   */
  public void writeSummary() throws IOException {
    IRandomAccess is = Location.getHandle(getCurrentFile(), false);
    is.setOrder(ByteOrder.LITTLE_ENDIAN);
    for (IM3Record rec: records) {
      rec.writeSummary(is, "");
    }
  }
View Full Code Here

TOP

Related Classes of loci.common.IRandomAccess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.