loci.formats.out

## Class ImageIOWriter

- java.lang.Object
- - loci.formats.FormatHandler
  - - loci.formats.FormatWriter
    - - loci.formats.out.ImageIOWriter

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, ICompressedTileWriter, IFormatHandler, IFormatWriter, IMetadataConfigurable, IPyramidHandler
  Direct Known Subclasses:
    JPEGWriter

      public abstract class ImageIOWriter
      extends FormatWriter

  ImageIOWriter is the superclass for file format writers that use the javax.imageio library.
  Author:
    Curtis Rueden ctrueden at wisc.edu

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `kind`

    - ### 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 and Description
    `ImageIOWriter(java.lang.String format, java.lang.String[] suffixes, java.lang.String kind)` Constructs an ImageIO-based writer with the given name, default suffixes and output type (e.g., png, jpeg).
    `ImageIOWriter(java.lang.String format, java.lang.String suffix, java.lang.String kind)` Constructs an ImageIO-based writer with the given name, default suffix and output type (e.g., png, jpeg).

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Class<?>` | `getNativeDataType()` Returns the native data type of image planes for this reader, as returned by `IFormatReader.openPlane(int, int, int, int, int)` or `IFormatWriter.savePlane(int, java.lang.Object)`.
    `int[]` | `getPixelTypes(java.lang.String codec)` Gets the supported pixel types for the given codec.
    `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` | `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.

    - ### Methods inherited from class loci.formats.FormatWriter

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

    - ### Methods inherited from class loci.formats.FormatHandler

      `checkSuffix, checkSuffix, getFormat, getMetadataOptions, 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, getSuffixes, isThisType`

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

      `getMetadataOptions, getSupportedMetadataLevels, setMetadataOptions`

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

      `getCodec, saveCompressedBytes`

- - ### Field Detail

    - #### kind

          protected java.lang.String kind

  - ### Constructor Detail

    - #### ImageIOWriter

          public ImageIOWriter(java.lang.String format,
                               java.lang.String suffix,
                               java.lang.String kind)

      Constructs an ImageIO-based writer with the given name, default suffix and output type (e.g., png, jpeg).

    - #### ImageIOWriter

          public ImageIOWriter(java.lang.String format,
                               java.lang.String[] suffixes,
                               java.lang.String kind)

      Constructs an ImageIO-based writer with the given name, default suffixes and output type (e.g., png, jpeg).

  - ### Method Detail

    - #### saveBytes

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

      Description copied from interface: `IFormatWriter`
      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.
      See Also:
        `IFormatWriter.saveBytes(int, byte[], int, int, int, int)`

    - #### savePlane

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

      Description copied from interface: `IFormatWriter`
      Saves the given image plane to the current series in the current file.
      Specified by:
        `savePlane` in interface `IFormatWriter`
      Overrides:
        `savePlane` in class `FormatWriter`
      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.
      See Also:
        `IFormatWriter.savePlane(int, Object, int, int, int, int)`

    - #### getPixelTypes

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

      Description copied from interface: `IFormatWriter`
      Gets the supported pixel types for the given codec.
      Specified by:
        `getPixelTypes` in interface `IFormatWriter`
      Overrides:
        `getPixelTypes` in class `FormatWriter`

    - #### getNativeDataType

          public java.lang.Class<?> getNativeDataType()

      Description copied from interface: `IFormatHandler`
      Returns the native data type of image planes for this reader, as returned by `IFormatReader.openPlane(int, int, int, int, int)` or `IFormatWriter.savePlane(int, java.lang.Object)`. For most readers this type will be a byte array; however, some readers call external APIs that work with other types such as `BufferedImage`.
      Specified by:
        `getNativeDataType` in interface `IFormatHandler`
      Overrides:
        `getNativeDataType` in class `FormatHandler`

Copyright © 2026 Open Microscopy Environment