Ejemplo n.º 1
0
  private IFDEntry readDirectoryEntry(long byteOffset) throws IOException {
    MappedByteBuffer ifd = makeReadOnlyBuffer(byteOffset, 12);
    char tag = ifd.getChar();
    char type = ifd.getChar();
    long count = unsignInt(ifd.getInt());
    long value = unsignInt(ifd.getInt());

    return (new IFDEntry(tag, type, count, value));
  }
  protected String receiveMessage() {
    String message = new String();
    buffer.position(0);

    for (char c = buffer.getChar(); c != '\0'; c = buffer.getChar()) {
      message += c;
    }

    return message;
  }
Ejemplo n.º 3
0
 // return byte offset of next IFD
 private IFDData readIFD(long byteOffset) throws IOException {
   MappedByteBuffer entries = makeReadOnlyBuffer(byteOffset, 2);
   int numEntries = entries.getChar();
   IFDData data = new IFDData();
   for (int i = 0; i < numEntries; i++) {
     IFDEntry entry = readDirectoryEntry(12 * i + 2 + byteOffset);
     if (entry.tag == MM_METADATA) {
       data.mdOffset = entry.value;
     } else if (entry.tag == STRIP_OFFSETS) {
       data.pixelOffset = entry.value;
     } else if (entry.tag == STRIP_BYTE_COUNTS) {
       data.bytesPerImage = entry.value;
     } else if (entry.tag == BITS_PER_SAMPLE) {
       if (entry.value <= 8) {
         data.bytesPerPixel = 1;
       } else if (entry.value <= 16) {
         data.bytesPerPixel = 2;
       } else {
         data.bytesPerPixel = 3;
       }
     } else if (entry.tag == MM_METADATA_LENGTH) {
       data.mdLength = entry.value;
     }
   }
   MappedByteBuffer next = makeReadOnlyBuffer(byteOffset + 2 + 12 * numEntries, 4);
   data.nextIFDAdress = unsignInt(next.getInt());
   return data;
 }