| java.lang.Object org.apache.poi.hdgf.HDGFLZW
HDGFLZW | public class HDGFLZW (Code) | | 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/
|
Method Summary | |
public byte[] | compress(InputStream src) | public void | compress(InputStream src, OutputStream res) Performs the Visio compatible streaming LZW compression. | public byte[] | decode(InputStream src) Decompresses the given input stream, returning the array of bytes
of the decompressed input. | public void | decode(InputStream src, OutputStream res) Perform a streaming decompression of the input. | public static int | fromByte(byte b) Given a java byte, turn it into an integer between 0
and 255 (i.e. | public static byte | fromInt(int b) Given an integer, turn it into a java byte, handling
the wrapping. |
compress | public byte[] compress(InputStream src) throws IOException(Code) | | Compress the given input stream, returning the array of bytes
of the compressed input
|
decode | public byte[] decode(InputStream src) throws IOException(Code) | | Decompresses the given input stream, returning the array of bytes
of the decompressed input.
|
decode | public void decode(InputStream src, OutputStream res) throws IOException(Code) | | Perform a streaming decompression of the input.
Works by:
1) Reading a flag byte, the 8 bits of which tell you if the
following 8 codes are compressed our un-compressed
2) Consider the 8 bits in turn
3) If the bit is set, the next code is un-compressed, so
add it to the dictionary and output it
4) If the bit isn't set, then read in the length and start
position in the dictionary, and output the bytes there
5) Loop until we've done all 8 bits, then read in the next
flag byte
|
fromByte | public static int fromByte(byte b)(Code) | | Given a java byte, turn it into an integer between 0
and 255 (i.e. handle the unwrapping).
This is a convenience method
|
fromInt | public static byte fromInt(int b)(Code) | | Given an integer, turn it into a java byte, handling
the wrapping.
This is a convenience method
|
|
|