Package org.apache.poi.hdgf
Class HDGFLZW
java.lang.Object
org.apache.poi.util.LZWDecompresser
org.apache.poi.hdgf.HDGFLZW
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intadjustDictionaryOffset(int pntr) We have a slight shift by 18 bytesbyte[]compress(InputStream src) Compress the given input stream, returning the array of bytes of the compressed inputvoidcompress(InputStream src, OutputStream res) Performs the Visio compatible streaming LZW compression.protected intpopulateDictionary(byte[] dict) We want an empty dictionary, so do nothingMethods inherited from class org.apache.poi.util.LZWDecompresser
decompress, decompress, fromByte, fromInt
-
Constructor Details
-
HDGFLZW
public HDGFLZW()
-
-
Method Details
-
compress
Compress the given input stream, returning the array of bytes of the compressed input- Parameters:
src- the compression source byte- Returns:
- the compressed stream as bytes
- Throws:
IOException- when the InputStream can't be read
-
adjustDictionaryOffset
protected int adjustDictionaryOffset(int pntr) We have a slight shift by 18 bytes- Specified by:
adjustDictionaryOffsetin classLZWDecompresser
-
populateDictionary
protected int populateDictionary(byte[] dict) We want an empty dictionary, so do nothing- Specified by:
populateDictionaryin classLZWDecompresser
-
compress
Performs the Visio compatible streaming LZW compression.- Parameters:
src- the input bytes for the compressionres- the OutputStream which receives the compressed bytes- Throws:
IOException- when the InputStream can't be read or the OutputStream can't be written to
-