iText 7 7.1.11 API
iText.IO.Codec.LZWStringTable Class Reference

General purpose LZW String Table. More...

Public Member Functions

 LZWStringTable ()
 Constructor allocate memory for string store data More...
 
virtual int AddCharString (short index, byte b)
 
virtual short FindCharString (short index, byte b)
 
virtual void ClearTable (int codesize)
 
virtual int ExpandCode (byte[] buf, int offset, short code, int skipHead)
 If expanded data doesn't fit into array only what will fit is written to buf and the return value indicates how much of the expanded code has been written to the buf. More...
 
virtual void Dump (StreamWriter output)
 

Static Public Member Functions

static int Hash (short index, byte lastbyte)
 

Detailed Description

General purpose LZW String Table.

General purpose LZW String Table. Extracted from GIFEncoder by Adam Doppelt Comments added by Robin Luiten expandCode added by Robin Luiten The strLen_ table to give quick access to the lenght of an expanded code for use by the expandCode method added by Robin.

Constructor & Destructor Documentation

◆ LZWStringTable()

iText.IO.Codec.LZWStringTable.LZWStringTable ( )
inline

Constructor allocate memory for string store data

Member Function Documentation

◆ AddCharString()

virtual int iText.IO.Codec.LZWStringTable.AddCharString ( short  index,
byte  b 
)
inlinevirtual
Parameters
indexvalue of -1 indicates no predecessor [used in initialization]
bthe byte [character] to add to the string store which follows the predecessor string specified the index.
Returns
0xFFFF if no space in table left for addition of predecessor index and byte b. Else return the code allocated for combination index + b.

◆ ClearTable()

virtual void iText.IO.Codec.LZWStringTable.ClearTable ( int  codesize)
inlinevirtual
Parameters
codesizethe size of code to be preallocated for the string store.

◆ ExpandCode()

virtual int iText.IO.Codec.LZWStringTable.ExpandCode ( byte[]  buf,
int  offset,
short  code,
int  skipHead 
)
inlinevirtual

If expanded data doesn't fit into array only what will fit is written to buf and the return value indicates how much of the expanded code has been written to the buf.

If expanded data doesn't fit into array only what will fit is written to buf and the return value indicates how much of the expanded code has been written to the buf. The next call to expandCode() should be with the same code and have the skip parameter set the negated value of the previous return. Successive negative return values should be negated and added together for next skip parameter value with same code.

Parameters
bufbuffer to place expanded data into
offsetoffset to place expanded data
codethe code to expand to the byte array it represents. PRECONDITION This code must already be in the LZSS
skipHeadis the number of bytes at the start of the expanded code to be skipped before data is written to buf. It is possible that skipHead is equal to codeLen.
Returns
the length of data expanded into buf. If the expanded code is longer than space left in buf then the value returned is a negative number which when negated is equal to the number of bytes that were used of the code being expanded. This negative value also indicates the buffer is full.

◆ FindCharString()

virtual short iText.IO.Codec.LZWStringTable.FindCharString ( short  index,
byte  b 
)
inlinevirtual
Parameters
indexindex to prefix string
bthe character that follws the index prefix
Returns
b if param index is HASH_FREE. Else return the code for this prefix and byte successor