Package mil.nga.tiff

Class FileDirectory


  • public class FileDirectory
    extends Object
    File Directory, represents all directory entries and can be used to read the image raster
    Author:
    osbornb
    • Constructor Detail

      • FileDirectory

        public FileDirectory​(SortedSet<FileDirectoryEntry> entries,
                             ByteReader reader)
        Constructor, for reading TIFF files
        Parameters:
        entries - file directory entries
        reader - TIFF file byte reader
      • FileDirectory

        public FileDirectory​(SortedSet<FileDirectoryEntry> entries,
                             ByteReader reader,
                             boolean cacheData)
        Constructor, for reading TIFF files
        Parameters:
        entries - file directory entries
        reader - TIFF file byte reader
        cacheData - true to cache tiles and strips
      • FileDirectory

        public FileDirectory()
        Constructor, for writing TIFF files
      • FileDirectory

        public FileDirectory​(Rasters rasters)
        Constructor, for writing TIFF files
        Parameters:
        rasters - image rasters to write
      • FileDirectory

        public FileDirectory​(SortedSet<FileDirectoryEntry> entries,
                             Rasters rasters)
        Constructor, for writing TIFF files
        Parameters:
        entries - file directory entries
        rasters - image rasters to write
    • Method Detail

      • addEntry

        public void addEntry​(FileDirectoryEntry entry)
        Add an entry
        Parameters:
        entry - file directory entry
      • setCache

        public void setCache​(boolean cacheData)
        Set whether to cache tiles. Does nothing is already caching tiles, clears the existing cache if set to false.
        Parameters:
        cacheData - true to cache tiles and strips
      • getReader

        public ByteReader getReader()
        Get the byte reader
        Returns:
        byte reader
      • isTiled

        public boolean isTiled()
        Is this a tiled image
        Returns:
        true if tiled
      • getDecoder

        public CompressionDecoder getDecoder()
        Get the compression decoder
        Returns:
        compression decoder
      • numEntries

        public int numEntries()
        Get the number of entries
        Returns:
        entry count
      • get

        public FileDirectoryEntry get​(FieldTagType fieldTagType)
        Get a file directory entry from the field tag type
        Parameters:
        fieldTagType - field tag type
        Returns:
        file directory entry
      • getEntries

        public Set<FileDirectoryEntry> getEntries()
        Get the file directory entries
        Returns:
        file directory entries
      • getFieldTagTypeMapping

        public Map<FieldTagType,​FileDirectoryEntry> getFieldTagTypeMapping()
        Get the field tag type to file directory entry mapping
        Returns:
        field tag type mapping
      • getImageWidth

        public Number getImageWidth()
        Get the image width
        Returns:
        image width
      • setImageWidth

        public void setImageWidth​(int width)
        Set the image width
        Parameters:
        width - image width
      • setImageWidthAsLong

        public void setImageWidthAsLong​(long width)
        Set the image width
        Parameters:
        width - image width
      • getImageHeight

        public Number getImageHeight()
        Get the image height
        Returns:
        image height
      • setImageHeight

        public void setImageHeight​(int height)
        Set the image height
        Parameters:
        height - image height
      • setImageHeightAsLong

        public void setImageHeightAsLong​(long height)
        Set the image height
        Parameters:
        height - image height
      • getBitsPerSample

        public List<Integer> getBitsPerSample()
        Get the bits per sample
        Returns:
        bits per sample
      • setBitsPerSample

        public void setBitsPerSample​(List<Integer> bitsPerSample)
        Set the bits per sample
        Parameters:
        bitsPerSample - bits per sample
      • setBitsPerSample

        public void setBitsPerSample​(int bitsPerSample)
        Set a single value bits per sample
        Parameters:
        bitsPerSample - bits per sample
      • getMaxBitsPerSample

        public Integer getMaxBitsPerSample()
        Get the max bits per sample
        Returns:
        max bits per sample
      • getCompression

        public Integer getCompression()
        Get the compression
        Returns:
        compression
      • setCompression

        public void setCompression​(int compression)
        Set the compression
        Parameters:
        compression - compression
      • getPhotometricInterpretation

        public Integer getPhotometricInterpretation()
        Get the photometric interpretation
        Returns:
        photometric interpretation
      • setPhotometricInterpretation

        public void setPhotometricInterpretation​(int photometricInterpretation)
        Set the photometric interpretation
        Parameters:
        photometricInterpretation - photometric interpretation
      • getStripOffsets

        public List<Number> getStripOffsets()
        Get the strip offsets
        Returns:
        strip offsets
      • setStripOffsets

        public void setStripOffsets​(List<Integer> stripOffsets)
        Set the strip offsets
        Parameters:
        stripOffsets - strip offsets
      • setStripOffsetsAsLongs

        public void setStripOffsetsAsLongs​(List<Long> stripOffsets)
        Set the strip offsets
        Parameters:
        stripOffsets - strip offsets
      • setStripOffsets

        public void setStripOffsets​(int stripOffset)
        Set a single value strip offset
        Parameters:
        stripOffset - strip offset
      • setStripOffsets

        public void setStripOffsets​(long stripOffset)
        Set a single value strip offset
        Parameters:
        stripOffset - strip offset
      • getSamplesPerPixel

        public int getSamplesPerPixel()
        Get the samples per pixel
        Returns:
        samples per pixel
        Since:
        2.0.0
      • setSamplesPerPixel

        public void setSamplesPerPixel​(int samplesPerPixel)
        Set the samples per pixel
        Parameters:
        samplesPerPixel - samples per pixel
      • getRowsPerStrip

        public Number getRowsPerStrip()
        Get the rows per strip
        Returns:
        rows per strip
      • setRowsPerStrip

        public void setRowsPerStrip​(int rowsPerStrip)
        Set the rows per strip
        Parameters:
        rowsPerStrip - rows per strip
      • setRowsPerStripAsLong

        public void setRowsPerStripAsLong​(long rowsPerStrip)
        Set the rows per strip
        Parameters:
        rowsPerStrip - rows per strip
      • getStripByteCounts

        public List<Number> getStripByteCounts()
        Get the strip byte counts
        Returns:
        strip byte counts
      • setStripByteCounts

        public void setStripByteCounts​(List<Integer> stripByteCounts)
        Set the strip byte counts
        Parameters:
        stripByteCounts - strip byte counts
      • setStripByteCountsAsLongs

        public void setStripByteCountsAsLongs​(List<Long> stripByteCounts)
        Set the strip byte counts
        Parameters:
        stripByteCounts - strip byte counts
      • setStripByteCounts

        public void setStripByteCounts​(int stripByteCount)
        Set a single value strip byte count
        Parameters:
        stripByteCount - strip byte count
      • setStripByteCounts

        public void setStripByteCounts​(long stripByteCount)
        Set a single value strip byte count
        Parameters:
        stripByteCount - strip byte count
      • getXResolution

        public List<Long> getXResolution()
        Get the x resolution
        Returns:
        x resolution
      • setXResolution

        public void setXResolution​(List<Long> xResolution)
        Set the x resolution
        Parameters:
        xResolution - x resolution
      • setXResolution

        public void setXResolution​(long xResolution)
        Set a single value x resolution
        Parameters:
        xResolution - x resolution
      • getYResolution

        public List<Long> getYResolution()
        Get the y resolution
        Returns:
        y resolution
      • setYResolution

        public void setYResolution​(List<Long> yResolution)
        Set the y resolution
        Parameters:
        yResolution - y resolution
      • setYResolution

        public void setYResolution​(long yResolution)
        Set a single value y resolution
        Parameters:
        yResolution - y resolution
      • getPlanarConfiguration

        public Integer getPlanarConfiguration()
        Get the planar configuration
        Returns:
        planar configuration
      • setPlanarConfiguration

        public void setPlanarConfiguration​(int planarConfiguration)
        Set the planar configuration
        Parameters:
        planarConfiguration - planar configuration
      • getResolutionUnit

        public Integer getResolutionUnit()
        Get the resolution unit
        Returns:
        resolution unit
      • setResolutionUnit

        public void setResolutionUnit​(int resolutionUnit)
        Set the resolution unit
        Parameters:
        resolutionUnit - resolution unit
      • getModelPixelScale

        public List<Double> getModelPixelScale()
        Get the model pixel scale
        Returns:
        model pixel scale
        Since:
        2.0.2
      • setModelPixelScale

        public void setModelPixelScale​(List<Double> modelPixelScale)
        Set the model pixel scale
        Parameters:
        modelPixelScale - pixel scale
        Since:
        2.0.5
      • getModelTiepoint

        public List<Double> getModelTiepoint()
        Get the model tiepoint
        Returns:
        model tiepoint
        Since:
        2.0.2
      • setModelTiepoint

        public void setModelTiepoint​(List<Double> modelTiepoint)
        Set the model tiepoint
        Parameters:
        modelTiepoint - model tiepoint
        Since:
        2.0.5
      • getColorMap

        public List<Integer> getColorMap()
        Get the color map
        Returns:
        color map
      • setColorMap

        public void setColorMap​(List<Integer> colorMap)
        Set the color map
        Parameters:
        colorMap - color map
      • setColorMap

        public void setColorMap​(int colorMap)
        Set a single value color map
        Parameters:
        colorMap - color map
      • getTileWidth

        public Number getTileWidth()
        Get the tile width
        Returns:
        tile width
      • setTileWidth

        public void setTileWidth​(int tileWidth)
        Set the tile width
        Parameters:
        tileWidth - tile width
      • setTileWidthAsLong

        public void setTileWidthAsLong​(long tileWidth)
        Set the tile width
        Parameters:
        tileWidth - tile width
      • getTileHeight

        public Number getTileHeight()
        Get the tile height
        Returns:
        tile height
      • setTileHeight

        public void setTileHeight​(int tileHeight)
        Set the tile height
        Parameters:
        tileHeight - tile height
      • setTileHeightAsLong

        public void setTileHeightAsLong​(long tileHeight)
        Set the tile height
        Parameters:
        tileHeight - tile height
      • getTileOffsets

        public List<Long> getTileOffsets()
        Get the tile offsets
        Returns:
        tile offsets
      • setTileOffsets

        public void setTileOffsets​(List<Long> tileOffsets)
        Set the tile offsets
        Parameters:
        tileOffsets - tile offsets
      • setTileOffsets

        public void setTileOffsets​(long tileOffset)
        Set a single value tile offset
        Parameters:
        tileOffset - tile offset
      • getTileByteCounts

        public List<Number> getTileByteCounts()
        Get the tile byte counts
        Returns:
        tile byte counts
      • setTileByteCounts

        public void setTileByteCounts​(List<Integer> tileByteCounts)
        Set the tile byte counts
        Parameters:
        tileByteCounts - tile byte counts
      • setTileByteCountsAsLongs

        public void setTileByteCountsAsLongs​(List<Long> tileByteCounts)
        Set the tile byte counts
        Parameters:
        tileByteCounts - tile byte counts
      • setTileByteCounts

        public void setTileByteCounts​(int tileByteCount)
        Set a single value tile byte count
        Parameters:
        tileByteCount - tile byte count
      • setTileByteCounts

        public void setTileByteCounts​(long tileByteCount)
        Set a single value tile byte count
        Parameters:
        tileByteCount - tile byte count
      • getSampleFormat

        public List<Integer> getSampleFormat()
        Get the sample format
        Returns:
        sample format
      • setSampleFormat

        public void setSampleFormat​(List<Integer> sampleFormat)
        Set the sample format
        Parameters:
        sampleFormat - sample format
      • setSampleFormat

        public void setSampleFormat​(int sampleFormat)
        Set a single value sample format
        Parameters:
        sampleFormat - sample format
      • getMaxSampleFormat

        public Integer getMaxSampleFormat()
        Get the max sample format
        Returns:
        max sample format
      • getPredictor

        public Integer getPredictor()
        Get the predictor
        Returns:
        predictor
        Since:
        3.0.0
      • setPredictor

        public void setPredictor​(int predictor)
        Set the predictor
        Parameters:
        predictor - predictor
        Since:
        3.0.0
      • getWriteRasters

        public Rasters getWriteRasters()
        Get the rasters for writing a TIFF file
        Returns:
        rasters image rasters
      • setWriteRasters

        public void setWriteRasters​(Rasters rasters)
        Set the rasters for writing a TIFF file
        Parameters:
        rasters - image rasters
      • readRasters

        public Rasters readRasters()
        Read the rasters
        Returns:
        rasters
      • readInterleavedRasters

        public Rasters readInterleavedRasters()
        Read the rasters as interleaved
        Returns:
        rasters
      • readRasters

        public Rasters readRasters​(ImageWindow window)
        Read the rasters
        Parameters:
        window - image window
        Returns:
        rasters
      • readInterleavedRasters

        public Rasters readInterleavedRasters​(ImageWindow window)
        Read the rasters as interleaved
        Parameters:
        window - image window
        Returns:
        rasters
      • readRasters

        public Rasters readRasters​(int[] samples)
        Read the rasters
        Parameters:
        samples - pixel samples to read
        Returns:
        rasters
      • readInterleavedRasters

        public Rasters readInterleavedRasters​(int[] samples)
        Read the rasters as interleaved
        Parameters:
        samples - pixel samples to read
        Returns:
        rasters
      • readRasters

        public Rasters readRasters​(ImageWindow window,
                                   int[] samples)
        Read the rasters
        Parameters:
        window - image window
        samples - pixel samples to read
        Returns:
        rasters
      • readInterleavedRasters

        public Rasters readInterleavedRasters​(ImageWindow window,
                                              int[] samples)
        Read the rasters as interleaved
        Parameters:
        window - image window
        samples - pixel samples to read
        Returns:
        rasters
      • readRasters

        public Rasters readRasters​(boolean sampleValues,
                                   boolean interleaveValues)
        Read the rasters
        Parameters:
        sampleValues - true to read results per sample
        interleaveValues - true to read results as interleaved
        Returns:
        rasters
      • readRasters

        public Rasters readRasters​(ImageWindow window,
                                   boolean sampleValues,
                                   boolean interleaveValues)
        Read the rasters
        Parameters:
        window - image window
        sampleValues - true to read results per sample
        interleaveValues - true to read results as interleaved
        Returns:
        rasters
      • readRasters

        public Rasters readRasters​(int[] samples,
                                   boolean sampleValues,
                                   boolean interleaveValues)
        Read the rasters
        Parameters:
        samples - pixel samples to read
        sampleValues - true to read results per sample
        interleaveValues - true to read results as interleaved
        Returns:
        rasters
      • readRasters

        public Rasters readRasters​(ImageWindow window,
                                   int[] samples,
                                   boolean sampleValues,
                                   boolean interleaveValues)
        Read the rasters
        Parameters:
        window - image window
        samples - pixel samples to read
        sampleValues - true to read results per sample
        interleaveValues - true to read results as interleaved
        Returns:
        rasters
      • getFieldTypeForSample

        public FieldType getFieldTypeForSample​(int sampleIndex)
        Get the field type for the sample
        Parameters:
        sampleIndex - sample index
        Returns:
        field type
      • getIntegerEntryValue

        public Integer getIntegerEntryValue​(FieldTagType fieldTagType)
        Get an integer entry value
        Parameters:
        fieldTagType - field tag type
        Returns:
        integer value
        Since:
        2.0.0
      • setUnsignedIntegerEntryValue

        public void setUnsignedIntegerEntryValue​(FieldTagType fieldTagType,
                                                 int value)
        Set an unsigned integer entry value for the field tag type
        Parameters:
        fieldTagType - field tag type
        value - unsigned integer value (16 bit)
        Since:
        2.0.0
      • getNumberEntryValue

        public Number getNumberEntryValue​(FieldTagType fieldTagType)
        Get an number entry value
        Parameters:
        fieldTagType - field tag type
        Returns:
        number value
        Since:
        2.0.0
      • setUnsignedLongEntryValue

        public void setUnsignedLongEntryValue​(FieldTagType fieldTagType,
                                              long value)
        Set an unsigned long entry value for the field tag type
        Parameters:
        fieldTagType - field tag type
        value - unsigned long value (32 bit)
        Since:
        2.0.0
      • getStringEntryValue

        public String getStringEntryValue​(FieldTagType fieldTagType)
        Get a string entry value for the field tag type
        Parameters:
        fieldTagType - field tag type
        Returns:
        string value
        Since:
        2.0.0
      • setStringEntryValue

        public void setStringEntryValue​(FieldTagType fieldTagType,
                                        String value)
        Set string value for the field tag type
        Parameters:
        fieldTagType - field tag type
        value - string value
        Since:
        2.0.0
      • getIntegerListEntryValue

        public List<Integer> getIntegerListEntryValue​(FieldTagType fieldTagType)
        Get an integer list entry value
        Parameters:
        fieldTagType - field tag type
        Returns:
        integer list value
        Since:
        2.0.0
      • getDoubleListEntryValue

        public List<Double> getDoubleListEntryValue​(FieldTagType fieldTagType)
        Get a double list entry value
        Parameters:
        fieldTagType - field tag type
        Returns:
        double list value
        Since:
        2.0.2
      • setDoubleListEntryValue

        public void setDoubleListEntryValue​(FieldTagType fieldTagType,
                                            List<Double> value)
        Set a double list entry value
        Parameters:
        fieldTagType - field tag type
        value - double list value
        Since:
        2.0.5
      • setUnsignedIntegerListEntryValue

        public void setUnsignedIntegerListEntryValue​(FieldTagType fieldTagType,
                                                     List<Integer> value)
        Set an unsigned integer list of values for the field tag type
        Parameters:
        fieldTagType - field tag type
        value - integer list value
        Since:
        2.0.0
      • getMaxIntegerEntryValue

        public Integer getMaxIntegerEntryValue​(FieldTagType fieldTagType)
        Get the max integer from integer list entry values
        Parameters:
        fieldTagType - field tag type
        Returns:
        max integer value
        Since:
        2.0.0
      • getNumberListEntryValue

        public List<Number> getNumberListEntryValue​(FieldTagType fieldTagType)
        Get a number list entry value
        Parameters:
        fieldTagType - field tag type
        Returns:
        long list value
        Since:
        2.0.0
      • getLongListEntryValue

        public List<Long> getLongListEntryValue​(FieldTagType fieldTagType)
        Get a long list entry value
        Parameters:
        fieldTagType - field tag type
        Returns:
        long list value
        Since:
        2.0.0
      • setUnsignedLongListEntryValue

        public void setUnsignedLongListEntryValue​(FieldTagType fieldTagType,
                                                  List<Long> value)
        Set an unsigned long list of values for the field tag type
        Parameters:
        fieldTagType - field tag type
        value - long list value
        Since:
        2.0.0
      • setRationalEntryValue

        public void setRationalEntryValue​(FieldTagType fieldTagType,
                                          List<Long> value)
        Set rational value for the field tag type
        Parameters:
        fieldTagType - field tag type
        value - long list value
        Since:
        2.0.1
      • size

        public long size()
        Size in bytes of the Image File Directory (all contiguous)
        Returns:
        size in bytes
      • sizeWithValues

        public long sizeWithValues()
        Size in bytes of the image file directory including entry values (not contiguous bytes)
        Returns:
        size in bytes