Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.batik.ext.awt.image.codec.tiff
Class TIFFDirectory  view TIFFDirectory download TIFFDirectory.java

java.lang.Object
  extended byorg.apache.batik.ext.awt.image.codec.tiff.TIFFDirectory
All Implemented Interfaces:
java.io.Serializable

public class TIFFDirectory
extends java.lang.Object
implements java.io.Serializable

A class representing an Image File Directory (IFD) from a TIFF 6.0 stream. The TIFF file format is described in more detail in the comments for the TIFFDescriptor class.

A TIFF IFD consists of a set of TIFFField tags. Methods are provided to query the set of tags and to obtain the raw field array. In addition, convenience methods are provided for acquiring the values of tags that contain a single value that fits into a byte, int, long, float, or double.

Every TIFF file is made up of one or more public IFDs that are joined in a linked list, rooted in the file header. A file may also contain so-called private IFDs that are referenced from tag data and do not appear in the main list.

This class is not a committed part of the JAI API. It may be removed or changed in future releases of JAI.


Field Summary
(package private)  java.util.Map fieldIndex
          A Hashtable indexing the fields by tag number.
(package private)  TIFFField[] fields
          An array of TIFFFields.
(package private)  long IFDOffset
          The offset of this IFD.
(package private)  boolean isBigEndian
          A boolean storing the endianness of the stream.
(package private)  long nextIFDOffset
          The offset of the next IFD.
(package private)  int numEntries
          The number of entries in the IFD.
private static int[] sizeOfType
           
 
Constructor Summary
(package private) TIFFDirectory()
          The default constructor.
  TIFFDirectory(org.apache.batik.ext.awt.image.codec.SeekableStream stream, int directory)
          Constructs a TIFFDirectory from a SeekableStream.
  TIFFDirectory(org.apache.batik.ext.awt.image.codec.SeekableStream stream, long ifd_offset, int directory)
          Constructs a TIFFDirectory by reading a SeekableStream.
 
Method Summary
 TIFFField getField(int tag)
          Returns the value of a given tag as a TIFFField, or null if the tag is not present.
 byte getFieldAsByte(int tag)
          Returns the value of index 0 of a given tag as a byte.
 byte getFieldAsByte(int tag, int index)
          Returns the value of a particular index of a given tag as a byte.
 double getFieldAsDouble(int tag)
          Returns the value of index 0 of a given tag as a double.
 double getFieldAsDouble(int tag, int index)
          Returns the value of a particular index of a given tag as a double.
 float getFieldAsFloat(int tag)
          Returns the value of index 0 of a given tag as a float.
 float getFieldAsFloat(int tag, int index)
          Returns the value of a particular index of a given tag as a float.
 long getFieldAsLong(int tag)
          Returns the value of index 0 of a given tag as a long.
 long getFieldAsLong(int tag, int index)
          Returns the value of a particular index of a given tag as a long.
 TIFFField[] getFields()
          Returns an array of TIFFFields containing all the fields in this directory.
 long getIFDOffset()
          Returns the offset of the IFD corresponding to this TIFFDirectory.
 long getNextIFDOffset()
          Returns the offset of the next IFD after the IFD corresponding to this TIFFDirectory.
