loci.formats

## Interface IFormatWriter

- All Superinterfaces:
    java.lang.AutoCloseable, java.io.Closeable, ICompressedTileWriter, IFormatHandler, IMetadataConfigurable, IPyramidHandler
  All Known Implementing Classes:
    APNGWriter, AVIWriter, BufferedImageWriter, CellH5Writer, DicomWriter, EPSWriter, FormatWriter, ICSWriter, ImageIOWriter, ImageWriter, JavaWriter, JPEG2000Writer, JPEGWriter, OMETiffWriter, OMEXMLWriter, PyramidOMETiffWriter, QTWriter, TiffWriter, V3DrawWriter, WriterWrapper

      public interface IFormatWriter
      extends IFormatHandler, IPyramidHandler, ICompressedTileWriter

  Interface for all biological file format writers.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `canDoStacks()` Reports whether the writer can save multiple images to a single file.
    `void` | `changeOutputFile(java.lang.String id)` Switch the output file for the current dataset.
    `java.awt.image.ColorModel` | `getColorModel()` Gets the color model.
    `java.lang.String` | `getCompression()` Gets the current compression type.
    `java.lang.String[]` | `getCompressionTypes()` Gets the available compression types.
    `int` | `getFramesPerSecond()` Gets the frames per second to use when writing.
    `MetadataRetrieve` | `getMetadataRetrieve()` Retrieves the current metadata retrieval object for this writer.
    `int[]` | `getPixelTypes()` Gets the supported pixel types.
    `int[]` | `getPixelTypes(java.lang.String codec)` Gets the supported pixel types for the given codec.
    `java.util.List<Resolution>` | `getResolutions()` Get a list of resolution objects for the current series.
    `int` | `getSeries()` Returns the current series.
    `int` | `getTileSizeX()` Retrieves the current tile width Defaults to 0 if not supported
    `int` | `getTileSizeY()` Retrieves the current tile height Defaults to 0 if not supported
    `boolean` | `isInterleaved()` Gets whether or not the channels in an image are interleaved.
    `boolean` | `isSupportedType(int type)` Checks if the given pixel type is supported.
    `void` | `saveBytes(int no, byte[] buf)` Saves the given image to the current series in the current file.
    `void` | `saveBytes(int no, byte[] buf, int x, int y, int w, int h)` Saves the given image tile to the current series in the current file.
    `void` | `saveBytes(int no, byte[] buf, loci.common.Region tile)` Saves the given image tile to the current series in the current file.
    `void` | `savePlane(int no, java.lang.Object plane)` Saves the given image plane to the current series in the current file.
    `void` | `savePlane(int no, java.lang.Object plane, int x, int y, int w, int h)` Saves the given image plane to the current series in the current file.
    `void` | `savePlane(int no, java.lang.Object plane, loci.common.Region tile)` Saves the given image plane to the current series in the current file.
    `void` | `setCodecOptions(CodecOptions options)` Sets the codec options.
    `void` | `setColorModel(java.awt.image.ColorModel cm)` Sets the color model.
    `void` | `setCompression(java.lang.String compress)` Sets the current compression type.
    `void` | `setFramesPerSecond(int rate)` Sets the frames per second to use when writing.
    `void` | `setInterleaved(boolean interleaved)` Sets whether or not the channels in an image are interleaved.
    `void` | `setMetadataRetrieve(MetadataRetrieve r)` Sets the metadata retrieval object from which to retrieve standardized metadata.
    `void` | `setResolutions(java.util.List<Resolution> resolutions)` Specify a list of resolution objects for the current series.
    `void` | `setSeries(int series)` Sets the current series.
    `int` | `setTileSizeX(int tileSize)` Will attempt to set the tile width to the desired value and return the actual value which will be used
    `int` | `setTileSizeY(int tileSize)` Will attempt to set the tile height to the desired value and return the actual value which will be used
    `void` | `setValidBitsPerPixel(int bits)` Sets the number of valid bits per pixel.
    `void` | `setWriteSequentially(boolean sequential)` Sets whether or not we know that planes will be written sequentially.

    - ### Methods inherited from interface loci.formats.IFormatHandler

      `getFormat, getNativeDataType, getSuffixes, isThisType, setId`

    - ### Methods inherited from interface java.io.Closeable

      `close`

    - ### Methods inherited from interface loci.formats.IMetadataConfigurable

      `getMetadataOptions, getSupportedMetadataLevels, setMetadataOptions`

    - ### Methods inherited from interface loci.formats.IPyramidHandler

      `getResolution, getResolutionCount, setResolution`

    - ### Methods inherited from interface loci.formats.ICompressedTileWriter

      `getCodec, getCodecOptions, saveCompressedBytes`

