Class LZWDecoder
java.lang.Object
com.twelvemonkeys.imageio.plugins.tiff.LZWDecoder
- All Implemented Interfaces:
Decoder
- Direct Known Subclasses:
LZWDecoder.LZWCompatibilityDecoder
,LZWDecoder.LZWSpecDecoder
Lempel–Ziv–Welch (LZW) decompression.
LZW is a universal loss-less data compression algorithm created by Abraham Lempel, Jacob Ziv, and Terry Welch.
Inspired by libTiff's LZW decompression.
- Version:
- $Id: LZWDecoder.java,v 1.0 08.05.12 21:11 haraldk Exp$
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
(package private) static final class
(package private) static final class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int
(package private) int
(package private) static final int
Clear: Re-initialize tables.(package private) boolean
(package private) static final int
End of Information.private static final int
private int
private int
private static final int
(package private) int
(package private) int
private int
private final LZWDecoder.LZWString[]
private static final int
private int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addStringToTable
(LZWDecoder.LZWString string) private static int
bitmaskFor
(int bits) static Decoder
create
(boolean oldBitReversedStream) int
decode
(InputStream stream, ByteBuffer buffer) Decodes up tobuffer.length
bytes from the given input stream, into the given buffer.protected abstract int
getNextCode
(InputStream stream) private void
init()
private boolean
isInTable
(int code) (package private) static boolean
isOldBitReversedStream
(InputStream stream) protected abstract int
maxCode()
-
Field Details
-
CLEAR_CODE
static final int CLEAR_CODEClear: Re-initialize tables.- See Also:
-
EOI_CODE
static final int EOI_CODEEnd of Information.- See Also:
-
MIN_BITS
private static final int MIN_BITS- See Also:
-
MAX_BITS
private static final int MAX_BITS- See Also:
-
TABLE_SIZE
private static final int TABLE_SIZE- See Also:
-
table
-
tableLength
private int tableLength -
bitsPerCode
int bitsPerCode -
oldCode
private int oldCode -
maxCode
private int maxCode -
bitMask
int bitMask -
maxString
private int maxString -
eofReached
boolean eofReached -
nextData
int nextData -
nextBits
int nextBits
-
-
Constructor Details
-
LZWDecoder
protected LZWDecoder(int tableSize)
-
-
Method Details
-
bitmaskFor
private static int bitmaskFor(int bits) -
init
private void init() -
decode
Description copied from interface:Decoder
Decodes up tobuffer.length
bytes from the given input stream, into the given buffer.- Specified by:
decode
in interfaceDecoder
- Parameters:
stream
- the input stream to decode data frombuffer
- buffer to store the read data- Returns:
- the total number of bytes read into the buffer, or
0
if there is no more data because the end of the stream has been reached. - Throws:
IOException
- if an I/O error occurs.
-
addStringToTable
- Throws:
IOException
-
maxCode
protected abstract int maxCode() -
isInTable
private boolean isInTable(int code) -
getNextCode
- Throws:
IOException
-
isOldBitReversedStream
- Throws:
IOException
-
create
-