org.apache.poi.hdgf
Class HDGFLZW

java.lang.Object
  extended by org.apache.poi.util.LZWDecompresser
      extended by org.apache.poi.hdgf.HDGFLZW

public class HDGFLZW
extends LZWDecompresser

A decoder for the crazy LZW implementation used in Visio. According to VSDump, "it's a slightly perverted version of LZW compression, with inverted meaning of flag byte and 0xFEE as an 'initial shift'". It uses 12 bit codes (http://www.gnome.ru/projects/vsdump_en.html) Two good resources on LZW are: http://en.wikipedia.org/wiki/LZW http://marknelson.us/1989/10/01/lzw-data-compression/


Constructor Summary
HDGFLZW()
           
 
Method Summary
protected  int adjustDictionaryOffset(int pntr)
          We have a slight shift by 18 bytes
 byte[] compress(java.io.InputStream src)
          Compress the given input stream, returning the array of bytes of the compressed input
 void compress(java.io.InputStream src, java.io.OutputStream res)
          Performs the Visio compatible streaming LZW compression.
protected  int populateDictionary(byte[] dict)
          We want an empty dictionary, so do nothing
 
Methods inherited from class org.apache.poi.util.LZWDecompresser
decompress, decompress, fromByte, fromInt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HDGFLZW

public HDGFLZW()
Method Detail

compress

public byte[] compress(java.io.InputStream src)
                throws java.io.IOException
Compress the given input stream, returning the array of bytes of the compressed input

Throws:
java.io.IOException

adjustDictionaryOffset

protected int adjustDictionaryOffset(int pntr)
We have a slight shift by 18 bytes

Specified by:
adjustDictionaryOffset in class LZWDecompresser

populateDictionary

protected int populateDictionary(byte[] dict)
We want an empty dictionary, so do nothing

Specified by:
populateDictionary in class LZWDecompresser

compress

public void compress(java.io.InputStream src,
                     java.io.OutputStream res)
              throws java.io.IOException
Performs the Visio compatible streaming LZW compression.

Throws:
java.io.IOException


Copyright 2012 The Apache Software Foundation or its licensors, as applicable.