Package net.sourceforge.jiu.codecs.tiff

# Class TIFFImageFileDirectory

java.lang.Object
net.sourceforge.jiu.codecs.tiff.TIFFImageFileDirectory

All Implemented Interfaces:
  `TIFFConstants`

public class TIFFImageFileDirectory extends Object implements TIFFConstants
This class encapsulates all data of a TIFF image file directory (IFD).

Author:
  Marco Schmidt

## Field Summary

Fields
Modifier and Type
Field
Description
`private String`
`artist`
`private int`
`bitsPerPixel`
`private int`
`bitsPerRow`
`private int[]`
`bitsPerSample`
`private int`
`bytesBetweenSamples`
`private int`
`bytesPerRow`
`private int[]`
`bytesPerSample`
`private int`
`compression`
`private String`
`copyright`
`private Date`
`date`
`private String`
`dateTime`
`private int`
`dpiX`
`private int`
`dpiY`
`private int[]`
`extraSamples`
`private int`
`height`
`private int`
`horizontalTiles`
`private String`
`hostComputer`
`private String`
`imageDescription`
`private int`
`imageType`
`private boolean`
`invertGraySamples`
`private String`
`make`
`private String`
`model`
`private int`
`numStrips`
`private int`
`numTiles`
`private int`
`orientation`
`private Palette`
`palette`
`private int`
`photometricInterpretation`
`private int`
`pixelsPerRow`
`private int`
`planarConfiguration`
`private int`
`predictor`
`private int`
`resolutionUnit`
`private double`
`resolutionX`
`private double`
`resolutionY`
`private int`
`rowsPerStrip`
`private int`
`samplesPerPixel`
`private int[]`
`sampleTypes`
`private String`
`software`
`private Vector`
`stripByteCounts`
`private Vector`
`stripOffsets`
`private int`
`t4Options`
`private int`
`t6Options`
`private Vector`
`tags`
`private Vector`
`tileByteCounts`
`private int`
`tileHeight`
`private Vector`
`tileOffsets`
`private int`
`tileWidth`
`private TimeZone`
`timeZone`
`static final int`
`TYPE_BILEVEL_BYTE`
`static final int`
`TYPE_BILEVEL_PACKED`
`static final int`
`TYPE_CMYK32_INTERLEAVED`
`static final int`
`TYPE_CMYK32_PLANAR`
`static final int`
`TYPE_GRAY16`
`static final int`
`TYPE_GRAY4`
`static final int`
`TYPE_GRAY8`
`static final int`
`TYPE_LOGL`
`static final int`
`TYPE_LOGLUV32_INTERLEAVED`
`static final int`
`TYPE_PALETTED4`
`static final int`
`TYPE_PALETTED8`
`static final int`
`TYPE_RGB24_INTERLEAVED`
`static final int`
`TYPE_RGB48_INTERLEAVED`
`private int`
`verticalTiles`
`private int`
`width`

### Fields inherited from interface net.sourceforge.jiu.codecs.tiff.TIFFConstants

