Class GIFDecoder
java.lang.Object
is.galia.codec.AbstractDecoder
is.galia.codec.AbstractImageIODecoder
is.galia.codec.gif.GIFDecoder
- All Implemented Interfaces:
Decoder,AutoCloseable
Implementation wrapping the default JDK Image I/O GIF
ImageReader.-
Field Summary
Fields inherited from class is.galia.codec.AbstractImageIODecoder
iioReaderFields inherited from class is.galia.codec.AbstractDecoder
arena, imageFile, inputStream -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanSeek()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.Called after a source has been set.protected org.slf4j.Loggerprotected String[]N.B.: This method returns a list of strings rather thanclassesbecause some readers reside under thecom.sunpackage, which is encapsulated.readMetadata(int imageIndex) Reads metadata pertaining to the image at the given index.Methods inherited from class is.galia.codec.AbstractImageIODecoder
close, decodeSequence, dispose, getNumImages, getNumResolutions, getNumThumbnails, getSize, getThumbnailSize, getTileSize, handle, initializeInputStream, readMonoResolution, readSmallestUsableSubimage, readThumbnailMethods inherited from class is.galia.codec.AbstractDecoder
setArena, setSource, setSourceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface is.galia.codec.Decoder
close, decodeSequence, getNumImages, getNumResolutions, getNumThumbnails, getSize, getThumbnailSize, getTileSize, readThumbnail, setArena, setSource, setSource
-
Constructor Details
-
GIFDecoder
public GIFDecoder()
-
-
Method Details
-
canSeek
public boolean canSeek()- Specified by:
canSeekin classAbstractImageIODecoder
-
detectFormat
Description copied from interface:DecoderCalled 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 returnFormat.UNKNOWN.- Specified by:
detectFormatin interfaceDecoder- 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 theformat 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:
getLoggerin classAbstractImageIODecoder
-
getPreferredIIOImplementations
Description copied from class:AbstractImageIODecoderN.B.: This method returns a list of strings rather thanclassesbecause some readers reside under thecom.sunpackage, which is encapsulated.- Specified by:
getPreferredIIOImplementationsin classAbstractImageIODecoder- Returns:
- Preferred reader implementation classes, in order of highest to lowest priority, or an empty array if there is no preference.
-
getSupportedFormats
- Specified by:
getSupportedFormatsin interfaceDecoder- Specified by:
getSupportedFormatsin classAbstractImageIODecoder- 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
Description copied from class:AbstractImageIODecoderExpedient but not necessarily efficient method that reads a whole image (excluding subimages) in one shot.- Specified by:
decodein interfaceDecoder- Overrides:
decodein classAbstractImageIODecoder- Throws:
IOException
-
decode
public BufferedImage decode(int imageIndex, Region region, double[] scales, ReductionFactor reductionFactor, double[] diffScales, Set<DecoderHint> decoderHints) throws IOException Description copied from class:AbstractImageIODecoderAttempts 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.
- Specified by:
decodein interfaceDecoder- Overrides:
decodein classAbstractImageIODecoder- Parameters:
imageIndex- Image index.region- May benull.scales- May benull.reductionFactor- TheReductionFactor.factorproperty 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- if there is some other error reading the image.
-
readMetadata
Description copied from interface:DecoderReads metadata pertaining to the image at the given index.- Specified by:
readMetadatain interfaceDecoder- Specified by:
readMetadatain classAbstractImageIODecoder- Returns:
- Metadata for the image at the given index. If there is none, an
EmptyMetadatacan be returned. - Throws:
IOException- if there is some other error reading the metadata.
-