org.geotools.image.io
Class SimpleImageReader

java.lang.Object
  extended byjavax.imageio.ImageReader
      extended byorg.geotools.image.io.SimpleImageReader
Direct Known Subclasses:
RawBinaryImageReader, TextImageReader

public abstract class SimpleImageReader
extends javax.imageio.ImageReader

Base class for simple image decoders. "Simple" images are usually flat binary or ASCII files with no meta-data and no color information. There pixel values may be floating point values instead of integers. Such formats are of common use in remote sensing.

This base class makes it easier to construct images from floating point values. It provides default implementations for most ImageReader methods. Since does not expect to know anything about image's color, it uses a grayscale color space scaled to fit the range of values. Displaying such an image may be very slow. Consequently, users who want to display image are encouraged to change data type and color space with Java Advanced Imaging operators after reading.

Since:
2.1
Version:
$Id: SimpleImageReader.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
RawBinaryImageReader, TextRecordImageReader, TextMatrixImageReader

Field Summary
 
Fields inherited from class javax.imageio.ImageReader
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
 
Constructor Summary
protected SimpleImageReader(javax.imageio.spi.ImageReaderSpi provider)
          Construct a new image reader.
 
Method Summary
abstract  javax.media.jai.util.Range getExpectedRange(int imageIndex, int bandIndex)
          Returns the expected range of values for a band.
 javax.imageio.metadata.IIOMetadata getImageMetadata(int imageIndex)
          Returns metadata associated with the given image.
 java.util.Iterator getImageTypes(int imageIndex)
          Returns a collection of ImageTypeSpecifier containing possible image types to which the given image may be decoded.
 int getNumBands(int imageIndex)
          Returns the number of bands available for the specified image.
 int getNumImages(boolean allowSearch)
          Returns the number of images available from the current input source.
 int getRawDataType(int imageIndex)
          Returns the data type which most closely represents the "raw" internal data of the image.
 javax.imageio.ImageTypeSpecifier getRawImageType(int imageIndex)
          Returns an image type specifier indicating the SampleModel and ColorModel which most closely represents the "raw" internal format of the image.
 javax.imageio.metadata.IIOMetadata getStreamMetadata()
          Returns metadata associated with the input source as a whole.
 void setInput(java.lang.Object input, boolean seekForwardOnly, boolean ignoreMetadata)
          Sets the input source to use.
 
Methods inherited from class javax.imageio.ImageReader
abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, dispose, getAspectRatio, getAvailableLocales, getDefaultReadParam, getDestination, getFormatName, getHeight, getImageMetadata, getInput, getLocale, getMinIndex, getNumThumbnails, getOriginatingProvider, getSourceRegion, 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, readerSupportsThumbnails, readRaster, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, reset, setInput, setInput, setLocale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleImageReader

protected SimpleImageReader(javax.imageio.spi.ImageReaderSpi provider)
Construct a new image reader.

Parameters:
provider - the ImageReaderSpi that is invoking this constructor, or null.
Method Detail

setInput

public void setInput(java.lang.Object input,
                     boolean seekForwardOnly,
                     boolean ignoreMetadata)
Sets the input source to use. If is , any currently set input source will be removed.

Parameters:
input - The input object to use for future decoding.
seekForwardOnly - If true, images and metadata may only be read in ascending order from this input source.
ignoreMetadata - If true, metadata may be ignored during reads.

getNumImages

public int getNumImages(boolean allowSearch)
                 throws java.lang.IllegalStateException,
                        java.io.IOException
Returns the number of images available from the current input source. Default implementation returns 1.

Parameters:
allowSearch - If true, the number of images will be returned even if a search is required.
Returns:
The number of images, or -1 if is false and a search would be required.
Throws:
java.lang.IllegalStateException - if the input source has not been set.
java.io.IOException - if an error occurs reading the information from the input source.

getNumBands

public int getNumBands(int imageIndex)
                throws java.io.IOException
Returns the number of bands available for the specified image. Default implementation returns 1.

Parameters:
imageIndex - The image index.
Throws:
java.io.IOException - if an error occurs reading the information from the input source.

getImageMetadata

public javax.imageio.metadata.IIOMetadata getImageMetadata(int imageIndex)
                                                    throws java.io.IOException
Returns metadata associated with the given image. Since many raw images can't store metadata, the default implementation returns .

Throws:
java.io.IOException - if an error occurs during reading.

getStreamMetadata

public javax.imageio.metadata.IIOMetadata getStreamMetadata()
                                                     throws java.io.IOException
Returns metadata associated with the input source as a whole. Since many raw images can't store metadata, the default implementation returns .

Throws:
java.io.IOException - if an error occurs during reading.

getImageTypes

public java.util.Iterator getImageTypes(int imageIndex)
                                 throws java.io.IOException
Returns a collection of ImageTypeSpecifier containing possible image types to which the given image may be decoded. The default implementation returns a singleton containing getRawImageType(int).

Parameters:
imageIndex - The index of the image to be retrieved.
Returns:
A set of suggested image types for decoding the current given image.
Throws:
java.io.IOException - If an error occurs reading the format information from the input source.

getRawImageType

public javax.imageio.ImageTypeSpecifier getRawImageType(int imageIndex)
                                                 throws java.io.IOException
Returns an image type specifier indicating the SampleModel and ColorModel which most closely represents the "raw" internal format of the image. The default implementation returns an image type specifier for a BandedSampleModel of data type getRawDataType(int).

Parameters:
imageIndex - The index of the image to be queried.
Returns:
The image type (never ).
Throws:
java.io.IOException - If an error occurs reading the format information from the input source.

getRawDataType

public int getRawDataType(int imageIndex)
                   throws java.io.IOException
Returns the data type which most closely represents the "raw" internal data of the image. It should be a constant from DataBuffer. Common types are DataBuffer.TYPE_INT, DataBuffer.TYPE_FLOAT and DataBuffer.TYPE_DOUBLE. The default implementation returns .

Parameters:
imageIndex - The index of the image to be queried.
Returns:
The data type ( by default).
Throws:
java.io.IOException - If an error occurs reading the format information from the input source.

getExpectedRange

public abstract javax.media.jai.util.Range getExpectedRange(int imageIndex,
                                                            int bandIndex)
                                                     throws java.io.IOException
Returns the expected range of values for a band. Implementation may read image data, or just returns some raisonable range.

Parameters:
imageIndex - The image index.
bandIndex - The band index. Valid index goes from inclusive to exclusive. Index are independent of any IIOParam.setSourceBands(int[]) setting.
Returns:
The expected range of values, or if unknow.
Throws:
java.io.IOException - If an error occurs reading the data information from the input source.


Copyright © GeoTools. All Rights Reserved.