`COMPRESSION_CCITT_GROUP3_1D_MODIFIED_HUFFMAN, COMPRESSION_CCITT_T4, COMPRESSION_CCITT_T6, COMPRESSION_DEFLATED_INOFFICIAL, COMPRESSION_DEFLATED_OFFICIAL, COMPRESSION_JBIG, COMPRESSION_JBIG2, COMPRESSION_JPEG_6_0, COMPRESSION_JPEG_POST_6_0, COMPRESSION_LZW, COMPRESSION_NEXT, COMPRESSION_NONE, COMPRESSION_NONE_WORD_ALIGNED, COMPRESSION_PACKBITS, COMPRESSION_SGI_LOG_24_PACKED, COMPRESSION_SGI_LOG_RLE, COMPRESSION_THUNDERSCAN, PHOTOMETRIC_BLACK_IS_ZERO, PHOTOMETRIC_LOGL, PHOTOMETRIC_PALETTED, PHOTOMETRIC_TRUECOLOR_CMYK, PHOTOMETRIC_TRUECOLOR_LOGLUV, PHOTOMETRIC_TRUECOLOR_RGB, PHOTOMETRIC_WHITE_IS_ZERO, PLANAR_CONFIGURATION_CHUNKY, PLANAR_CONFIGURATION_PLANAR, TAG_ARTIST, TAG_BAD_FAX_LINES, TAG_BITS_PER_SAMPLE, TAG_CELL_LENGTH, TAG_CELL_WIDTH, TAG_CLEAN_FAX_DATA, TAG_COLOR_MAP, TAG_COMPRESSION, TAG_CONSECUTIVE_BAD_FAX_LINES, TAG_COPYRIGHT, TAG_DATE_TIME, TAG_DOCUMENT_NAME, TAG_EXTRA_SAMPLES, TAG_FILL_ORDER, TAG_FREE_BYTE_COUNTS, TAG_FREE_OFFSETS, TAG_GRAY_RESPONSE_CURVE, TAG_GRAY_RESPONSE_UNIT, TAG_HOST_COMPUTER, TAG_IMAGE_DESCRIPTION, TAG_IMAGE_LENGTH, TAG_IMAGE_WIDTH, TAG_LENGTH, TAG_MAKE, TAG_MAX_SAMPLE_VALUE, TAG_MIN_SAMPLE_VALUE, TAG_MODEL, TAG_NEW_SUBFILE_TYPE, TAG_ORIENTATION, TAG_PHOTOMETRIC_INTERPRETATION, TAG_PHOTOSHOP_IMAGE_RESOURCES, TAG_PLANAR_CONFIGURATION, TAG_PREDICTOR, TAG_RESOLUTION_UNIT, TAG_RESOLUTION_X, TAG_RESOLUTION_Y, TAG_ROWS_PER_STRIP, TAG_SAMPLES_PER_PIXEL, TAG_SOFTWARE, TAG_STRIP_BYTE_COUNTS, TAG_STRIP_OFFSETS, TAG_T4_OPTIONS, TAG_T6_OPTIONS, TAG_TILE_BYTE_COUNTS, TAG_TILE_HEIGHT, TAG_TILE_OFFSETS, TAG_TILE_WIDTH, TAG_TYPE_ASCII, TAG_TYPE_BYTE, TAG_TYPE_DOUBLE, TAG_TYPE_FLOAT, TAG_TYPE_LONG, TAG_TYPE_RATIONAL, TAG_TYPE_SBYTE, TAG_TYPE_SHORT, TAG_TYPE_SLONG, TAG_TYPE_SRATIONAL, TAG_TYPE_SSHORT, TAG_TYPE_UNDEFINED`

## Constructor Summary

Constructors
Constructor
Description
`TIFFImageFileDirectory()`
Initializes all members to null or -1 and creates an internal list for the tags that will be make up this directory.

## Method Summary

Modifier and Type
Method
Description
`void`
`append(TIFFTag tag)`
Adds a tag to the end of the internal list of tags.
`private void`
`checkContent()`
`int`
`computeNumBytes(int numPixels)`
TODO: regard extra samples
`String`
`getArtist()`
Returns information on the person who created the image (as stored in tag `TIFFConstants.TAG_ARTIST`).
`int`
`getBitsPerPixel()`
Returns the number of bits per pixel (not including transparency information).
`int`
`getByteCount(int tileIndex)`
Returns the number of compressed byte for a given tile.
`int`
`getBytesPerRow()`
`int`
`getCompression()`
Returns the compression method, encoded as a number as found in `TIFFConstants` (more specifically, the COMPRESSION_xyz constants).
`static String`
`getCompressionName(int method)`
Returns the name of a TIFF compression method.
`String`
`getCopyright()`
`Date`
`getDateTime()`
If a date / time tag was found in this image file directory and `initFromTags(boolean)` was called already, it was attempted to create a `Date` object from it.
`String`
`getDateTimeString()`
If there was a date / time tag in this IFD, its String value is returned.
`int`
`getDpiX()`
`int`
`getDpiY()`
`int`
`getHeight()`
`String`
`getHostComputer()`
`String`
`getImageDescription()`
`int`
`getImageType()`
`String`
`getModel()`
`int`
`getNumHorizontalTiles()`
`int`
`getNumStrips()`
`int`
`getNumTiles()`
`int`
`getNumVerticalTiles()`
`Palette`
`getPalette()`
`int`
`getPhotometricInterpretation()`
`int`
`getPredictor()`
`int`
`getRowsPerStrip()`
`int`
`getSamplesPerPixel()`
`String`
`getSoftware()`
`Vector`
`getStripOffsets()`
`int`
`getT4Options()`
`int`
`getT6Options()`
`int`
`getTileHeight()`
`long`
`getTileOffset(int tileIndex)`
`int`
`getTileWidth()`
`int`
`getTileX1(int tileIndex)`
`int`
`getTileX2(int tileIndex)`
`int`
`getTileY1(int tileIndex)`
`int`
`getTileY2(int tileIndex)`
`int`
`getWidth()`
`void`
`initFromTags(boolean check)`
`void`
`initMembers()`
`boolean`
`isGrayscale()`
`boolean`
`isPaletted()`
`boolean`
`isStriped()`
Returns `true` if the image belonging to this IFD is stored as strips, `false` otherwise.
`boolean`
`isTiled()`
Returns `true` if the image belonging to this IFD is stored as tiles, `false` otherwise.
`void`
`setTimeZone(TimeZone tz)`
Sets the time zone to be used when trying to interpret dates found in a `TIFFConstants.TAG_DATE_TIME` tag.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### TYPE_BILEVEL_PACKED

