it.tidalwave.imageio.tiff
Class TIFFImageReaderSupport

java.lang.Object
  extended by javax.imageio.ImageReader
      extended by it.tidalwave.imageio.raw.RAWImageReaderSupport
          extended by it.tidalwave.imageio.tiff.TIFFImageReaderSupport
Direct Known Subclasses:
CR2ImageReader, DCRImageReader, DNGImageReader, MRWImageReader, NEFImageReader, ORFImageReader, PEFImageReader, SRFImageReader

public abstract class TIFFImageReaderSupport
extends RAWImageReaderSupport

This abstract class is provided as a support for implementing, by subclassing, an ImageReader for any TIFF-based image format.

Version:
CVS $Id: TIFFImageReaderSupport.java,v 1.5 2006/02/15 13:53:53 fabriziogiudici Exp $
Author:
Fabrizio Giudici

Field Summary
protected  java.lang.Class makerNoteClass
          The class of the maker note.
 
Fields inherited from class it.tidalwave.imageio.raw.RAWImageReaderSupport
headerProcessor, iis, makerNote, metadata, metadataLoaded, primaryDirectory
 
Fields inherited from class javax.imageio.ImageReader
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
 
Constructor Summary
protected TIFFImageReaderSupport(javax.imageio.spi.ImageReaderSpi originatingProvider, java.lang.Class makerNoteClass, java.lang.Class metadataClass)
           
 
Method Summary
protected  void checkThumbnailIndex(int thumbnailIndex)
          Checks the validity of a thumbnail index.
protected  RAWMetadataSupport createMetadata(Directory primaryDirectory, Directory imageDirectory)
          This method must be implemented by concrete subclasses to create an instance of RAWMetadataSupport.
 int getHeight(int imageIndex)
           
 int getNumThumbnails(int imageIndex)
           
 int getThumbnailHeight(int imageIndex, int thumbnailIndex)
          Overrides the default ImageReader implementation to avoid to actually load the thumbnail.
 int getThumbnailWidth(int imageIndex, int thumbnailIndex)
          Overrides the default ImageReader implementation by avoiding to actually load the thumbnail.
 int getWidth(int imageIndex)
           
protected  void initializeRasterReader(int width, int height, int bitsPerSample, RasterReader rasterReader)
           
protected  java.awt.image.BufferedImage loadImage(int imageIndex)
          A default implementation that just invokes loadRAWImage().
protected  Directory loadPrimaryDirectory()
          Loads the primary directory.
protected  java.awt.image.BufferedImage loadThumbnail(int imageIndex, int thumbnailIndex)
          This method must be implemented by concrete subclasses to load a thumbnail.
protected  void processEXIFAndMakerNote(Directory directory)
          Processes the EXIF metadata, if present.
static long processHeader(javax.imageio.stream.ImageInputStream iis, HeaderProcessor skipper)
          Processes a TIFF header and sets the endianness property for the given ImageInputStream.
protected  void processMakerNote()
           
protected  void processMetadata()
          Analyzes and sets various variables to point at different pieces of metadata.
static void setByteOrder(javax.imageio.stream.ImageInputStream iis)
          Sets the byteorder of the given ImageInputStream guessing it by the marker in the next 16-bit integer.
 
Methods inherited from class it.tidalwave.imageio.raw.RAWImageReaderSupport
checkImageIndex, checkMetadataIsLoaded, createImage, dispose, disposeAll, ensureMetadataIsLoaded, failure, getImageMetadata, getImageTypes, getNumImages, getStreamMetadata, loadEmbeddedImage, loadMetadata, loadRAWImage, loadRAWRaster, processImageProgress, read, readerSupportsThumbnails, readThumbnail, reset, setInput, wrapInput
 
Methods inherited from class javax.imageio.ImageReader
abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getDefaultReadParam, getDestination, getFormatName, getImageMetadata, getInput, getLocale, getMinIndex, getOriginatingProvider, getRawImageType, getSourceRegion, getStreamMetadata, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, hasThumbnails, isIgnoringMetadata, isImageTiled, isRandomAccessEasy, isSeekForwardOnly, processImageComplete, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, read, readAll, readAll, readAsRenderedImage, readRaster, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, setInput, setInput, setLocale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

makerNoteClass

protected java.lang.Class makerNoteClass
The class of the maker note.

Constructor Detail

TIFFImageReaderSupport

protected TIFFImageReaderSupport(javax.imageio.spi.ImageReaderSpi originatingProvider,
                                 java.lang.Class makerNoteClass,
                                 java.lang.Class metadataClass)
Method Detail

getWidth

public int getWidth(int imageIndex)
             throws java.io.IOException
Specified by:
getWidth in class javax.imageio.ImageReader
Throws:
java.io.IOException

