loci.formats.in
Class BaseTiffReader

java.lang.Object
  extended by loci.formats.FormatHandler
      extended by loci.formats.FormatReader
          extended by loci.formats.in.BaseTiffReader
All Implemented Interfaces:
IFormatHandler, IFormatReader, StatusReporter
Direct Known Subclasses:
FlexReader, FluoviewReader, GelReader, ImarisTiffReader, ImprovisionTiffReader, IPWReader, MetamorphReader, NikonReader, OMETiffReader, SEQReader, TCSReader, TiffReader, ZeissLSMReader

public abstract class BaseTiffReader
extends FormatReader

BaseTiffReader is the superclass for file format readers compatible with or derived from the TIFF 6.0 file format.

Source code:
Trac, SVN

Author:
Curtis Rueden ctrueden at wisc.edu, Melissa Linkert linkert at wisc.edu

Field Summary
protected  Hashtable[] ifds
          List of IFDs for the current TIFF.
 
Fields inherited from class loci.formats.FormatReader
collectMetadata, core, filterMetadata, group, in, metadata, metadataStore, normalizeData, saveOriginalMetadata, series, THUMBNAIL_DIMENSION
 
Fields inherited from class loci.formats.FormatHandler
currentId, debug, debugLevel, format, statusListeners, suffixes
 
Fields inherited from interface loci.formats.IFormatReader
CAN_GROUP, CANNOT_GROUP, MUST_GROUP
 
Constructor Summary
BaseTiffReader(String name, String suffix)
          Constructs a new BaseTiffReader.
BaseTiffReader(String name, String[] suffixes)
          Constructs a new BaseTiffReader.
 
Method Summary
 short[][] get16BitLookupTable()
          Gets the 16-bit color lookup table associated with the most recently opened image.
 byte[][] get8BitLookupTable()
          Gets the 8-bit color lookup table associated with the most recently opened image.
protected  String getImageCreationDate()
          Retrieves the image creation date.
protected  String getImageDescription()
          Retrieves the image description.
protected  String getImageName()
          Retrieves the image name from the TIFF.
 Object getMetadataValue(String field)
          Obtains the specified metadata field's value for the current file.
 int[] getTiffDimensions()
          Gets the dimensions of the given (possibly multi-page) TIFF file.
protected  void initFile(String id)
          Initializes the given file (parsing header information, etc.).
protected  void initMetadata()
          Populates the metadata hashtable and metadata store.
protected  void initMetadataStore()
          Populates the metadata store using the data parsed in initStandardMetadata() along with some further parsing done in the method itself.
protected  void initStandardMetadata()
          Parses standard metadata.
 boolean isThisType(byte[] block)
          Checks if the given block is a valid header for this file format.
 byte[] openBytes(int no, byte[] buf)
          Obtains the specified image from the current file into a pre-allocated byte array of (sizeX * sizeY * bytesPerPixel).
protected  void put(String key, boolean value)
           
protected  void put(String key, byte value)
           
protected  void put(String key, char value)
           
protected  void put(String key, double value)
           
protected  void put(String key, float value)
           
protected  void put(String key, Hashtable ifd, int tag)
           
protected  void put(String key, int value)
           
protected  void put(String key, long value)
           
protected  void put(String key, Object value)
           
protected  void put(String key, short value)
           
protected  void putInt(String key, Hashtable ifd, int tag)
           
protected  byte[] swapIfRequired(byte[] byteArray)
          Examines a byte array to see if it needs to be byte swapped and modifies the byte array directly.
 
Methods inherited from class loci.formats.FormatReader
addMeta, checkBytes, close, close, fileGroupOption, getChannelDimLengths, getChannelDimLengths, getChannelDimTypes, getChannelDimTypes, getCoreMetadata, getCoreMetadata, getCurrentFile, getDimensionOrder, getDimensionOrder, getEffectiveSizeC, getEffectiveSizeC, getImageCount, getImageCount, getIndex, getIndex, getMeta, getMetadata, getMetadata, getMetadataStore, getMetadataStore, getMetadataStoreRoot, getMetadataStoreRoot, getMetadataValue, getPixelType, getPixelType, getRGBChannelCount, getRGBChannelCount, getSeries, getSeries, getSeriesCount, getSeriesCount, getSizeC, getSizeC, getSizeT, getSizeT, getSizeX, getSizeX, getSizeY, getSizeY, getSizeZ, getSizeZ, getThumbSizeX, getThumbSizeX, getThumbSizeY, getThumbSizeY, getUsedFiles, getUsedFiles, getZCTCoords, getZCTCoords, isFalseColor, isGroupFiles, isIndexed, isInterleaved, isInterleaved, isInterleaved, isInterleaved, isLittleEndian, isLittleEndian, isMetadataCollected, isMetadataComplete, isMetadataFiltered, isNormalized, isOrderCertain, isOrderCertain, isOriginalMetadataPopulated, isRGB, isRGB, isUsedFile, openBytes, openBytes, openBytes, openImage, openImage, openThumbBytes, openThumbBytes, openThumbImage, openThumbImage, setGroupFiles, setId, setMetadataCollected, setMetadataFiltered, setMetadataStore, setNormalized, setOriginalMetadataPopulated, setSeries, setSeries
 
