Class TIFFInputStream

java.lang.Object
java.io.InputStream
org.monte.media.tiff.TIFFInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class TIFFInputStream extends InputStream
Reads a TIFF file.

References:

TIFF TM Revision 6.0. Final — June 3, 1992. Adobe Systems Inc. http://www.exif.org/specifications.html

Author:
Werner Randelshofer
  • Constructor Details

  • Method Details

    • getByteOrder

      public ByteOrder getByteOrder()
    • setByteOrder

      public void setByteOrder(ByteOrder newValue)
    • getFirstIFDOffset

      public long getFirstIFDOffset()
    • readIFD

      public IFD readIFD(long offset) throws IOException
      Reads the IFD at the specified offset.

      An IFD consists of a 2-byte count of the number of directory entries (i.e., the number of fields), followed by a sequence of 12-byte field entries, followed by a 4-byte offset of the next IFD (or 0 if none).

      Each 12-byte IFD entry has the following format: Bytes 0-1 The Tag that identifies the field. Bytes 2-3 The field Type. Bytes 4-7 The number of values, Count of the indicated Type. Bytes 8-11 The Value Offset, the file offset (in bytes) of the Value for the field. The Value is expected to begin on a word boundary; the corresponding Value Offset will thus be an even number. This file offset may point anywhere in the file, even after the image data.

      There must be at least 1 IFD in a TIFF file and each IFD must have at least one entry.

      Throws:
      IOException
    • readIFD

      public IFD readIFD(long offset, boolean hasNextOffset, boolean isFirstIFD) throws IOException
      Reads the IFD at the specified offset.

      An IFD consists of a 2-byte count of the number of directory entries (i.e., the number of fields), followed by a sequence of 12-byte field entries, followed by a 4-byte offset of the next IFD (or 0 if none).

      Each 12-byte IFD entry has the following format: Bytes 0-1 The Tag that identifies the field. Bytes 2-3 The field Type. Bytes 4-7 The number of values, Count of the indicated Type. Bytes 8-11 The Value Offset, the file offset (in bytes) of the Value for the field. The Value is expected to begin on a word boundary; the corresponding Value Offset will thus be an even number. This file offset may point anywhere in the file, even after the image data.

      There must be at least 1 IFD in a TIFF file and each IFD must have at least one entry.

      Throws:
      IOException
    • readASCII

      public String readASCII(long offset, long length) throws IOException
      Reads an ASCII (8-bit byte that contains a 7-bit ASCII code; the last byte must be NUL (binary zero). value at the specified offset.
      Throws:
      IOException
    • readLONG

      public long readLONG(long offset) throws IOException
      Reads a LONG (32-bit (4-byte) unsigned integer). value at the specified offset.
      Throws:
      IOException
    • readLONG

      public long[] readLONG(long offset, long count) throws IOException
      Reads the specified number of LONGs (32-bit (4-byte) unsigned integer). value at the specified offset.
      Throws:
      IOException
    • readSLONG

      public int readSLONG(long offset) throws IOException
      Reads a SLONG (32-bit (4-byte) signed integer). value at the specified offset.
      Throws:
      IOException
    • readSLONG

      public int[] readSLONG(long offset, long count) throws IOException
      Reads the specified number of SLONGs (32-bit (4-byte) signed integer). value at the specified offset.
      Throws:
      IOException
    • readSHORT

      public int[] readSHORT(long offset, long count) throws IOException
      Reads the specified number of SHORTs (16-bit (2-byte) unsigned integer). value at the specified offset.
      Throws:
      IOException
    • readSSHORT

      public short[] readSSHORT(long offset, long count) throws IOException
      Reads the specified number of SSHORTs (16-bit (2-byte) signed integer). value at the specified offset.
      Throws:
      IOException
    • readRATIONAL

      public Rational readRATIONAL(long offset) throws IOException
      Reads a RATIONAL number at the specified offset.
      Throws:
      IOException
    • readSRATIONAL

      public Rational readSRATIONAL(long offset) throws IOException
      Reads a RATIONAL number at the specified offset.
      Throws:
      IOException
    • readRATIONAL

      public Rational[] readRATIONAL(long offset, long count) throws IOException
      Reads the specified number of RATIONALs at the specified offset.
      Throws:
      IOException
    • readSRATIONAL

      public Rational[] readSRATIONAL(long offset, long count) throws IOException
      Reads the specified number of RATIONALs at the specified offset.
      Throws:
      IOException
    • read

      public int read() throws IOException
      Specified by:
      read in class InputStream
      Throws:
      IOException
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Overrides:
      read in class InputStream
      Throws:
      IOException
    • read

      public int read(long offset, byte[] b, int off, int len) throws IOException
      Throws:
      IOException