loci.formats.codec
Class LZWCodec

java.lang.Object
  extended by loci.formats.codec.BaseCodec
      extended by loci.formats.codec.LZWCodec
All Implemented Interfaces:
Codec

public class LZWCodec
extends BaseCodec
implements Codec

Implements basic LZW compression and decompression, as outlined in the TIFF 6.0 Specification at http://partners.adobe.com/asn/developer/pdfs/tn/TIFF6.pdf (page 61).

Source code:
Trac, SVN

Author:
Eric Kjellman egkjellman at wisc.edu, Curtis Rueden ctrueden at wisc.edu, Wayne Rasband wsr at nih.gov

Field Summary
protected static int CLEAR_CODE
           
protected static int EOI_CODE
           
 
Constructor Summary
LZWCodec()
           
 
Method Summary
 byte[] compress(byte[] input, int x, int y, int[] dims, Object options)
          Compresses a block of data using LZW compression.
 byte[] decompress(byte[] input, Object options)
          Decodes an LZW-compressed data block.
static void main(String[] args)
          Main testing method.
 
Methods inherited from class loci.formats.codec.BaseCodec
compress, decompress, decompress, decompress, test
 
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, decompress, decompress
 

Field Detail

CLEAR_CODE

protected static final int CLEAR_CODE
See Also:
Constant Field Values

EOI_CODE

protected static final int EOI_CODE
See Also:
Constant Field Values
Constructor Detail

LZWCodec

public LZWCodec()
Method Detail

compress

public byte[] compress(byte[] input,
                       int x,
                       int y,
                       int[] dims,
                       Object options)
                throws loci.formats.FormatException
Compresses a block of data using LZW compression. If input is null or of 0 length, simply returns input.

Specified by:
compress in interface Codec
Parameters:
input - the data to be compressed
x - ignored for LZW.
y - ignored for LZW.
dims - ignored for LZW.
options - ignored for LZW.
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[] input,
                         Object options)
                  throws loci.formats.FormatException
Decodes an LZW-compressed data block.

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

main

public static void main(String[] args)
                 throws loci.formats.FormatException
Main testing method.

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