loci.formats.codec

## Interface Codec

- All Known Implementing Classes:
    Base64Codec, BaseCodec, HuffmanCodec, JPEG2000Codec, JPEGCodec, JPEGXRCodec, LosslessJPEGCodec, LZOCodec, LZWCodec, MJPBCodec, MSRLECodec, MSVideoCodec, NikonCodec, PackbitsCodec, PassthroughCodec, QTRLECodec, RPZACodec, TargaRLECodec, WrappedCodec, ZlibCodec, ZstdCodec

      public interface Codec

  This class is an interface for any kind of compression or decompression. Data is presented to the compressor in a 1D or 2D byte array, with (optionally, depending on the compressor) pixel dimensions and an Object containing any other options the compressor may need. If an argument is not appropriate for the compressor type, it is expected to completely ignore the argument. i.e.: Passing a compressor that does not require pixel dimensions null for the dimensions must not cause the compressor to throw a NullPointerException. Classes implementing the Codec interface are expected to either implement both compression methods or neither. (The same is expected for decompression).
  Author:
    Eric Kjellman egkjellman at wisc.edu

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `compress(byte[][] data, CodecOptions options)` Compresses a block of data.
    `byte[]` | `compress(byte[] data, CodecOptions options)` Compresses a block of data.
    `byte[]` | `decompress(byte[] data)` Decompresses a block of data.
    `byte[]` | `decompress(byte[][] data)` Decompresses a block of data.
    `byte[]` | `decompress(byte[][] data, CodecOptions options)` Decompresses a block of data.
    `byte[]` | `decompress(byte[] data, CodecOptions options)` Decompresses a block of data.
    `byte[]` | `decompress(loci.common.RandomAccessInputStream in, CodecOptions options)` Decompresses data from the given RandomAccessInputStream.

- - ### Method Detail

    - #### compress

          byte[] compress(byte[] data,
                          CodecOptions options)
                   throws FormatException

      Compresses a block of data.
      Parameters:
        `data` - The data to be compressed.
        `options` - Options to be used during compression, if appropriate.
      Returns:
        The compressed data.
      Throws:
        `FormatException` - If input is not a compressed data block of the appropriate type.

    - #### compress

          byte[] compress(byte[][] data,
                          CodecOptions options)
                   throws FormatException

      Compresses a block of data.
      Parameters:
        `data` - The data to be compressed.
        `options` - Options to be used during compression, if appropriate.
      Returns:
        The compressed data.
      Throws:
        `FormatException` - If input is not a compressed data block of the appropriate type.

    - #### decompress

          byte[] decompress(byte[] data,
                            CodecOptions options)
                     throws FormatException

      Decompresses a block of data.
      Parameters:
        `data` - the data to be decompressed
        `options` - Options to be used during decompression.
      Returns:
        the decompressed data.
      Throws:
        `FormatException` - If data is not valid.

    - #### decompress

          byte[] decompress(byte[][] data,
                            CodecOptions options)
                     throws FormatException

      Decompresses a block of data.
      Parameters:
        `data` - the data to be decompressed
        `options` - Options to be used during decompression.
      Returns:
        the decompressed data.
      Throws:
        `FormatException` - If data is not valid.

    - #### decompress

          byte[] decompress(byte[] data)
                     throws FormatException

      Decompresses a block of data.
      Parameters:
        `data` - the data to be decompressed.
      Returns:
        The decompressed data.
      Throws:
        `FormatException` - If data is not valid compressed data for this decompressor.

    - #### decompress

          byte[] decompress(byte[][] data)
                     throws FormatException

      Decompresses a block of data.
      Parameters:
        `data` - The data to be decompressed.
      Returns:
        The decompressed data.
      Throws:
        `FormatException` - If data is not valid compressed data for this decompressor.

    - #### decompress

          byte[] decompress(loci.common.RandomAccessInputStream in,
                            CodecOptions options)
                     throws FormatException,
                            java.io.IOException

      Decompresses data from the given RandomAccessInputStream.
      Parameters:
        `in` - The stream from which to read compressed data.
        `options` - Options to be used during decompression.
      Returns:
        The decompressed data.
      Throws:
        `FormatException` - If data is not valid compressed data for this decompressor.
        `java.io.IOException`

Copyright © 2026 Open Microscopy Environment