Package ome.codecs
Interface Codec
- All Known Implementing Classes:
Base64Codec,BaseCodec,HuffmanCodec,JPEG2000Codec,JPEGCodec,LosslessJPEGCodec,LZ4Codec,LZOCodec,LZWCodec,MJPBCodec,MSRLECodec,MSVideoCodec,PackbitsCodec,PassthroughCodec,QTRLECodec,RPZACodec,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
Modifier and TypeMethodDescriptionbyte[]compress(byte[][] data, CodecOptions options) Compresses a block of data.byte[]compress(byte[] data, CodecOptions options) Compresses a block of data.compress(ByteBuffer target, byte[] data, CodecOptions options) Compresses data from an array into a ByteBuffer.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 Details
-
compress
Compresses data from an array into a ByteBuffer. A preexisting destination ByteBuffer may be provided, and a compressor may choose to use (or not) that ByteBuffer if it has enough remaining space. Regardless, the function returns a reference to the ByteBuffer where the compressed data was actually stored. This potentially avoids unnecessary buffer creation and copying, since the ByteBuffer position indicates how much of the buffer is actually used.- Parameters:
target- A preallocated ByteBuffer that may be used for the compressed data. This may benullto force the compressor to allocate a fresh buffer.data- The data to be compressed.options- Options to be used during compression, if appropriate.- Returns:
- The ByteBuffer holding the compressed data.
- Throws:
CodecException- If input cannot be processed.
-
compress
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:
CodecException- If input is not a compressed data block of the appropriate type.
-
compress
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:
CodecException- If input is not a compressed data block of the appropriate type.
-
decompress
Decompresses a block of data.- Parameters:
data- the data to be decompressedoptions- Options to be used during decompression.- Returns:
- the decompressed data.
- Throws:
CodecException- If data is not valid.
-
decompress
Decompresses a block of data.- Parameters:
data- the data to be decompressedoptions- Options to be used during decompression.- Returns:
- the decompressed data.
- Throws:
CodecException- If data is not valid.
-
decompress
Decompresses a block of data.- Parameters:
data- the data to be decompressed.- Returns:
- The decompressed data.
- Throws:
CodecException- If data is not valid compressed data for this decompressor.
-
decompress
Decompresses a block of data.- Parameters:
data- The data to be decompressed.- Returns:
- The decompressed data.
- Throws:
CodecException- If data is not valid compressed data for this decompressor.
-
decompress
byte[] decompress(loci.common.RandomAccessInputStream in, CodecOptions options) throws CodecException, 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:
CodecException- If data is not valid compressed data for this decompressor.IOException
-