Exemplo n.º 1
0
  // Stream must be positioned at start of IFD for 'currIndex'
  private void readMetadata() throws IIOException {
    if (stream == null) {
      throw new IllegalStateException("Input not set!");
    }

    if (imageMetadata != null) {
      return;
    }
    try {
      // Create an object to store the image metadata
      List tagSets;
      if (imageReadParam instanceof TIFFImageReadParam) {
        tagSets = ((TIFFImageReadParam) imageReadParam).getAllowedTagSets();
      } else {
        tagSets = new ArrayList(1);
        tagSets.add(BaselineTIFFTagSet.getInstance());
      }

      this.imageMetadata = new TIFFImageMetadata(tagSets);
      imageMetadata.initializeFromStream(stream, ignoreMetadata);
    } catch (IIOException iioe) {
      throw iioe;
    } catch (IOException ioe) {
      throw new IIOException("I/O error reading image metadata!", ioe);
    }
  }