Methods inherited from class loci.formats.FormatHandler
addStatusListener, debug, getFormat, getStatusListeners, getSuffixes, isThisType, isThisType, removeStatusListener, setDebug, setDebugLevel, setId, status, status, status, trace, trace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface loci.formats.IFormatHandler
getFormat, getSuffixes, isThisType, isThisType, setId
 
Methods inherited from interface loci.formats.StatusReporter
addStatusListener, getStatusListeners, removeStatusListener
 

Field Detail

ifds

protected Hashtable[] ifds
List of IFDs for the current TIFF.

Constructor Detail

BaseTiffReader

public BaseTiffReader(String name,
                      String suffix)
Constructs a new BaseTiffReader.


BaseTiffReader

public BaseTiffReader(String name,
                      String[] suffixes)
Constructs a new BaseTiffReader.

Method Detail

getTiffDimensions

public int[] getTiffDimensions()
                        throws FormatException,
                               IOException
Gets the dimensions of the given (possibly multi-page) TIFF file.

Throws:
FormatException
IOException

isThisType

public boolean isThisType(byte[] block)
Description copied from interface: IFormatReader
Checks if the given block is a valid header for this file format.


get8BitLookupTable

public byte[][] get8BitLookupTable()
                            throws FormatException,
                                   IOException
Description copied from interface: IFormatReader
Gets the 8-bit color lookup table associated with the most recently opened image. If no images have been opened, or if isIndexed() returns false, then this returns null. Also, if getPixelType() returns anything other than INT8 or UINT8, this method will return null.

Specified by:
get8BitLookupTable in interface IFormatReader
Overrides:
get8BitLookupTable in class FormatReader
Throws:
FormatException
IOException

get16BitLookupTable

public short[][] get16BitLookupTable()
                              throws FormatException,
                                     IOException
Description copied from interface: IFormatReader
Gets the 16-bit color lookup table associated with the most recently opened image. If no images have been opened, or if isIndexed() returns false, then this returns null. Also, if getPixelType() returns anything other than INT16 or UINT16, this method will return null.

Specified by:
get16BitLookupTable in interface IFormatReader
Overrides:
get16BitLookupTable in class FormatReader
Throws:
FormatException
IOException

getMetadataValue

public Object getMetadataValue(String field)
Description copied from interface: IFormatReader
Obtains the specified metadata field's value for the current file.

Specified by:
getMetadataValue in interface IFormatReader
Overrides:
getMetadataValue in class FormatReader
Parameters:
field - the name associated with the metadata field
Returns:
the value, or null if the field doesn't exist

openBytes

public byte[] openBytes(int no,
                        byte[] buf)
                 throws FormatException,
                        IOException
Description copied from interface: IFormatReader
Obtains the specified image from the current file into a pre-allocated byte array of (sizeX * sizeY * bytesPerPixel).

Parameters:
no - the image index within the file.
buf - a pre-allocated buffer.
Returns:
the pre-allocated buffer buf for convenience.
Throws:
FormatException - if there was a problem parsing the metadata of the file.
IOException - if there was a problem reading the file.

initMetadata

protected void initMetadata()
                     throws FormatException,
                            IOException
Populates the metadata hashtable and metadata store.

Throws:
FormatException
IOException

initStandardMetadata

protected void initStandardMetadata()
                             throws FormatException,
                                    IOException
Parses standard metadata. NOTE: Absolutely no calls to the metadata store should be made in this method or methods that override this method. Data will be overwritten if you do so.

Throws:
FormatException
IOException

initMetadataStore

protected void initMetadataStore()
Populates the metadata store using the data parsed in initStandardMetadata() along with some further parsing done in the method itself. All calls to the active MetadataStore should be made in this method and only in this method. This is especially important for sub-classes that override the getters for pixel set array size, etc.


getImageName

protected String getImageName()
Retrieves the image name from the TIFF.

Returns:
the image name.

getImageCreationDate

protected String getImageCreationDate()
Retrieves the image creation date.

Returns:
the image creation date.

getImageDescription

protected String getImageDescription()
Retrieves the image description.

Returns:
the image description.

swapIfRequired

protected byte[] swapIfRequired(byte[] byteArray)
                         throws FormatException,
                                IOException
Examines a byte array to see if it needs to be byte swapped and modifies the byte array directly.

Parameters:
byteArray - The byte array to check and modify if required.
Returns:
the byteArray either swapped or not for convenience.
Throws:
IOException - if there is an error read from the file.
FormatException - if there is an error during metadata parsing.

put

protected void put(String key,
                   Object value)

put

protected void put(String key,
                   int value)

put

protected void put(String key,
                   boolean value)

put

protected void put(String key,
                   byte value)

put

protected void put(String key,
                   char value)

put

protected void put(String key,
                   double value)

put

protected void put(String key,
                   float value)

put

protected void put(String key,
                   long value)

put

protected void put(String key,
                   short value)

put

protected void put(String key,
                   Hashtable ifd,
                   int tag)

putInt

protected void putInt(String key,
                      Hashtable ifd,
                      int tag)

initFile

protected void initFile(String id)
                 throws FormatException,
                        IOException
Description copied from class: FormatReader
Initializes the given file (parsing header information, etc.). Most subclasses should override this method to perform initialization operations such as parsing metadata.

Overrides:
initFile in class FormatReader
Throws:
FormatException
IOException