Class TIFFDecoder

All Implemented Interfaces:
Decoder, AutoCloseable

public final class TIFFDecoder extends AbstractImageIODecoder implements Decoder
Implementation wrapping the default JDK Image I/O TIFF ImageReader.
  • Constructor Details

    • TIFFDecoder

      public TIFFDecoder()
  • Method Details

    • canSeek

      public boolean canSeek()
      Specified by:
      canSeek in class AbstractImageIODecoder
    • detectFormat

      public Format detectFormat() throws IOException
      Description copied from interface: Decoder

      Called after a source has been set.

      If reading from a Decoder.setSource(ImageInputStream) stream}, the stream position is reset to 0 before returning.

      Unlike many of the other interface methods, implementations should not throw a SourceFormatException, and instead just return Format.UNKNOWN.

      Specified by:
      detectFormat in interface Decoder
      Returns:
      Format of the image to decode, if supported by the instance; otherwise Format.UNKNOWN. The implementation must create the instance from scratch and not obtain it from the format registry, which may be empty at the time this method is invoked.
      Throws:
      IOException - if there is some other error reading the image.
    • getLogger

      protected org.slf4j.Logger getLogger()
      Specified by:
      getLogger in class AbstractImageIODecoder
    • getNumResolutions

      public int getNumResolutions() throws IOException
      Only a pyramidal TIFF will have more than one resolution; but there is no simple flag in a pyramidal TIFF that indicates that it's pyramidal. For files that contain multiple images, this method checks the dimensions of each, and if they look like they comprise a pyramid based on their dimensions, returns their count. If not, it returns 1.
      Specified by:
      getNumResolutions in interface Decoder
      Overrides:
      getNumResolutions in class AbstractImageIODecoder
      Returns:
      1.
      Throws:
      IOException - if there is some other error reading the number of resolutions.
    • getPreferredIIOImplementations

      protected String[] getPreferredIIOImplementations()
      Description copied from class: AbstractImageIODecoder
      N.B.: This method returns a list of strings rather than classes because some readers reside under the com.sun package, which is encapsulated.
      Specified by:
      getPreferredIIOImplementations in class AbstractImageIODecoder
      Returns:
      Preferred reader implementation classes, in order of highest to lowest priority, or an empty array if there is no preference.
    • getSupportedFormats

      public Set<Format> getSupportedFormats()
      Specified by:
      getSupportedFormats in interface Decoder
      Specified by:
      getSupportedFormats in class AbstractImageIODecoder
      Returns:
      All formats supported by the implementation. The instances must be created from scratch and not obtained from the format registry, which may be empty at the time this method is invoked.
    • decode

      public BufferedImage decode(int imageIndex, Region region, double[] scales, ReductionFactor reductionFactor, double[] diffScales, Set<DecoderHint> hints) throws IOException

      Override that is multi-resolution- and tile-aware.

      After reading, clients should check the decoder hints to see whether the returned image will require additional scaling.

      Specified by:
      decode in interface Decoder
      Overrides:
      decode in class AbstractImageIODecoder
      Parameters:
      imageIndex - Image index.
      region - May be null.
      scales - May be null.
      reductionFactor - The ReductionFactor.factor property will be modified to reflect the reduction factor of the returned image.
      diffScales - Two-element array that will be populated with the X and Y axis differential scales used during reading (if the decoder supports this).
      hints - Will be populated by information returned from the reader.
      Returns:
      Image best matching the given arguments.
      Throws:
      IOException - if there is some other error reading the image.
    • readMetadata

      public Metadata readMetadata(int imageIndex) throws IOException
      Description copied from interface: Decoder
      Reads metadata pertaining to the image at the given index.
      Specified by:
      readMetadata in interface Decoder
      Specified by:
      readMetadata in class AbstractImageIODecoder
      Returns:
      Metadata for the image at the given index. If there is none, an EmptyMetadata can be returned.
      Throws:
      IOException - if there is some other error reading the metadata.
    • decodeSequence

      public BufferedImageSequence decodeSequence() throws IOException
      Description copied from interface: Decoder

      Decodes a sequence of images into memory

      This method is meant to support short animations (e.g. animated GIF). It is not meant to support video formats, which could fill up all available memory and then some. These should simply throw an UnsupportedOperationException, which is what this default implementation does.

      Specified by:
      decodeSequence in interface Decoder
      Overrides:
      decodeSequence in class AbstractImageIODecoder
      Throws:
      IOException - if there is some other error reading the sequence.