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)

114 lines (113 loc) 3.73 kB
/** @format */ /** * @property {number} lit - The literal value of the node. * @property {number} f - The frequency of the node. * @property {TreeNode} [l] - The left child node. * @property {TreeNode} [r] - The right child node. * @property {number} [d] - The depth of the node. */ type TreeNode = { lit: number; f: number; l?: TreeNode; r?: TreeNode; d?: number; }; /** * Compresses data using the deflate algorithm without headers. * * @param {Uint8Array} data - The input data to be compressed. * @param {Uint8Array} out - The output buffer to store the compressed data. * @param {number} opos - The starting position in the output buffer. * @param {number} lvl - The compression level (0-9). * @returns {number} - The position in the output buffer after compression. */ export declare function deflateRaw(data: Uint8Array, out: Uint8Array, opos: number, lvl: number): number; /** * Generates Huffman trees for the literals, distances, and code lengths. * * @returns {Array} - An array containing the generated trees and related data. */ export declare function getTrees(): (number | number[])[]; /** * Sets the depth of the tree nodes. * * @param {TreeNode} t - The tree node. * @param {number} d - The current depth. * @returns {number} The maximum depth of the tree. */ export declare function setDepth(t: TreeNode, d: number): number; /** * Restricts the depth of the tree nodes. * * @param {Array<Object>} dps - The array of tree nodes. * @param {number} MD - The maximum depth. * @param {number} maxl - The current maximum depth. */ export declare function restrictDepth(dps: { lit: number; f: number; l?: unknown; r?: unknown; d?: number; }[], MD: number, maxl: number): void; /** * Inflates the given data using the provided buffer. * * @param {Uint8Array} data - The data to inflate. * @param {Uint8Array} [buf] - The buffer to use for inflation. * @returns {Uint8Array} The inflated data. */ export declare function inflate(data: Uint8Array, buf?: Uint8Array): Uint8Array; /** * Generates Huffman codes for the given tree. * * @param {Array<number>} tree - The tree structure. * @param {number} MAX_BITS - The maximum number of bits. */ export declare function makeCodes(tree: number[], MAX_BITS: number): void; /** * Converts codes to a map. * * @param {Array<number>} tree - The tree array containing codes. * @param {number} MAX_BITS - The maximum number of bits. * @param {Object} map - The map to store the converted codes. */ export declare function codes2map(tree: number[], MAX_BITS: number, map: Record<number, number>): void; /** * Reverses codes in the tree. * * @param {Array<number>} tree - The tree array containing codes. * @param {number} MAX_BITS - The maximum number of bits. */ export declare function revCodes(tree: number[], MAX_BITS: number): void; export declare const U: { next_code: Uint16Array<ArrayBuffer>; bl_count: Uint16Array<ArrayBuffer>; ordr: number[]; of0: number[]; exb: number[]; ldef: Uint16Array<ArrayBuffer>; df0: number[]; dxb: number[]; ddef: Uint32Array<ArrayBuffer>; flmap: Uint16Array<ArrayBuffer>; fltree: number[]; fdmap: Uint16Array<ArrayBuffer>; fdtree: number[]; lmap: Uint16Array<ArrayBuffer>; ltree: number[]; ttree: number[]; dmap: Uint16Array<ArrayBuffer>; dtree: number[]; imap: Uint16Array<ArrayBuffer>; itree: number[]; rev15: Uint16Array<ArrayBuffer>; lhst: Uint32Array<ArrayBuffer>; dhst: Uint32Array<ArrayBuffer>; ihst: Uint32Array<ArrayBuffer>; lits: Uint32Array<ArrayBuffer>; strt: Uint16Array<ArrayBuffer>; prev: Uint16Array<ArrayBuffer>; }; export {};