public static final int TYPE_BILEVEL_PACKED

See Also:
  - Constant Field Values

### TYPE_GRAY4

public static final int TYPE_GRAY4

See Also:
  - Constant Field Values

### TYPE_GRAY8

public static final int TYPE_GRAY8

See Also:
  - Constant Field Values

### TYPE_GRAY16

public static final int TYPE_GRAY16

See Also:
  - Constant Field Values

### TYPE_PALETTED4

public static final int TYPE_PALETTED4

See Also:
  - Constant Field Values

### TYPE_PALETTED8

public static final int TYPE_PALETTED8

See Also:
  - Constant Field Values

### TYPE_RGB24_INTERLEAVED

public static final int TYPE_RGB24_INTERLEAVED

See Also:
  - Constant Field Values

### TYPE_RGB48_INTERLEAVED

public static final int TYPE_RGB48_INTERLEAVED

See Also:
  - Constant Field Values

### TYPE_BILEVEL_BYTE

public static final int TYPE_BILEVEL_BYTE

See Also:
  - Constant Field Values

### TYPE_CMYK32_INTERLEAVED

public static final int TYPE_CMYK32_INTERLEAVED

See Also:
  - Constant Field Values

### TYPE_CMYK32_PLANAR

public static final int TYPE_CMYK32_PLANAR

See Also:
  - Constant Field Values

### TYPE_LOGLUV32_INTERLEAVED

public static final int TYPE_LOGLUV32_INTERLEAVED

See Also:
  - Constant Field Values

### TYPE_LOGL

public static final int TYPE_LOGL

See Also:
  - Constant Field Values

### artist

private String artist

### bitsPerSample

private int[] bitsPerSample

### bitsPerPixel

private int bitsPerPixel

### bitsPerRow

private int bitsPerRow

### bytesBetweenSamples

private int bytesBetweenSamples

### bytesPerSample

private int[] bytesPerSample

### bytesPerRow

private int bytesPerRow

### compression

private int compression

### copyright

private String copyright

### date

private Date date

### dateTime

private String dateTime

### dpiX

private int dpiX

### dpiY

private int dpiY

### extraSamples

private int[] extraSamples

### height

private int height

### horizontalTiles

private int horizontalTiles

### hostComputer

private String hostComputer

### imageDescription

private String imageDescription

### imageType

private int imageType

### invertGraySamples

private boolean invertGraySamples

### make

private String make

### model

private String model

### numStrips

private int numStrips

### numTiles

private int numTiles

### orientation

private int orientation

### palette

private Palette palette

### pixelsPerRow

private int pixelsPerRow

### planarConfiguration

private int planarConfiguration

### photometricInterpretation

private int photometricInterpretation

### predictor

private int predictor

### sampleTypes

private int[] sampleTypes

### resolutionUnit

private int resolutionUnit

### resolutionX

private double resolutionX

### resolutionY

private double resolutionY

### rowsPerStrip

private int rowsPerStrip

### samplesPerPixel

private int samplesPerPixel

### software

private String software

### stripByteCounts

private Vector stripByteCounts

### stripOffsets

private Vector stripOffsets

### t4Options

private int t4Options

### t6Options

private int t6Options

### tags

private Vector tags

### tileByteCounts

private Vector tileByteCounts

### tileOffsets

private Vector tileOffsets

### timeZone

private TimeZone timeZone

### tileWidth

private int tileWidth

### tileHeight

private int tileHeight

### verticalTiles

private int verticalTiles

### width

private int width

## Constructor Details

### TIFFImageFileDirectory

public TIFFImageFileDirectory()
Initializes all members to null or -1 and creates an internal list for the tags that will be make up this directory.

