Class TiffWriter

java.lang.Object
loci.formats.FormatHandler
loci.formats.FormatWriter
loci.formats.out.TiffWriter
All Implemented Interfaces:
Closeable, AutoCloseable, loci.formats.ICompressedTileWriter, loci.formats.IFormatHandler, loci.formats.IFormatWriter, loci.formats.IMetadataConfigurable, loci.formats.IPyramidHandler
Direct Known Subclasses:
OMETiffWriter

public class TiffWriter extends loci.formats.FormatWriter
TiffWriter is the file format writer for TIFF files.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Whether or not BigTIFF can be used automatically.
    protected boolean
    Whether or not to check the parameters passed to saveBytes.
    static final String
     
    static final String
     
    static final String
     
    static final String
     
    static final String
     
    static final String
     
    protected loci.common.RandomAccessInputStream
    Input stream to use when overwriting data.
    protected boolean
    Whether or not the output file is a BigTIFF file.
    protected TiffSaver
    The TiffSaver that will do most of the writing.
    protected int
    The tile width which will be used for writing.
    protected int
    The tile height which will be used for writing.

    Fields inherited from class loci.formats.FormatWriter

    cm, compression, compressionTypes, fps, initialized, interleaved, metadataRetrieve, options, out, resolution, resolutionData, sequential, series, validBits

    Fields inherited from class loci.formats.FormatHandler

    COMPRESSION_SUFFIXES, currentId, format, LOGGER, metadataOptions, suffixes
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    TiffWriter(String format, String[] exts)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    void
     
    protected loci.common.RandomAccessInputStream
     
    protected TiffSaver
     
    loci.formats.codec.Codec
     
    int[]
     
    int
     
    int
     
    int
     
    protected IFD
     
    protected int
    prepareToWriteImage(int no, byte[] buf, IFD ifd, int x, int y, int w, int h)
    Performs the preparation for work prior to the usage of the TIFF saver.
    void
    saveBytes(int no, byte[] buf, int x, int y, int w, int h)
     
    void
    saveBytes(int no, byte[] buf, IFD ifd)
    Saves the given image to the specified (possibly already open) file.
    void
    saveBytes(int no, byte[] buf, IFD ifd, int x, int y, int w, int h)
    Saves the given image to the specified series in the current file.
    void
    saveCompressedBytes(int no, byte[] buf, int x, int y, int w, int h)
     
    void
    setBigTiff(boolean bigTiff)
    Sets whether or not BigTIFF files should be written.
    void
    setCanDetectBigTiff(boolean detect)
    Sets whether or not BigTIFF can be used automatically based upon the input data size (true by default).
    void
     
    int
    setTileSizeX(int tileSize)
     
    int
    setTileSizeY(int tileSize)
     
    protected void
     

    Methods inherited from class loci.formats.FormatWriter

    changeOutputFile, checkParams, createOutputStream, getCodecOptions, getColorModel, getCompression, getCompressionTypes, getFramesPerSecond, getMetadataRetrieve, getPixelTypes, getPlaneCount, getResolution, getResolutionCount, getResolutions, getSamplesPerPixel, getSamplesPerPixel, getSeries, getSizeX, getSizeY, hasResolutions, isFullPlane, isInterleaved, isSupportedType, saveBytes, saveBytes, savePlane, savePlane, savePlane, seekToPlaneOffset, setCodecOptions, setColorModel, setCompression, setFramesPerSecond, setInterleaved, setMetadataRetrieve, setResolution, setResolutions, setSeries, setValidBitsPerPixel, setWriteSequentially

    Methods inherited from class loci.formats.FormatHandler

    checkSuffix, checkSuffix, getFormat, getMetadataOptions, getNativeDataType, getSuffixes, getSupportedMetadataLevels, isThisType, setMetadataOptions

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface loci.formats.IFormatHandler

    getFormat, getNativeDataType, getSuffixes, isThisType

    Methods inherited from interface loci.formats.IMetadataConfigurable

    getMetadataOptions, getSupportedMetadataLevels, setMetadataOptions
  • Field Details

    • COMPRESSION_UNCOMPRESSED

      public static final String COMPRESSION_UNCOMPRESSED
    • COMPRESSION_LZW

      public static final String COMPRESSION_LZW
    • COMPRESSION_J2K

      public static final String COMPRESSION_J2K
    • COMPRESSION_J2K_LOSSY

      public static final String COMPRESSION_J2K_LOSSY
    • COMPRESSION_JPEG

      public static final String COMPRESSION_JPEG
    • COMPRESSION_ZLIB

      public static final String COMPRESSION_ZLIB
    • isBigTiff

      protected boolean isBigTiff
      Whether or not the output file is a BigTIFF file.
    • canDetectBigTiff

      protected boolean canDetectBigTiff
      Whether or not BigTIFF can be used automatically.
    • tiffSaver

      protected TiffSaver tiffSaver
      The TiffSaver that will do most of the writing.
    • in

      protected loci.common.RandomAccessInputStream in
      Input stream to use when overwriting data.
    • checkParams

      protected boolean checkParams
      Whether or not to check the parameters passed to saveBytes.
    • tileSizeX

      protected int tileSizeX
      The tile width which will be used for writing.
    • tileSizeY

      protected int tileSizeY
      The tile height which will be used for writing.
  • Constructor Details

    • TiffWriter

      public TiffWriter()
    • TiffWriter

      public TiffWriter(String format, String[] exts)
  • Method Details

    • getCodec

      public loci.formats.codec.Codec getCodec()
    • saveCompressedBytes

      public void saveCompressedBytes(int no, byte[] buf, int x, int y, int w, int h) throws loci.formats.FormatException, IOException
      Throws:
      loci.formats.FormatException
      IOException
    • makeIFD

      protected IFD makeIFD() throws loci.formats.FormatException, IOException
      Throws:
      loci.formats.FormatException
      IOException
    • setId

      public void setId(String id) throws loci.formats.FormatException, IOException
      Specified by:
      setId in interface loci.formats.IFormatHandler
      Overrides:
      setId in class loci.formats.FormatWriter
      Throws:
      loci.formats.FormatException
      IOException
    • saveBytes

      public void saveBytes(int no, byte[] buf, IFD ifd) throws IOException, loci.formats.FormatException
      Saves the given image to the specified (possibly already open) file. The IFD hashtable allows specification of TIFF parameters such as bit depth, compression and units. Use one IFD instance per plane.
      Throws:
      IOException
      loci.formats.FormatException
    • saveBytes

      public void saveBytes(int no, byte[] buf, IFD ifd, int x, int y, int w, int h) throws IOException, loci.formats.FormatException
      Saves the given image to the specified series in the current file. The IFD hashtable allows specification of TIFF parameters such as bit depth, compression and units. Use one IFD instance per plane.
      Throws:
      IOException
      loci.formats.FormatException
    • prepareToWriteImage

      protected int prepareToWriteImage(int no, byte[] buf, IFD ifd, int x, int y, int w, int h) throws IOException, loci.formats.FormatException
      Performs the preparation for work prior to the usage of the TIFF saver. This method is factored out from saveBytes() in an attempt to ensure thread safety.
      Throws:
      IOException
      loci.formats.FormatException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class loci.formats.FormatWriter
      Throws:
      IOException
    • getPlaneCount

      public int getPlaneCount()
      Overrides:
      getPlaneCount in class loci.formats.FormatWriter
    • saveBytes

      public void saveBytes(int no, byte[] buf, int x, int y, int w, int h) throws loci.formats.FormatException, IOException
      Throws:
      loci.formats.FormatException
      IOException
      See Also:
      • IFormatWriter.saveBytes(int, byte[], int, int, int, int)
    • canDoStacks

      public boolean canDoStacks()
      Specified by:
      canDoStacks in interface loci.formats.IFormatWriter
      Overrides:
      canDoStacks in class loci.formats.FormatWriter
    • getPixelTypes

      public int[] getPixelTypes(String codec)
      Specified by:
      getPixelTypes in interface loci.formats.IFormatWriter
      Overrides:
      getPixelTypes in class loci.formats.FormatWriter
    • setBigTiff

      public void setBigTiff(boolean bigTiff)
      Sets whether or not BigTIFF files should be written. This flag is not reset when close() is called.
    • setCanDetectBigTiff

      public void setCanDetectBigTiff(boolean detect)
      Sets whether or not BigTIFF can be used automatically based upon the input data size (true by default). This flag is not reset when close() is called.
    • setupTiffSaver

      protected void setupTiffSaver() throws IOException
      Throws:
      IOException
    • getTileSizeX

      public int getTileSizeX() throws loci.formats.FormatException
      Specified by:
      getTileSizeX in interface loci.formats.IFormatWriter
      Overrides:
      getTileSizeX in class loci.formats.FormatWriter
      Throws:
      loci.formats.FormatException
    • setTileSizeX

      public int setTileSizeX(int tileSize) throws loci.formats.FormatException
      Specified by:
      setTileSizeX in interface loci.formats.IFormatWriter
      Overrides:
      setTileSizeX in class loci.formats.FormatWriter
      Throws:
      loci.formats.FormatException
    • getTileSizeY

      public int getTileSizeY() throws loci.formats.FormatException
      Specified by:
      getTileSizeY in interface loci.formats.IFormatWriter
      Overrides:
      getTileSizeY in class loci.formats.FormatWriter
      Throws:
      loci.formats.FormatException
    • setTileSizeY

      public int setTileSizeY(int tileSize) throws loci.formats.FormatException
      Specified by:
      setTileSizeY in interface loci.formats.IFormatWriter
      Overrides:
      setTileSizeY in class loci.formats.FormatWriter
      Throws:
      loci.formats.FormatException
    • createInputStream

      protected loci.common.RandomAccessInputStream createInputStream() throws IOException
      Throws:
      IOException
    • createTiffSaver

      protected TiffSaver createTiffSaver()