Exemplo n.º 1
0
  public void readHeader() throws IOException {
    if (gotHeader) return;

    if (iis == null) {
      throw new IllegalStateException("Input source not set!");
    }

    metadata = new WBMPMetadata();

    wbmpType = iis.readByte(); // TypeField
    byte fixHeaderField = iis.readByte();

    // check for valid wbmp image
    if (fixHeaderField != 0 || !isValidWbmpType(wbmpType)) {
      throw new IIOException(I18N.getString("WBMPImageReader2"));
    }

    metadata.wbmpType = wbmpType;

    // Read image width
    width = readMultiByteInteger();
    metadata.width = width;

    // Read image height
    height = readMultiByteInteger();
    metadata.height = height;

    gotHeader = true;
  }
Exemplo n.º 2
0
 private int readMultiByteInteger() throws IOException {
   int value = iis.readByte();
   int result = value & 0x7f;
   while ((value & 0x80) == 0x80) {
     result <<= 7;
     value = iis.readByte();
     result |= (value & 0x7f);
   }
   return result;
 }