gnu.javax.imageio.jpeg

Class JPEGImageReader


public class JPEGImageReader
extends ImageReader

Field Summary

Fields inherited from class javax.imageio.ImageReader

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

Constructor Summary

JPEGImageReader(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
getImageTypes(int imageIndex)
Get an iterator over the collection of image types into which this reader can decode image data.
int
getNumImages(boolean allowSearch)
Return the number of images available from the image input source, not including thumbnails.
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)
Read the given frame into a buffered image using the given read parameters.

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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

JPEGImageReader

protected JPEGImageReader(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)
            throws IOException
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
IOException - if a read error occurs

getImageTypes

public Iterator getImageTypes(int imageIndex)
            throws IOException
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
IOException - if a read error occurs

getNumImages

public int getNumImages(boolean allowSearch)
            throws IOException
Return the number of images available from the image input source, not including thumbnails. This method will return 1 unless this reader is reading an animated image. Certain multi-image formats do not encode the total number of images. When reading images in those formats it may be necessary to repeatedly call read, incrementing the image index at each call, until an IndexOutOfBoundsException is thrown. The allowSearch parameter determines whether all images must be available at all times. When allowSearch is false, getNumImages will return -1 if the total number of images is unknown. Otherwise this method returns the number of images.
Overrides:
getNumImages in interface ImageReader
Parameters:
allowSearch - true if all images should be available at once, false otherwise
Returns:
-1 if allowSearch is false and the total number of images is currently unknown, or the number of images
Throws:
IllegalStateException - if input has not been set, or if seekForwardOnly is true
IOException - if a read error occurs

getStreamMetadata

public IIOMetadata getStreamMetadata()
            throws IOException
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
Throws:
IOException - if a read error occurs

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
Read the given frame into a buffered image using the given read parameters. Listeners will be notified of image loading progress and warnings.
Overrides:
read in interface ImageReader
Parameters:
imageIndex - the index of the frame to read
param - the image read parameters to use when reading
Returns:
a buffered image
Throws:
IllegalStateException - if input is null
IndexOutOfBoundsException - if the frame index is out-of-bounds
IOException - if a read error occurs

JPEGImageReader.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.