org.geotoolkit.image.io.plugin
Class RawImageReader

Object
  extended by ImageReader
      extended by SpatialImageReader
          extended by RawImageReader
All Implemented Interfaces:
WarningProducer, Disposable, Localized

public class RawImageReader
extends SpatialImageReader

Image reader for raw binary files. The default implementation can process only inputs of type RawImageInputStream. However subclasses can process arbitrary ImageInputStream if they override the following methods:

This class provides similar functionalities than the RAW image reader provided by the Image I/O extensions for JAI library. The main difference is that this class can be extended, and provides support for color palette and "no data value" conversion as documented in the super-class. Experience also suggests that this class is faster at least for floating point values. In addition, version 1.1 of the Image I/O extension for JAI seems to have a bug in their reading of subsampled floating point values.


Restrictions on the sample model
The current implementations requires that the image in the stream has a pixel stride equals to 1. If the pixel stride may be different, consider using the reader provided by the Image I/O extensions for JAI library instead.

Since:
3.07 (derived from 2.0)
Version:
3.07
Author:
Martin Desruisseaux (Geomatys)
See Also:
RawImageInputStream
Module:
coverage/geotk-coverageio (download)    View source code for this class

Nested Class Summary
static class RawImageReader.Spi
          Service provider interface (SPI) for RawImageReaders.
 
Field Summary
 
Fields inherited from class ImageReader
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
 
Fields inherited from interface WarningProducer
LOGGER
 
Constructor Summary
RawImageReader(RawImageReader.Spi provider)
          Constructs a new image reader.
 
Method Summary
 int getHeight(int imageIndex)
          Returns the image's height.
 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.
protected  int getRawDataType(int imageIndex)
          Returns the data type which most closely represents the "raw" internal data of the image.
 ImageTypeSpecifier getRawImageType(int imageIndex)
          Returns the data type which most closely represents the "raw" internal data of the image.
 int getWidth(int imageIndex)
          Returns the image's width.
 boolean isRandomAccessEasy(int imageIndex)
          Returns true since random access is easy in uncompressed images.
 BufferedImage read(int imageIndex, ImageReadParam param)
          Reads the image indexed by imageIndex.
 
Methods inherited from class SpatialImageReader
checkBandIndex, checkImageIndex, close, collapseNoDataValues, createMetadata, dispose, flipVertically, getDefaultReadParam, getDestination, getDimension, getGridEnvelope, getImageMetadata, getImageType, getImageTypes, getStreamMetadata, hasColors, setInput, warningOccurred
 
Methods inherited from class ImageReader
abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getDestination, getFormatName, getImageMetadata, getInput, getLocale, getMinIndex, getNumThumbnails, getOriginatingProvider, getSourceRegion, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, hasThumbnails, isIgnoringMetadata, isImageTiled, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, read, readAll, readAll, readAsRenderedImage, readerSupportsThumbnails, readRaster, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, reset, setInput, setInput, setLocale
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Localized
getLocale
 

Constructor Detail

RawImageReader

public RawImageReader(RawImageReader.Spi provider)
Constructs a new image reader.

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

getNumImages

public int getNumImages(boolean allowSearch)
                 throws IllegalStateException,
                        IOException
Returns the number of images available from the current input source. The default implementation fetches this information from the input stream if it is of kind RawImageInputStream, or delegates to the super-class otherwise.

Overrides:
getNumImages in class SpatialImageReader
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 allowSearch is false and a search would be required.
Throws:
IllegalStateException - if the input source has not been set.
IOException - if an error occurs reading the information from the input source.

getWidth

public int getWidth(int imageIndex)
             throws IOException
Returns the image's width. The default implementation fetches this information from the input stream if it is of kind RawImageInputStream, or thrown an exception otherwise. Subclasses can override this method if they can get the image width in an other way.

Specified by:
getWidth in class ImageReader
Throws:
IOException - If the width can not be obtained of an I/O error occurred.

getHeight

public int getHeight(int imageIndex)
              throws IOException
Returns the image's height. The default implementation fetches this information from the input stream if it is of kind RawImageInputStream, or thrown an exception otherwise. Subclasses can override this method if they can get the height width in an other way.

Specified by:
getHeight in class ImageReader
Throws:
IOException - If the height can not be obtained of an I/O error occurred.

getNumBands

public int getNumBands(int imageIndex)
                throws IOException
Returns the number of bands available for the specified image. The default implementation fetches this information from the input stream if it is of kind RawImageInputStream, or delegates to the super-class otherwise.

Overrides:
getNumBands in class SpatialImageReader
Parameters:
imageIndex - The image index.
Returns:
The number of bands available for the specified image.
Throws:
IOException - if an error occurs reading the information from the input source.

getRawDataType

protected int getRawDataType(int imageIndex)
                      throws IOException
Returns the data type which most closely represents the "raw" internal data of the image. It should be one of DataBuffer constants. The default implementation fetches this information from the input stream if it is of kind RawImageInputStream, or returns DataBuffer.TYPE_FLOAT otherwise.

Subclasses can override this method if they can get the data type in an other way. See the super-class javadoc for an explanation about how the returned type is used.

Overrides:
getRawDataType in class SpatialImageReader
Parameters:
imageIndex - The index of the image to be queried.
Returns:
The data type.
Throws:
IOException - If an error occurs reading the format information from the input source.
See Also:
SpatialImageReader.getImageType(int, ImageReadParam, SampleConverter[]), SampleConversionType.SHIFT_SIGNED_INTEGERS

getRawImageType

public ImageTypeSpecifier getRawImageType(int imageIndex)
                                   throws IOException
Returns the data type which most closely represents the "raw" internal data of the image. The default implementation fetches this information from the input stream if it is of kind RawImageInputStream, or delegates to the super-class otherwise.

Overrides:
getRawImageType in class SpatialImageReader
Parameters:
imageIndex - The index of the image to be queried.
Returns:
The image type (never null).
Throws:
IOException - If an error occurs reading the format information from the input source.
See Also:
SpatialImageReader.getImageType(int, ImageReadParam, SampleConverter[]), SpatialImageReader.getDefaultReadParam()

isRandomAccessEasy

public boolean isRandomAccessEasy(int imageIndex)
                           throws IOException
Returns true since random access is easy in uncompressed images.

Overrides:
isRandomAccessEasy in class ImageReader
Throws:
IOException

read

public BufferedImage read(int imageIndex,
                          ImageReadParam param)
                   throws IOException
Reads the image indexed by imageIndex.

Specified by:
read in class ImageReader
Parameters:
imageIndex - The index of the image to be retrieved.
param - Parameters used to control the reading process, or null.
Returns:
The desired portion of the image.
Throws:
IOException - if an input operation failed.


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.