Class AbstractImageIODecoder
java.lang.Object
is.galia.codec.AbstractDecoder
is.galia.codec.AbstractImageIODecoder
- Direct Known Subclasses:
BMPDecoder
,GIFDecoder
,JPEGDecoder
,PNGDecoder
,TIFFDecoder
Abstract class that can be extended by a
Decoder
that wraps an
ImageReader
. Supports resolution levels and tiling.-
Field Summary
FieldsFields inherited from class is.galia.codec.AbstractDecoder
arena, imageFile, inputStream
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
canSeek()
void
close()
decode
(int imageIndex) Expedient but not necessarily efficient method that reads a whole image (excluding subimages) in one shot.decode
(int imageIndex, Region region, double[] scales, ReductionFactor reductionFactor, double[] diffScales, Set<DecoderHint> decoderHints) Attempts to read an image as efficiently as possible, exploiting its tile layout, if possible.void
dispose()
Should be called when the instance is no longer needed.protected abstract org.slf4j.Logger
int
int
int
getNumThumbnails
(int imageIndex) protected abstract String[]
N.B.: This method returns a list of strings rather thanclasses
because some readers reside under thecom.sun
package, which is encapsulated.getSize
(int imageIndex) getThumbnailSize
(int imageIndex, int thumbIndex) getTileSize
(int imageIndex) protected static void
void
abstract Metadata
readMetadata
(int imageIndex) protected BufferedImage
readMonoResolution
(int imageIndex, Region region) Reads a particular image from a multi-image file.protected BufferedImage
readSmallestUsableSubimage
(Region region, double[] scales, ReductionFactor reductionFactor) Reads the smallest image that can fulfill the given ROI and scale from a multi-image file.readThumbnail
(int imageIndex, int thumbIndex) Methods inherited from class is.galia.codec.AbstractDecoder
setArena, setSource, setSource
-
Field Details
-
iioReader
Assigned bycreateReader()
.
-
-
Constructor Details
-
AbstractImageIODecoder
public AbstractImageIODecoder()
-
-
Method Details
-
handle
- Throws:
IOException
-
canSeek
public abstract boolean canSeek() -
close
public void close()- Overrides:
close
in classAbstractDecoder
-
initializeInputStream
- Throws:
IOException
-
dispose
public void dispose()Should be called when the instance is no longer needed. -
getLogger
protected abstract org.slf4j.Logger getLogger() -
getNumImages
- Returns:
- Number of images contained inside the source image.
- Throws:
IOException
-
getNumResolutions
- Returns:
1
.- Throws:
IOException
-
getNumThumbnails
- Throws:
IOException
-
getPreferredIIOImplementations
N.B.: This method returns a list of strings rather thanclasses
because some readers reside under thecom.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
- Returns:
- Pixel dimensions of the image at the given index.
- Throws:
IOException
-
getSupportedFormats
-
getThumbnailSize
- Returns:
- Size of the thumbnail at the given coordinates.
- Throws:
IOException
-
getTileSize
- 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
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 benull
.scales
- May benull
.reductionFactor
- TheReductionFactor.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
- Throws:
IOException
-
readMonoResolution
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
- Throws:
IOException
-
readThumbnail
- Throws:
IOException
-