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 intClear: Re-initialize tables.(package private) boolean(package private) static final intEnd of Information.private static final intprivate intprivate intprivate static final int(package private) int(package private) intprivate intprivate final LZWDecoder.LZWString[]private static final intprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddStringToTable(LZWDecoder.LZWString string) private static intbitmaskFor(int bits) static Decodercreate(boolean oldBitReversedStream) intdecode(InputStream stream, ByteBuffer buffer) Decodes up tobuffer.lengthbytes from the given input stream, into the given buffer.protected abstract intgetNextCode(InputStream stream) private voidinit()private booleanisInTable(int code) (package private) static booleanisOldBitReversedStream(InputStream stream) protected abstract intmaxCode()
-
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:DecoderDecodes up tobuffer.lengthbytes from the given input stream, into the given buffer.- Specified by:
decodein 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
0if 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
-