loci.formats.codec
Class BaseCodec

java.lang.Object
  extended by loci.formats.codec.BaseCodec
All Implemented Interfaces:
Codec
Direct Known Subclasses:
AdobeDeflateCodec, Base64Codec, JPEGCodec, LuraWaveCodec, LZOCodec, LZWCodec, MJPBCodec, MSRLECodec, MSVideoCodec, NikonCodec, PackbitsCodec, QTRLECodec, RPZACodec

public abstract class BaseCodec
extends Object
implements Codec

BaseCodec contains default implementation and testing for classes implementing the Codec interface, and acts as a base class for any of the compression classes. Base 1D compression and decompression methods are not implemented here, and are left as abstract. 2D methods do simple concatenation and call to the 1D methods

Source code:
Trac, SVN

Author:
Eric Kjellman egkjellman at wisc.edu

Constructor Summary
BaseCodec()
           
 
Method Summary
 byte[] compress(byte[][] data, int x, int y, int[] dims, Object options)
          2D data block encoding default implementation.
 byte[] decompress(byte[] data)
          Decompresses a block of data.
 byte[] decompress(byte[][] data)
          Decompresses a block of data.
 byte[] decompress(byte[][] data, Object options)
          2D data block decoding default implementation.
 void test()
          Main testing method default implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface loci.formats.codec.Codec
compress, decompress
 

Constructor Detail

BaseCodec

public BaseCodec()
Method Detail

test

public void test()
          throws loci.formats.FormatException
Main testing method default implementation. This method tests whether the data is the same after compressing and decompressing, as well as doing a basic test of the 2D methods.

Throws:
loci.formats.FormatException - Can only occur if there is a bug in the compress method.

compress

public byte[] compress(byte[][] data,
                       int x,
                       int y,
                       int[] dims,
                       Object options)
                throws loci.formats.FormatException
2D data block encoding default implementation. This method simply concatenates data[0] + data[1] + ... + data[i] into a 1D block of data, then calls the 1D version of compress.

Specified by:
compress in interface Codec
Parameters:
data - The data to be compressed.
x - Length of the x dimension of the image data, if appropriate.
y - Length of the y dimension of the image data, if appropriate.
dims - The dimensions of the image data, if appropriate.
options - Options to be used during compression, if appropriate.
Returns:
The compressed data.
Throws:
loci.formats.FormatException - If input is not a compressed data block of the appropriate type.

decompress

public byte[] decompress(byte[] data)
                  throws loci.formats.FormatException
Description copied from interface: Codec
Decompresses a block of data.

Specified by:
decompress in interface Codec
Parameters:
data - the data to be decompressed.
Returns:
The decompressed data.
Throws:
loci.formats.FormatException - If data is not valid compressed data for this decompressor.

decompress

public byte[] decompress(byte[][] data)
                  throws loci.formats.FormatException
Description copied from interface: Codec
Decompresses a block of data.

Specified by:
decompress in interface Codec
Parameters:
data - The data to be decompressed.
Returns:
The decompressed data.
Throws:
loci.formats.FormatException - If data is not valid compressed data for this decompressor.

decompress

public byte[] decompress(byte[][] data,
                         Object options)
                  throws loci.formats.FormatException
2D data block decoding default implementation. This method simply concatenates data[0] + data[1] + ... + data[i] into a 1D block of data, then calls the 1D version of decompress.

Specified by:
decompress in interface Codec
Parameters:
data - The data to be decompressed.
options - Options to be used during decompression.
Returns:
The decompressed data.
Throws:
loci.formats.FormatException - If input is not a compressed data block of the appropriate type.