- - ### Method Detail

    - #### saveBytes

          void saveBytes(int no,
                         byte[] buf)
                  throws FormatException,
                         java.io.IOException

      Saves the given image to the current series in the current file.
      Parameters:
        `no` - the plane index within the series.
        `buf` - the byte array that represents the image.
      Throws:
        `FormatException` - if one of the parameters is invalid.
        `java.io.IOException` - if there was a problem writing to the file.

    - #### saveBytes

          void saveBytes(int no,
                         byte[] buf,
                         int x,
                         int y,
                         int w,
                         int h)
                  throws FormatException,
                         java.io.IOException

      Saves the given image tile to the current series in the current file.
      Parameters:
        `no` - the plane index within the series.
        `buf` - the byte array that represents the image tile.
        `x` - the X coordinate of the upper-left corner of the image tile.
        `y` - the Y coordinate of the upper-left corner of the image tile.
        `w` - the width (in pixels) of the image tile.
        `h` - the height (in pixels) of the image tile.
      Throws:
        `FormatException` - if one of the parameters is invalid.
        `java.io.IOException` - if there was a problem writing to the file.

    - #### saveBytes

          void saveBytes(int no,
                         byte[] buf,
                         loci.common.Region tile)
                  throws FormatException,
                         java.io.IOException

      Saves the given image tile to the current series in the current file.
      Parameters:
        `no` - the plane index within the series.
        `buf` - the byte array that represents the image tile.
        `tile` - the Region representing the image tile to be read.
      Throws:
        `FormatException` - if one of the parameters is invalid.
        `java.io.IOException` - if there was a problem writing to the file.

    - #### savePlane

          void savePlane(int no,
                         java.lang.Object plane)
                  throws FormatException,
                         java.io.IOException

      Saves the given image plane to the current series in the current file.
      Parameters:
        `no` - the plane index within the series.
        `plane` - the image plane.
      Throws:
        `FormatException` - if one of the parameters is invalid.
        `java.io.IOException` - if there was a problem writing to the file.

    - #### savePlane

          void savePlane(int no,
                         java.lang.Object plane,
                         int x,
                         int y,
                         int w,
                         int h)
                  throws FormatException,
                         java.io.IOException

      Saves the given image plane to the current series in the current file.
      Parameters:
        `no` - the plane index within the series.
        `plane` - the image plane.
        `x` - the X coordinate of the upper-left corner of the image tile.
        `y` - the Y coordinate of the upper-left corner of the image tile.
        `w` - the width (in pixels) of the image tile.
        `h` - the height (in pixels) of the image tile.
      Throws:
        `FormatException` - if one of the parameters is invalid.
        `java.io.IOException` - if there was a problem writing to the file.

    - #### savePlane

          void savePlane(int no,
                         java.lang.Object plane,
                         loci.common.Region tile)
                  throws FormatException,
                         java.io.IOException

      Saves the given image plane to the current series in the current file.
      Parameters:
        `no` - the plane index within the series.
        `plane` - the image plane.
        `tile` - the Region representing the image tile to be read.
      Throws:
        `FormatException` - if one of the parameters is invalid.
        `java.io.IOException` - if there was a problem writing to the file.

    - #### setSeries

          void setSeries(int series)
                  throws FormatException

      Sets the current series.
      Parameters:
        `series` - the series index, starting from 0.
      Throws:
        `FormatException` - if the specified series is invalid.

    - #### getSeries

          int getSeries()

      Returns the current series.

    - #### setInterleaved

          void setInterleaved(boolean interleaved)

      Sets whether or not the channels in an image are interleaved.

    - #### setValidBitsPerPixel

          void setValidBitsPerPixel(int bits)

      Sets the number of valid bits per pixel.

    - #### isInterleaved

          boolean isInterleaved()

      Gets whether or not the channels in an image are interleaved.

    - #### canDoStacks

          boolean canDoStacks()

      Reports whether the writer can save multiple images to a single file.

    - #### setMetadataRetrieve

          void setMetadataRetrieve(MetadataRetrieve r)

      Sets the metadata retrieval object from which to retrieve standardized metadata.

    - #### getMetadataRetrieve

          MetadataRetrieve getMetadataRetrieve()

      Retrieves the current metadata retrieval object for this writer. You can be assured that this method will never return a `null` metadata retrieval object.
      Returns:
        A metadata retrieval object.

    - #### setColorModel

          void setColorModel(java.awt.image.ColorModel cm)

      Sets the color model.

    - #### getColorModel

          java.awt.image.ColorModel getColorModel()

      Gets the color model.

    - #### setFramesPerSecond

          void setFramesPerSecond(int rate)

      Sets the frames per second to use when writing.

    - #### getFramesPerSecond

          int getFramesPerSecond()

      Gets the frames per second to use when writing.

    - #### getCompressionTypes

          java.lang.String[] getCompressionTypes()

      Gets the available compression types.

    - #### getPixelTypes

          int[] getPixelTypes()

      Gets the supported pixel types.

    - #### getPixelTypes

          int[] getPixelTypes(java.lang.String codec)

      Gets the supported pixel types for the given codec.

    - #### isSupportedType

          boolean isSupportedType(int type)

      Checks if the given pixel type is supported.

    - #### setCompression

          void setCompression(java.lang.String compress)
                       throws FormatException

      Sets the current compression type.
      Throws:
        `FormatException`

    - #### setCodecOptions

          void setCodecOptions(CodecOptions options)

      Sets the codec options.
      Parameters:
        `options` - The options to set.

    - #### getCompression

          java.lang.String getCompression()

      Gets the current compression type.

    - #### changeOutputFile

          void changeOutputFile(java.lang.String id)
                         throws FormatException,
                                java.io.IOException

      Switch the output file for the current dataset.
      Throws:
        `FormatException`
        `java.io.IOException`

    - #### setWriteSequentially

          void setWriteSequentially(boolean sequential)

      Sets whether or not we know that planes will be written sequentially. If planes are written sequentially and this flag is set, then performance will be slightly improved.

    - #### getTileSizeX

          int getTileSizeX()
                    throws FormatException

      Retrieves the current tile width Defaults to 0 if not supported
      Returns:
        The current tile width being used
      Throws:
        `FormatException` - Image metadata including Pixels Size X must be set prior to calling getTileSizeX()

    - #### setTileSizeX

          int setTileSizeX(int tileSize)
                    throws FormatException

      Will attempt to set the tile width to the desired value and return the actual value which will be used
      Parameters:
        `tileSize` - The tile width you wish to use. Setting to 0 will disable tiling
      Returns:
        The tile width which will actually be used, this may differ from the value requested. If the requested value is not supported the writer will return and use the closest appropriate value.
      Throws:
        `FormatException` - Tile size must be greater than or equal to 0 and less than the image width

    - #### getTileSizeY

          int getTileSizeY()
                    throws FormatException

      Retrieves the current tile height Defaults to 0 if not supported
      Returns:
        The current tile height being used
      Throws:
        `FormatException` - Image metadata including Pixels Size Y must be set prior to calling getTileSizeY()

    - #### setTileSizeY

          int setTileSizeY(int tileSize)
                    throws FormatException

      Will attempt to set the tile height to the desired value and return the actual value which will be used
      Parameters:
        `tileSize` - The tile height you wish to use. Setting to 0 will disable tiling
      Returns:
        The tile height which will actually be used, this may differ from the value requested. If the requested value is not supported the writer will return and use the closest appropriate value.
      Throws:
        `FormatException` - Tile size must be greater than or equal to 0 and less than the image height

    - #### setResolutions

          void setResolutions(java.util.List<Resolution> resolutions)

      Specify a list of resolution objects for the current series. If resolutions are specified using this method, then any resolution data supplied via the MetadataRetrieve will be ignored.

    - #### getResolutions

          java.util.List<Resolution> getResolutions()

      Get a list of resolution objects for the current series.

Copyright © 2026 Open Microscopy Environment