static int getNumDirectories(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
          Returns the number of image directories (subimages) stored in a given TIFF file, represented by a SeekableStream.
 int getNumEntries()
          Returns the number of directory entries.
 int[] getTags()
          Returns an ordered array of ints indicating the tag values.
private  void initialize(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
           
 boolean isBigEndian()
          Returns a boolean indicating whether the byte order used in the the TIFF file is big-endian.
 boolean isTagPresent(int tag)
          Returns true if a tag appears in the directory.
private static boolean isValidEndianTag(int endian)
           
private  double readDouble(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
           
private  float readFloat(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
           
private  int readInt(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
           
private  long readLong(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
           
private  short readShort(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
           
private  long readUnsignedInt(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
           
private static long readUnsignedInt(org.apache.batik.ext.awt.image.codec.SeekableStream stream, boolean isBigEndian)
           
private  int readUnsignedShort(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
           
private static int readUnsignedShort(org.apache.batik.ext.awt.image.codec.SeekableStream stream, boolean isBigEndian)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isBigEndian

boolean isBigEndian
A boolean storing the endianness of the stream.


numEntries

int numEntries
The number of entries in the IFD.


fields

TIFFField[] fields
An array of TIFFFields.


fieldIndex

java.util.Map fieldIndex
A Hashtable indexing the fields by tag number.


IFDOffset

long IFDOffset
The offset of this IFD.


nextIFDOffset

long nextIFDOffset
The offset of the next IFD.


sizeOfType

private static final int[] sizeOfType
Constructor Detail

TIFFDirectory

TIFFDirectory()
The default constructor.


TIFFDirectory

public TIFFDirectory(org.apache.batik.ext.awt.image.codec.SeekableStream stream,
                     int directory)
              throws java.io.IOException
Constructs a TIFFDirectory from a SeekableStream. The directory parameter specifies which directory to read from the linked list present in the stream; directory 0 is normally read but it is possible to store multiple images in a single TIFF file by maintaing multiple directories.


TIFFDirectory

public TIFFDirectory(org.apache.batik.ext.awt.image.codec.SeekableStream stream,
                     long ifd_offset,
                     int directory)
              throws java.io.IOException
Constructs a TIFFDirectory by reading a SeekableStream. The ifd_offset parameter specifies the stream offset from which to begin reading; this mechanism is sometimes used to store private IFDs within a TIFF file that are not part of the normal sequence of IFDs.

Method Detail

isValidEndianTag

private static boolean isValidEndianTag(int endian)

initialize

private void initialize(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
                 throws java.io.IOException

getNumEntries

public int getNumEntries()
Returns the number of directory entries.


getField

public TIFFField getField(int tag)
Returns the value of a given tag as a TIFFField, or null if the tag is not present.


isTagPresent

public boolean isTagPresent(int tag)
Returns true if a tag appears in the directory.


getTags

public int[] getTags()
Returns an ordered array of ints indicating the tag values.


getFields

public TIFFField[] getFields()
Returns an array of TIFFFields containing all the fields in this directory.


getFieldAsByte

public byte getFieldAsByte(int tag,
                           int index)
Returns the value of a particular index of a given tag as a byte. The caller is responsible for ensuring that the tag is present and has type TIFFField.TIFF_SBYTE, TIFF_BYTE, or TIFF_UNDEFINED.


getFieldAsByte

public byte getFieldAsByte(int tag)
Returns the value of index 0 of a given tag as a byte. The caller is responsible for ensuring that the tag is present and has type TIFFField.TIFF_SBYTE, TIFF_BYTE, or TIFF_UNDEFINED.


getFieldAsLong

public long getFieldAsLong(int tag,
                           int index)
Returns the value of a particular index of a given tag as a long. The caller is responsible for ensuring that the tag is present and has type TIFF_BYTE, TIFF_SBYTE, TIFF_UNDEFINED, TIFF_SHORT, TIFF_SSHORT, TIFF_SLONG or TIFF_LONG.


getFieldAsLong

public long getFieldAsLong(int tag)
Returns the value of index 0 of a given tag as a long. The caller is responsible for ensuring that the tag is present and has type TIFF_BYTE, TIFF_SBYTE, TIFF_UNDEFINED, TIFF_SHORT, TIFF_SSHORT, TIFF_SLONG or TIFF_LONG.


getFieldAsFloat

public float getFieldAsFloat(int tag,
                             int index)
Returns the value of a particular index of a given tag as a float. The caller is responsible for ensuring that the tag is present and has numeric type (all but TIFF_UNDEFINED and TIFF_ASCII).


getFieldAsFloat

public float getFieldAsFloat(int tag)
Returns the value of index 0 of a given tag as a float. The caller is responsible for ensuring that the tag is present and has numeric type (all but TIFF_UNDEFINED and TIFF_ASCII).


getFieldAsDouble

public double getFieldAsDouble(int tag,
                               int index)
Returns the value of a particular index of a given tag as a double. The caller is responsible for ensuring that the tag is present and has numeric type (all but TIFF_UNDEFINED and TIFF_ASCII).


getFieldAsDouble

public double getFieldAsDouble(int tag)
Returns the value of index 0 of a given tag as a double. The caller is responsible for ensuring that the tag is present and has numeric type (all but TIFF_UNDEFINED and TIFF_ASCII).


readShort

private short readShort(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
                 throws java.io.IOException

readUnsignedShort

private int readUnsignedShort(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
                       throws java.io.IOException

readInt

private int readInt(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
             throws java.io.IOException

readUnsignedInt

private long readUnsignedInt(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
                      throws java.io.IOException

readLong

private long readLong(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
               throws java.io.IOException

readFloat

private float readFloat(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
                 throws java.io.IOException

readDouble

private double readDouble(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
                   throws java.io.IOException

readUnsignedShort

private static int readUnsignedShort(org.apache.batik.ext.awt.image.codec.SeekableStream stream,
                                     boolean isBigEndian)
                              throws java.io.IOException

readUnsignedInt

private static long readUnsignedInt(org.apache.batik.ext.awt.image.codec.SeekableStream stream,
                                    boolean isBigEndian)
                             throws java.io.IOException

getNumDirectories

public static int getNumDirectories(org.apache.batik.ext.awt.image.codec.SeekableStream stream)
                             throws java.io.IOException
Returns the number of image directories (subimages) stored in a given TIFF file, represented by a SeekableStream.


isBigEndian

public boolean isBigEndian()
Returns a boolean indicating whether the byte order used in the the TIFF file is big-endian. That is, whether the byte order is from the most significant to the least significant.


getIFDOffset

public long getIFDOffset()
Returns the offset of the IFD corresponding to this TIFFDirectory.


getNextIFDOffset

public long getNextIFDOffset()
Returns the offset of the next IFD after the IFD corresponding to this TIFFDirectory.