public class LZWFilter extends Filter
Modifier and Type | Field and Description |
---|---|
static long |
CLEAR_TABLE
The LZW clear table code.
|
static long |
EOD
The LZW end of data code.
|
private static org.apache.commons.logging.Log |
LOG
Log instance.
|
SYSPROP_DEFLATELEVEL
Constructor and Description |
---|
LZWFilter() |
Modifier and Type | Method and Description |
---|---|
private int |
calculateChunk(int tabSize,
int earlyChange)
Calculate the appropriate chunk size
|
private void |
checkIndexBounds(java.util.List<byte[]> codeTable,
long index,
javax.imageio.stream.MemoryCacheImageInputStream in) |
private java.util.List<byte[]> |
createCodeTable()
Init the code table with 1 byte entries and the EOD and CLEAR_TABLE
markers.
|
DecodeResult |
decode(java.io.InputStream encoded,
java.io.OutputStream decoded,
COSDictionary parameters,
int index)
Decodes data, producing the original non-encoded data.
|
private void |
doLZWDecode(java.io.InputStream encoded,
java.io.OutputStream decoded,
int earlyChange) |
protected void |
encode(java.io.InputStream rawData,
java.io.OutputStream encoded,
COSDictionary parameters) |
private int |
findPatternCode(java.util.List<byte[]> codeTable,
byte[] pattern)
Find the longest matching pattern in the code table.
|
decode, encode, findImageReader, getCompressionLevel, getDecodeParams
private static final org.apache.commons.logging.Log LOG
public static final long CLEAR_TABLE
public static final long EOD
public DecodeResult decode(java.io.InputStream encoded, java.io.OutputStream decoded, COSDictionary parameters, int index) throws java.io.IOException
decode
in class Filter
encoded
- the encoded byte streamdecoded
- the stream where decoded data will be writtenparameters
- the parameters used for decodingindex
- the index to the filter being decodedjava.io.IOException
- if the stream cannot be decodedprivate void doLZWDecode(java.io.InputStream encoded, java.io.OutputStream decoded, int earlyChange) throws java.io.IOException
java.io.IOException
private void checkIndexBounds(java.util.List<byte[]> codeTable, long index, javax.imageio.stream.MemoryCacheImageInputStream in) throws java.io.IOException
java.io.IOException
protected void encode(java.io.InputStream rawData, java.io.OutputStream encoded, COSDictionary parameters) throws java.io.IOException
private int findPatternCode(java.util.List<byte[]> codeTable, byte[] pattern)
codeTable
- The LZW code table.pattern
- The pattern to be searched for.private java.util.List<byte[]> createCodeTable()
private int calculateChunk(int tabSize, int earlyChange)
tabSize
- the size of the code tableearlyChange
- 0 or 1 for early chunk increase