Exemplo n.º 1
0
 private void readIndexMap() throws IOException {
   MappedByteBuffer mapOffset = makeReadOnlyBuffer(8, 8);
   if (mapOffset.getInt() != MultipageTiffWriter.INDEX_MAP_OFFSET_HEADER) {
     ReportingUtils.logError("Image map offset header incorrect");
     indexMap_ = null;
     return;
   }
   long offset = unsignInt(mapOffset.getInt());
   MappedByteBuffer mapHeader = makeReadOnlyBuffer(offset, 8);
   int headerCode = mapHeader.getInt();
   if (headerCode != MultipageTiffWriter.INDEX_MAP_HEADER) {
     ReportingUtils.logError("Image index map header incorrect");
     indexMap_ = null;
     return;
   }
   int numMappings = mapHeader.getInt();
   MappedByteBuffer mapData = makeReadOnlyBuffer(offset + 8, 24 * numMappings);
   for (int i = 0; i < numMappings; i++) {
     int channel = mapData.getInt();
     int slice = mapData.getInt();
     int frame = mapData.getInt();
     int position = mapData.getInt();
     long imageOffset = mapData.getLong();
     indexMap_.put(MDUtils.generateLabel(channel, slice, frame, position), imageOffset);
   }
 }
Exemplo n.º 2
0
 private static void parseMeta() {
   try {
     RandomAccessFile f = new RandomAccessFile(path + "meta", "r");
     MappedByteBuffer mbb = f.getChannel().map(MapMode.READ_ONLY, 0, f.length());
     mbb.position(0);
     pos = mbb.getLong();
     long ck = mbb.getLong();
     int len = mbb.getInt();
     byte[] dst = new byte[len];
     mbb.get(dst);
     name = new String(dst, Charset.forName("UTF-8"));
     System.out.println("file: " + name + " pos: " + pos + " checksum: " + ck);
     mbb = null;
     f.close();
   } catch (Exception e) {
     System.out.println(e.getMessage());
     pos = 0;
     name = "null";
   }
 }
Exemplo n.º 3
0
  /**
   * Step through the table of sections, looking for .rsrc. When the .rsrc sections is found, call
   * another function to process it.
   *
   * @param file The file we're reading from
   * @param sectionsBase A pointer to the beginning of the sections.
   * @param numberOfSections The number of sections.
   * @return The version number, or 0 if it couldn't be found.
   * @throws IOException If there is a problem finding the version.
   */
  private static int processSections(
      MappedByteBuffer file, int sectionsBase, int numberOfSections, boolean byteorder)
      throws IOException {
    /* The location where the loaded RVA will be */
    int virtualStart;
    /* The location in the file where the data starts */
    int rawStart;
    /* The difference between the virtual start and the raw start */
    int rsrcVirtualToRaw;
    /* A pointer to the beginning of the section */
    int sectionBase;

    /* Loop over the sections */
    for (int i = 0; i < numberOfSections; i++) {
      /* Get the virtual address where the section starts */
      virtualStart = file.getInt(sectionsBase + (i * 40) + 12);
      /* Get the raw address where the section starts */
      rawStart = file.getInt(sectionsBase + (i * 40) + 20);
      /* Get the base of the section */
      sectionBase = sectionsBase + (i * 40);
      /* Find the difference between the actual location of rsrc and the virtual location of it */
      rsrcVirtualToRaw = rawStart - virtualStart;

      /* If we've found the rsrc section, process it.  If not, we really don't care. */
      if (file.getLong(sectionsBase + (i * 40)) == rsrc)
        return processResourceRecord(
            new LinkedList<Integer>(),
            file,
            0,
            file.getInt(sectionBase + 20),
            rsrcVirtualToRaw,
            byteorder);
    }

    return 0;
  }
Exemplo n.º 4
0
 @Override
 long readLong() {
   return mFileBuffer.getLong();
 }