UNPKG

image-in-browser

Version:

Package for encoding / decoding images, transforming images, applying filters, drawing primitives on images on the client side (no need for server Node.js)

99 lines (98 loc) 2.48 kB
/** @format */ import { InputBuffer } from '../../common/input-buffer.js'; /** * Class representing an LZW Decoder. */ export declare class LzwDecoder { /** * Maximum LZW code value. */ private static readonly _lzMaxCode; /** * Value representing no such code. */ private static readonly _noSuchCode; /** * Table for AND operations based on bits to get. */ private static readonly _andTable; /** * Buffer for storing decoded strings. */ private readonly _buffer; /** * Number of bits to get for the next code. */ private _bitsToGet; /** * Pointer to the current byte in the data. */ private _bytePointer; /** * Data for the next code. */ private _nextData; /** * Number of bits available in the next data. */ private _nextBits; /** * Input data to be decoded. */ private _data; /** * Length of the input data. */ private _dataLength; /** * Output buffer for the decoded data. */ private _out; /** * Pointer to the current position in the output buffer. */ private _outPointer; /** * Table for storing decoded strings. */ private _table; /** * Prefix table for the LZW algorithm. */ private _prefix; /** * Current index in the table. */ private _tableIndex?; /** * Length of the buffer. */ private _bufferLength; /** * Adds a new string to the string table. * @param {number} string - The existing string code. * @param {number} newString - The new string code to add. */ private addString; /** * Retrieves a string from the string table. * @param {number} code - The code of the string to retrieve. */ private getString; /** * Returns the next 9, 10, 11 or 12 bits. * @returns {number} The next code. */ private getNextCode; /** * Initialize the string table. */ private initializeStringTable; /** * Decodes the input buffer and writes the result to the output buffer. * @param {InputBuffer<Uint8Array>} p - The input buffer containing the data to decode. * @param {Uint8Array} out - The output buffer to write the decoded data to. * @throws {LibError} Throws an error if the input data is invalid. */ decode(p: InputBuffer<Uint8Array>, out: Uint8Array): void; }