## Method Details

### append

public void append(TIFFTag tag)
Adds a tag to the end of the internal list of tags.

Parameters:
  `tag` - the TIFFTag instance to be appended

### checkContent

private void checkContent() throws InvalidFileStructureException, UnsupportedTypeException

Throws:
  `InvalidFileStructureException`
  `UnsupportedTypeException`

### computeNumBytes

public int computeNumBytes(int numPixels)
TODO: regard extra samples

### getArtist

public String getArtist()
Returns information on the person who created the image (as stored in tag `TIFFConstants.TAG_ARTIST`).

### getBitsPerPixel

public int getBitsPerPixel()
Returns the number of bits per pixel (not including transparency information).

### getByteCount

public int getByteCount(int tileIndex)
Returns the number of compressed byte for a given tile. Tile index must not be negative and must be smaller than the number of tiles.

Parameters:
  `tileIndex` - zero-based index of tile or strip for which the number of compressed bytes is to be returned

### getBytesPerRow

public int getBytesPerRow()

### getCompression

public int getCompression()
Returns the compression method, encoded as a number as found in `TIFFConstants` (more specifically, the COMPRESSION_xyz constants). Use `getCompressionName(int)` to get the English name of this compression method.

Returns:
  compression method

### getCompressionName

public static String getCompressionName(int method)
Returns the name of a TIFF compression method. If the name is unknown, Unknown method plus the method number is returned. This static method can be used in combination with the value from `getCompression()`.

Parameters:
  `method` - the compression method number
Returns:
  the compression method name

### getCopyright

public String getCopyright()

### getDateTime

public Date getDateTime()
If a date / time tag was found in this image file directory and `initFromTags(boolean)` was called already, it was attempted to create a `Date` object from it. This object (or `null`) is returned. Use `setTimeZone(java.util.TimeZone)` to provide a time zone before the date parsing is done.

See Also:
  - `getDateTimeString()`

### getDateTimeString

public String getDateTimeString()
If there was a date / time tag in this IFD, its String value is returned.

See Also:
  - `getDateTime()`

### getDpiX

public int getDpiX()

### getDpiY

public int getDpiY()

### getHeight

public int getHeight()

### getHostComputer

public String getHostComputer()

### getImageDescription

public String getImageDescription()

### getImageType

public int getImageType()

### getModel

public String getModel()

### getNumHorizontalTiles

public int getNumHorizontalTiles()

### getNumStrips

public int getNumStrips()

### getNumTiles

public int getNumTiles()

### getNumVerticalTiles

public int getNumVerticalTiles()

### getPalette

public Palette getPalette()

### getPhotometricInterpretation

public int getPhotometricInterpretation()

### getPredictor

public int getPredictor()

### getRowsPerStrip

public int getRowsPerStrip()

### getSamplesPerPixel

public int getSamplesPerPixel()

### getSoftware

public String getSoftware()

### getStripOffsets

public Vector getStripOffsets()

### getT4Options

public int getT4Options()

### getT6Options

public int getT6Options()

### getTileHeight

public int getTileHeight()

### getTileOffset

public long getTileOffset(int tileIndex)

### getTileWidth

public int getTileWidth()

### getTileX1

public int getTileX1(int tileIndex)

### getTileX2

public int getTileX2(int tileIndex)

### getTileY1

public int getTileY1(int tileIndex)

### getTileY2

public int getTileY2(int tileIndex)

### getWidth

public int getWidth()

### initMembers

public void initMembers()

### initFromTags

public void initFromTags(boolean check) throws InvalidFileStructureException, UnsupportedTypeException

Throws:
  `InvalidFileStructureException`
  `UnsupportedTypeException`

### isGrayscale

public boolean isGrayscale()

### isPaletted

public boolean isPaletted()

### isStriped

public boolean isStriped()
Returns `true` if the image belonging to this IFD is stored as strips, `false` otherwise.

See Also:
  - `isTiled()`

### isTiled

public boolean isTiled()
Returns `true` if the image belonging to this IFD is stored as tiles, `false` otherwise.

See Also:
  - `isStriped()`

### setTimeZone

public void setTimeZone(TimeZone tz)
Sets the time zone to be used when trying to interpret dates found in a `TIFFConstants.TAG_DATE_TIME` tag. Example call: `setTimeZone(TimeZone.getTimeZone("America/New_York");`.

Parameters:
  `tz` - TimeZone object