Package com.aowagie.text.pdf.codec
Class TIFFDirectory
java.lang.Object
com.aowagie.text.pdf.codec.TIFFDirectory
- All Implemented Interfaces:
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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Hashtable
A Hashtable indexing the fields by tag number.private TIFFField[]
An array of TIFFFields.private long
The offset of this IFD.private boolean
A boolean storing the endianness of the stream.private long
The offset of the next IFD.private int
The number of entries in the IFD.private static final long
private static final int[]
-
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor.TIFFDirectory
(RandomAccessFileOrArray stream, int directory) Constructs a TIFFDirectory from a SeekableStream. -
Method Summary
Modifier and TypeMethodDescription(package private) TIFFField
getField
(int tag) Returns the value of a given tag as a TIFFField, or null if the tag is not present.private byte
getFieldAsByte
(int tag, int index) Returns the value of a particular index of a given tag as a byte.private double
getFieldAsDouble
(int tag, int index) Returns the value of a particular index of a given tag as a double.private float
getFieldAsFloat
(int tag, int index) Returns the value of a particular index of a given tag as a float.(package private) long
getFieldAsLong
(int tag) Returns the value of index 0 of a given tag as a long.private long
getFieldAsLong
(int tag, int index) Returns the value of a particular index of a given tag as a long.Returns an array of TIFFFields containing all the fields in this directory.long
Returns the offset of the IFD corresponding to thisTIFFDirectory
.long
Returns the offset of the next IFD after the IFD corresponding to thisTIFFDirectory
.int
Returns the number of directory entries.int[]
getTags()
Returns an ordered array of ints indicating the tag values.private void
initialize
(RandomAccessFileOrArray stream) boolean
Returns a boolean indicating whether the byte order used in the the TIFF file is big-endian (i.e.(package private) boolean
isTagPresent
(int tag) Returns true if a tag appears in the directory.private static boolean
isValidEndianTag
(int endian) private double
readDouble
(RandomAccessFileOrArray stream) private float
readFloat
(RandomAccessFileOrArray stream) private int
readInt
(RandomAccessFileOrArray stream) private long
readLong
(RandomAccessFileOrArray stream) private short
readShort
(RandomAccessFileOrArray stream) private long
private static long
readUnsignedInt
(RandomAccessFileOrArray stream, boolean isBigEndian) private int
private static int
readUnsignedShort
(RandomAccessFileOrArray stream, boolean isBigEndian)
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
isBigEndian
private boolean isBigEndianA boolean storing the endianness of the stream. -
numEntries
private int numEntriesThe number of entries in the IFD. -
fields
An array of TIFFFields. -
fieldIndex
A Hashtable indexing the fields by tag number. -
IFDOffset
private long IFDOffsetThe offset of this IFD. -
nextIFDOffset
private long nextIFDOffsetThe offset of the next IFD. -
sizeOfType
private static final int[] sizeOfType
-
-
Constructor Details
-
TIFFDirectory
TIFFDirectory()The default constructor. -
TIFFDirectory
TIFFDirectory(RandomAccessFileOrArray stream, int directory) throws 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 maintaining multiple directories.- Parameters:
stream
- a SeekableStream to read from.directory
- the index of the directory to read.- Throws:
IOException
-
-
Method Details
-
isValidEndianTag
private static boolean isValidEndianTag(int endian) -
initialize
- Throws:
IOException
-
getNumEntries
public int getNumEntries()Returns the number of directory entries. -
getField
Returns the value of a given tag as a TIFFField, or null if the tag is not present. -
isTagPresent
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
Returns an array of TIFFFields containing all the fields in this directory. -
getFieldAsByte
private 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. -
getFieldAsLong
private 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
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
private 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). -
getFieldAsDouble
private 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). -
readShort
- Throws:
IOException
-
readUnsignedShort
- Throws:
IOException
-
readInt
- Throws:
IOException
-
readUnsignedInt
- Throws:
IOException
-
readLong
- Throws:
IOException
-
readFloat
- Throws:
IOException
-
readDouble
- Throws:
IOException
-
readUnsignedShort
private static int readUnsignedShort(RandomAccessFileOrArray stream, boolean isBigEndian) throws IOException - Throws:
IOException
-
readUnsignedInt
private static long readUnsignedInt(RandomAccessFileOrArray stream, boolean isBigEndian) throws IOException - Throws:
IOException
-
isBigEndian
public boolean isBigEndian()Returns a boolean indicating whether the byte order used in the the TIFF file is big-endian (i.e. 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 thisTIFFDirectory
. -
getNextIFDOffset
public long getNextIFDOffset()Returns the offset of the next IFD after the IFD corresponding to thisTIFFDirectory
.
-