org.geotoolkit.image.io.plugin
Class RawTiffImageReader

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

public class RawTiffImageReader
extends SpatialImageReader

An image reader for uncompressed TIFF files or RGB images. This image reader duplicates the works performed by the reader provided in Image I/O extension for Java Advanced Imaging, but is specialized to the specific case of uncompressed files. For such case, this RawTiffImageReader is faster.

RawTiffImageReader has the following restrictions:

Because of the above-cited restrictions, this reader registers itself only after the JAI readers (unless otherwise specified). Users wanting this reader should request for it explicitly, for example as below:

ImageReaderSpi spi = IIORegistry.getDefaultInstance().getServiceProviderByClass(RawTiffImageReader.class);
ImageReader reader = spi.createReaderInstance();
This image reader can also process Big TIFF images.

Since:
3.16
Version:
3.16
Author:
Martin Desruisseaux (Geomatys)
Module:
coverage/geotk-coverageio (download)    View source code for this class

Nested Class Summary
static class RawTiffImageReader.Spi
          Service provider interface (SPI) for RawTiffImageReaders.
 
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
RawTiffImageReader(RawTiffImageReader.Spi provider)
          Creates a new reader.
 
Method Summary
protected  void close()
          Closes the file channel.
 int getHeight(int imageIndex)
          Returns the height of the image at the given index.
 Iterator<ImageTypeSpecifier> 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 file.
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 SampleModel and ColorModel which most closely represents the internal format of the image.
 int getTileHeight(int imageIndex)
          Returns the height of the tiles in the given image.
 int getTileWidth(int imageIndex)
          Returns the width of the tiles in the given image.
 int getWidth(int imageIndex)
          Returns the width of the image at the given index.
 boolean hasColors(int imageIndex)
          Returns true since TIFF images have color palette.
 boolean isImageTiled(int imageIndex)
          Returns true if the image is organized into tiles.
 boolean isRandomAccessEasy(int imageIndex)
          Returns true since this image format places no inherent impediment on random access to pixels.
 BufferedImage read(int imageIndex, ImageReadParam param)
          Reads the image at the given index.
 
Methods inherited from class SpatialImageReader
checkBandIndex, checkImageIndex, collapseNoDataValues, createMetadata, dispose, flipVertically, getDefaultReadParam, getDestination, getDimension, getGridEnvelope, getImageMetadata, getImageType, getStreamMetadata, 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, hasThumbnails, isIgnoringMetadata, 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

RawTiffImageReader

public RawTiffImageReader(RawTiffImageReader.Spi provider)
Creates a new reader.

Parameters:
provider - The provider, or null if none.
Method Detail

isRandomAccessEasy

public boolean isRandomAccessEasy(int imageIndex)
                           throws IOException
Returns true since this image format places no inherent impediment on random access to pixels. Actually, having easy random access is the whole point of uncompressed TIFF files in many GIS infrastructures.

Overrides:
isRandomAccessEasy in class ImageReader
Parameters:
imageIndex - The image index (ignored by this implementation).
Returns:
Always true in this implementation.
Throws:
IOException - If an I/O access was necessary and failed.

getNumImages

public int getNumImages(boolean allowSearch)
                 throws IOException
Returns the number of images available from the current input file. This method will scan the file the first time it is invoked with a true argument value.

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:
IOException - if an error occurs reading the information from the input source.

getNumBands

public int getNumBands(int imageIndex)
                throws IOException
Returns the number of bands available for the specified image.

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.

getWidth

public int getWidth(int imageIndex)
             throws IOException
Returns the width of the image at the given index.

Specified by:
getWidth in class ImageReader
Parameters:
imageIndex - the index of the image to be queried.
Returns:
The width of the given image.
Throws:
IOException - If an error occurred while reading the file.

getHeight

public int getHeight(int imageIndex)
              throws IOException
Returns the height of the image at the given index.

Specified by:
getHeight in class ImageReader
Parameters:
imageIndex - the index of the image to be queried.
Returns:
The height of the given image.
Throws:
IOException - If an error occurred while reading the file.

getTileWidth

public int getTileWidth(int imageIndex)
                 throws IOException
Returns the width of the tiles in the given image.

Overrides:
getTileWidth in class ImageReader
Parameters:
imageIndex - the index of the image to be queried.
Returns:
The width of the tile in the given image.
Throws:
IOException - If an error occurred while reading the file.

getTileHeight

public int getTileHeight(int imageIndex)
                  throws IOException
Returns the height of the tiles in the given image.

Overrides:
getTileHeight in class ImageReader
Parameters:
imageIndex - the index of the image to be queried.
Returns:
The height of the tile in the given image.
Throws:
IOException - If an error occurred while reading the file.

isImageTiled

public boolean isImageTiled(int imageIndex)
                     throws IOException
Returns true if the image is organized into tiles.

Overrides:
isImageTiled in class ImageReader
Parameters:
imageIndex - the index of the image to be queried.
Returns:
true if the image is organized into tiles.
Throws:
IOException - If an error occurred while reading the file.

hasColors

public boolean hasColors(int imageIndex)
                  throws IOException
Returns true since TIFF images have color palette.

Overrides:
hasColors in class SpatialImageReader
Parameters:
imageIndex - The index of the image to be queried.
Returns:
true if the image at the given index has a color palette.
Throws:
IOException - If an error occurs reading the information from the input source.
See Also:
SpatialImageReadParam.setPaletteName(String)

getRawDataType

protected int getRawDataType(int imageIndex)
                      throws IOException
Returns the data type which most closely represents the "raw" internal data of the image. The default implementation is as below:
return getRawImageType(imageIndex).getSampleModel().getDataType();

Overrides:
getRawDataType in class SpatialImageReader
Parameters:
imageIndex - The index of the image to be queried.
Returns:
The data type (typically DataBuffer.TYPE_BYTE).
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 SampleModel and ColorModel which most closely represents the internal format of the image.

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

getImageTypes

public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex)
                                           throws 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 only the raw image type.

Overrides:
getImageTypes in class SpatialImageReader
Parameters:
imageIndex - The index of the image to be queried.
Returns:
A set of suggested image types for decoding the current given image.
Throws:
IOException - If an error occurs reading the format information from the input source.

read

public BufferedImage read(int imageIndex,
                          ImageReadParam param)
                   throws IOException
Reads the image at the given index.

Specified by:
read in class ImageReader
Parameters:
imageIndex - The index of the image to read.
param - Parameters used to control the reading process, or null.
Returns:
The image.
Throws:
IOException - If an error occurred while reading the image.

close

protected void close()
              throws IOException
Closes the file channel. If the channel is already closed, then this method does nothing.

Overrides:
close in class SpatialImageReader
Throws:
IOException - If an error occurred while closing the channel.


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