getHeight

public int getHeight(int imageIndex)
              throws java.io.IOException
Specified by:
getHeight in class javax.imageio.ImageReader
Throws:
java.io.IOException

getNumThumbnails

public int getNumThumbnails(int imageIndex)
                     throws java.io.IOException
Overrides:
getNumThumbnails in class javax.imageio.ImageReader
Throws:
java.io.IOException

getThumbnailWidth

public int getThumbnailWidth(int imageIndex,
                             int thumbnailIndex)
                      throws java.io.IOException
Overrides the default ImageReader implementation by avoiding to actually load the thumbnail.

Overrides:
getThumbnailWidth in class javax.imageio.ImageReader
Throws:
java.io.IOException

getThumbnailHeight

public int getThumbnailHeight(int imageIndex,
                              int thumbnailIndex)
                       throws java.io.IOException
Overrides the default ImageReader implementation to avoid to actually load the thumbnail.

Overrides:
getThumbnailHeight in class javax.imageio.ImageReader
Throws:
java.io.IOException

loadThumbnail

protected java.awt.image.BufferedImage loadThumbnail(int imageIndex,
                                                     int thumbnailIndex)
                                              throws java.io.IOException
Description copied from class: RAWImageReaderSupport
This method must be implemented by concrete subclasses to load a thumbnail.

Specified by:
loadThumbnail in class RAWImageReaderSupport
Parameters:
imageIndex - the index of the image
thumbnailIndex - the index of the thumbnail to load
Returns:
the loaded thumbnail
Throws:
java.io.IOException - if an I/O error occurs

loadImage

protected java.awt.image.BufferedImage loadImage(int imageIndex)
                                          throws java.io.IOException
A default implementation that just invokes loadRAWImage().

Overrides:
loadImage in class RAWImageReaderSupport
Parameters:
imageIndex - the imageIndex of the image to load - 0 is the only valid value
Returns:
the thumbnail
Throws:
java.io.IOException - if an I/O error occurs

processHeader

public static long processHeader(javax.imageio.stream.ImageInputStream iis,
                                 HeaderProcessor skipper)
                          throws java.io.IOException
Processes a TIFF header and sets the endianness property for the given ImageInputStream. Returns the offset of the primary IFD.

Parameters:
iis - the ImageInputStream
Returns:
the offset of the primary IFD
Throws:
java.io.IOException - if validation errors occur

setByteOrder

public static void setByteOrder(javax.imageio.stream.ImageInputStream iis)
                         throws java.io.IOException
Sets the byteorder of the given ImageInputStream guessing it by the marker in the next 16-bit integer.

Parameters:
iis - the ImageInputSream to set the byte order to
Throws:
java.io.IOException - if an error occurs

initializeRasterReader

protected void initializeRasterReader(int width,
                                      int height,
                                      int bitsPerSample,
                                      RasterReader rasterReader)
Parameters:
bitsPerSample -
rasterReader -

loadPrimaryDirectory

protected Directory loadPrimaryDirectory()
                                  throws java.io.IOException
Loads the primary directory.

Specified by:
loadPrimaryDirectory in class RAWImageReaderSupport
Returns:
the primary directory
Throws:
java.io.IOException - if an I/O error occurs

createMetadata

protected RAWMetadataSupport createMetadata(Directory primaryDirectory,
                                            Directory imageDirectory)
Description copied from class: RAWImageReaderSupport
This method must be implemented by concrete subclasses to create an instance of RAWMetadataSupport. Each SPI should use its own subclass.

Specified by:
createMetadata in class RAWImageReaderSupport
Parameters:
primaryDirectory - the primary directory
imageDirectory - the image directory
Returns:
the raw metadata

processMetadata

protected void processMetadata()
                        throws java.io.IOException
Description copied from class: RAWImageReaderSupport
Analyzes and sets various variables to point at different pieces of metadata.

Specified by:
processMetadata in class RAWImageReaderSupport
Throws:
java.io.IOException - if an I/O error occurs

processEXIFAndMakerNote

protected void processEXIFAndMakerNote(Directory directory)
                                throws java.io.IOException
Processes the EXIF metadata, if present. The EXIF data is added to the imageMetadata. The MakerNote is processed too.

Parameters:
directory - the primary directory
Throws:
java.io.IOException - if an I/O error occurs

processMakerNote

protected void processMakerNote()
                         throws java.io.IOException
Throws:
java.io.IOException

checkThumbnailIndex

protected void checkThumbnailIndex(int thumbnailIndex)
                            throws java.io.IOException
Checks the validity of a thumbnail index.

Parameters:
thumbnailIndex - the thumbnail index
Throws:
java.lang.IndexOutOfBoundsException - if the index is invalid
java.io.IOException