gnu.javax.imageio.gif

Class GIFImageReader


public class GIFImageReader
extends ImageReader

Field Summary

Fields inherited from class javax.imageio.ImageReader

availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales

Constructor Summary

GIFImageReader(ImageReaderSpi originatingProvider)
Construct an image reader.

Method Summary

int
getHeight(int imageIndex)
Get the height of the input image in pixels.
IIOMetadata
getImageMetadata(int imageIndex)
Get the metadata associated with this image.
Iterator<E>
getImageTypes(int imageIndex)
Get an iterator over the collection of image types into which this reader can decode image data.
int
getNumImages(boolean allowSearch)
Returns the number of images.
IIOMetadata
getStreamMetadata()
Get the metadata associated with the image being read.
int
getWidth(int imageIndex)
Get the width of the input image in pixels.
BufferedImage
read(int imageIndex, ImageReadParam param)
Reads the image indexed by imageIndex and returns it as a complete BufferedImage, using a supplied ImageReadParam.
void
setInput(Object input)
Set the input source to the given object.
void
setInput(Object input, boolean isStreamable)
Set the input source to the given object and specify whether this reader should be allowed to read input from the data stream more than once.
void
setInput(Object input, boolean seekForwardOnly, boolean ignoreMetadata)
Set the input source to the given object, specify whether this reader should be allowed to read input from the data stream more than once, and specify whether this reader should ignore metadata in the input stream.

Methods inherited from class javax.imageio.ImageReader

abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, dispose, getAspectRatio, getAvailableLocales, getDefaultReadParam, getDestination, getFormatName, getHeight, getImageMetadata, getImageMetadata, getImageTypes, getInput, getLocale, getMinIndex, getNumImages, getNumThumbnails, getOriginatingProvider, getRawImageType, getSourceRegion, getStreamMetadata, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getWidth, hasThumbnails, isIgnoringMetadata, isImageTiled, isRandomAccessEasy, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, read, read, readAll, readAll, readAsRenderedImage, readRaster, readThumbnail, readTile, readTileRaster, readerSupportsThumbnails, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, reset, setInput, setInput, setInput, setLocale

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

GIFImageReader

protected GIFImageReader(ImageReaderSpi originatingProvider)
Construct an image reader.
Parameters:
originatingProvider - the provider that is constructing this image reader, or null

Method Details

getHeight

public int getHeight(int imageIndex)
            throws IOException
Get the height of the input image in pixels. If the input image is resizable then a default height is returned.
Overrides:
getHeight in interface ImageReader
Parameters:
imageIndex - the frame index
Returns:
the height of the input image
Throws:
IllegalStateException - if input has not been set
IndexOutOfBoundsException - if the frame index is out-of-bounds
IOException - if a read error occurs

getImageMetadata

public IIOMetadata getImageMetadata(int imageIndex)
Get the metadata associated with this image. If the reader is set to ignore metadata or does not support reading metadata, or if no metadata is available then null is returned.
Overrides:
getImageMetadata in interface ImageReader
Parameters:
imageIndex - the frame index
Returns:
a metadata object, or null
Throws:
IllegalStateException - if input has not been set
IndexOutOfBoundsException - if the frame index is out-of-bounds

getImageTypes

public Iterator<E> getImageTypes(int imageIndex)
Get an iterator over the collection of image types into which this reader can decode image data. This method is guaranteed to return at least one valid image type specifier. The elements of the iterator should be ordered; the first element should be the most appropriate image type for this decoder, followed by the second-most appropriate, and so on.
Overrides:
getImageTypes in interface ImageReader
Parameters:
imageIndex - the frame index
Returns:
an iterator over a collection of image type specifiers
Throws:
IllegalStateException - if input has not been set
IndexOutOfBoundsException - if the frame index is out-of-bounds

getNumImages

public int getNumImages(boolean allowSearch)
Returns the number of images.
Overrides:
getNumImages in interface ImageReader

getStreamMetadata

public IIOMetadata getStreamMetadata()
Get the metadata associated with the image being read. If the reader is set to ignore metadata or does not support reading metadata, or if no metadata is available then null is returned. This method returns metadata associated with the entirety of the image data, whereas getImageMetadata(int) returns metadata associated with a frame within a multi-image data stream.
Overrides:
getStreamMetadata in interface ImageReader
Returns:
metadata associated with the image being read, or null

getWidth

public int getWidth(int imageIndex)
            throws IOException
Get the width of the input image in pixels. If the input image is resizable then a default width is returned.
Overrides:
getWidth in interface ImageReader
Parameters:
imageIndex - the image's index
Returns:
the width of the input image
Throws:
IllegalStateException - if input has not been set
IndexOutOfBoundsException - if the frame index is out-of-bounds
IOException - if a read error occurs

read

public BufferedImage read(int imageIndex,
                          ImageReadParam param)
            throws IOException,
                   IIOException
Reads the image indexed by imageIndex and returns it as a complete BufferedImage, using a supplied ImageReadParam.
Overrides:
read in interface ImageReader

setInput

public void setInput(Object input)
Set the input source to the given object. The input source must be set before many methods can be called on this reader. (see all ImageReader methods that throw IllegalStateException). If input is null then the current input source will be removed.
Overrides:
setInput in interface ImageReader
Parameters:
input - the input source object
Throws:
IllegalArgumentException - if input is not a valid input source for this reader and is not an ImageInputStream

setInput

public void setInput(Object input,
                     boolean isStreamable)
Set the input source to the given object and specify whether this reader should be allowed to read input from the data stream more than once. The input source must be set before many methods can be called on this reader. (see all ImageReader methods that throw IllegalStateException). If input is null then the current input source will be removed.
Overrides:
setInput in interface ImageReader
Parameters:
Throws:
IllegalArgumentException - if input is not a valid input source for this reader and is not an ImageInputStream

setInput

public void setInput(Object input,
                     boolean seekForwardOnly,
                     boolean ignoreMetadata)
Set the input source to the given object, specify whether this reader should be allowed to read input from the data stream more than once, and specify whether this reader should ignore metadata in the input stream. The input source must be set before many methods can be called on this reader. (see all ImageReader methods that throw IllegalStateException). If input is null then the current input source will be removed. Unless this reader has direct access with imaging hardware, input should be an ImageInputStream.
Overrides:
setInput in interface ImageReader
Parameters:
input - the input source object
seekForwardOnly - true if this reader should be allowed to read input from the data stream more than once, false otherwise
ignoreMetadata - true if this reader should ignore metadata associated with the input source, false otherwise
Throws:
IllegalArgumentException - if input is not a valid input source for this reader and is not an ImageInputStream

GIFImageReader.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.