Class AbstractImageIODecoder

java.lang.Object
is.galia.codec.AbstractDecoder
is.galia.codec.AbstractImageIODecoder
Direct Known Subclasses:
BMPDecoder, GIFDecoder, JPEGDecoder, PNGDecoder, TIFFDecoder

public abstract class AbstractImageIODecoder extends AbstractDecoder
Abstract class that can be extended by a Decoder that wraps an ImageReader. Supports resolution levels and tiling.
  • Field Details

    • iioReader

      protected ImageReader iioReader
      Assigned by createReader().
  • Constructor Details

    • AbstractImageIODecoder

      public AbstractImageIODecoder()
  • Method Details

    • handle

      protected static void handle(IIOException e) throws IOException
      Throws:
      IOException
    • canSeek

      public abstract boolean canSeek()
    • close

      public void close()
      Overrides:
      close in class AbstractDecoder
    • initializeInputStream

      public void initializeInputStream() throws IOException
      Throws:
      IOException
    • dispose

      public void dispose()
      Should be called when the instance is no longer needed.
    • getLogger

      protected abstract org.slf4j.Logger getLogger()
    • getNumImages

      public int getNumImages() throws IOException
      Returns:
      Number of images contained inside the source image.
      Throws:
      IOException
    • getNumResolutions

      public int getNumResolutions() throws IOException
      Returns:
      1.
      Throws:
      IOException
    • getNumThumbnails

      public int getNumThumbnails(int imageIndex) throws IOException
      Throws:
      IOException
    • getPreferredIIOImplementations

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

      public Size getSize(int imageIndex) throws IOException
      Returns:
      Pixel dimensions of the image at the given index.
      Throws:
      IOException
    • getSupportedFormats

      public abstract Set<Format> getSupportedFormats()
    • getThumbnailSize

      public Size getThumbnailSize(int imageIndex, int thumbIndex) throws IOException
      Returns:
      Size of the thumbnail at the given coordinates.
      Throws:
      IOException
    • getTileSize

      public Size getTileSize(int imageIndex) throws IOException
      Returns:
      Tile size of the image at the given index, or the full image dimensions if the image is not tiled (or is mono-tiled).
      Throws:
      IOException
    • decode

      public BufferedImage decode(int imageIndex) throws IOException
      Expedient but not necessarily efficient method that reads a whole image (excluding subimages) in one shot.
      Throws:
      IOException
    • decode

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

      Attempts to read an image as efficiently as possible, exploiting its tile layout, if possible.

      This implementation is optimized for mono-resolution images.

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

      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).
      decoderHints - Will be populated by information returned from the reader.
      Returns:
      Image best matching the given arguments.
      Throws:
      IOException
    • readMetadata

      public abstract Metadata readMetadata(int imageIndex) throws IOException
      Throws:
      IOException
    • readMonoResolution

      protected BufferedImage readMonoResolution(int imageIndex, Region region) throws IOException
      Reads a particular image from a multi-image file.
      Parameters:
      imageIndex - Image index.
      region - Requested region of interest.
      Returns:
      Smallest image fitting the requested operations.
      Throws:
      IOException
      See Also:
    • readSmallestUsableSubimage

      protected BufferedImage readSmallestUsableSubimage(Region region, double[] scales, ReductionFactor reductionFactor) throws IOException
      Reads the smallest image that can fulfill the given ROI and scale from a multi-image file.
      Parameters:
      region - Requested region of interest.
      scales - Requested X and Y axis scales.
      reductionFactor - Will be set to the reduction factor of the returned image.
      Returns:
      Smallest image fitting the requested operations.
      Throws:
      IOException
      See Also:
    • decodeSequence

      public BufferedImageSequence decodeSequence() throws IOException
      Throws:
      IOException
    • readThumbnail

      public BufferedImage readThumbnail(int imageIndex, int thumbIndex) throws IOException
      Throws:
      IOException