Class LZWCompressor

java.lang.Object
com.itextpdf.io.codec.LZWCompressor

public class LZWCompressor extends Object
Modified from original LZWCompressor to change interface to passing a buffer of data to be compressed.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) BitFile
    output destination for bit codes
    (package private) int
    reserved clear code based on code size
    (package private) int
    base underlying code size of data being compressed 8 for TIFF, 1 to 8 for GIF
    (package private) int
    reserved end of data code based on code size
    (package private) int
    limit at which current number of bits code size has to be increased
    (package private) LZWStringTable
    general purpose LZW string table
    (package private) int
    current number bits output for each code
    (package private) short
    the prefix code which represents the predecessor string to current input point
    (package private) boolean
    modify the limits of the code values in LZW encoding due to TIFF bug / feature
  • Constructor Summary

    Constructors
    Constructor
    Description
    LZWCompressor(OutputStream outputStream, int codeSize, boolean TIFF)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    compress(byte[] buf, int offset, int length)
     
    void
    Indicate to compressor that no more data to go so write out any remaining buffered data.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • codeSize_

      int codeSize_
      base underlying code size of data being compressed 8 for TIFF, 1 to 8 for GIF
    • clearCode_

      int clearCode_
      reserved clear code based on code size
    • endOfInfo_

      int endOfInfo_
      reserved end of data code based on code size
    • numBits_

      int numBits_
      current number bits output for each code
    • limit_

      int limit_
      limit at which current number of bits code size has to be increased
    • prefix_

      short prefix_
      the prefix code which represents the predecessor string to current input point
    • bf_

      BitFile bf_
      output destination for bit codes
    • lzss_

      general purpose LZW string table
    • tiffFudge_

      boolean tiffFudge_
      modify the limits of the code values in LZW encoding due to TIFF bug / feature
  • Constructor Details

    • LZWCompressor

      public LZWCompressor(OutputStream outputStream, int codeSize, boolean TIFF) throws IOException
      Parameters:
      outputStream - destination for compressed data
      codeSize - the initial code size for the LZW compressor
      TIFF - flag indicating that TIFF lzw fudge needs to be applied
      Throws:
      IOException - if underlying output stream error
  • Method Details

    • compress

      public void compress(byte[] buf, int offset, int length) throws IOException
      Parameters:
      buf - The data to be compressed to output stream
      offset - The offset at which the data starts
      length - The length of the data being compressed
      Throws:
      IOException - if underlying output stream error
    • flush

      public void flush() throws IOException
      Indicate to compressor that no more data to go so write out any remaining buffered data.
      Throws:
      IOException - if underlying output stream error