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)

76 lines (75 loc) 3.56 kB
/** @format */ /** * Reads an unsigned short (2 bytes) from a buffer at a specified position. * @param {Uint8Array} buff - The buffer to read from. * @param {number} p - The position in the buffer to start reading. * @returns {number} The unsigned short value read from the buffer. */ export declare function readUshort(buff: Uint8Array, p: number): number; /** * Writes an unsigned short (2 bytes) to a buffer at a specified position. * @param {Uint8Array} buff - The buffer to write to. * @param {number} p - The position in the buffer to start writing. * @param {number} n - The unsigned short value to write. */ export declare function writeUshort(buff: Uint8Array, p: number, n: number): void; /** * Reads an unsigned integer (4 bytes) from a buffer at a specified position. * @param {Uint8Array} buff - The buffer to read from. * @param {number} p - The position in the buffer to start reading. * @returns {number} The unsigned integer value read from the buffer. */ export declare function readUint(buff: Uint8Array, p: number): number; /** * Writes an unsigned integer (4 bytes) to a buffer at a specified position. * @param {Uint8Array} buff - The buffer to write to. * @param {number} p - The position in the buffer to start writing. * @param {number} n - The unsigned integer value to write. */ export declare function writeUint(buff: Uint8Array, p: number, n: number): void; /** * Reads an ASCII string from a buffer at a specified position and length. * @param {Uint8Array} buff - The buffer to read from. * @param {number} p - The position in the buffer to start reading. * @param {number} l - The length of the string to read. * @returns {string} The ASCII string read from the buffer. */ export declare function readASCII(buff: Uint8Array, p: number, l: number): string; /** * Writes an ASCII string to a buffer at a specified position. * @param {Uint8Array} data - The buffer to write to. * @param {number} p - The position in the buffer to start writing. * @param {string} s - The ASCII string to write. */ export declare function writeASCII(data: Uint8Array, p: number, s: string): void; /** * Pads a string with a leading zero if its length is less than 2. * @param {string} n - The string to pad. * @returns {string} The padded string. */ export declare function pad(n: string): string; /** * Reads a UTF-8 string from a buffer at a specified position and length. * @param {Uint8Array} buff - The buffer to read from. * @param {number} p - The position in the buffer to start reading. * @param {number} l - The length of the string to read. * @returns {string} The UTF-8 string read from the buffer. * @throws {Error} If the string cannot be decoded as UTF-8. */ export declare function readUTF8(buff: Uint8Array, p: number, l: number): string; /** * Writes a UTF-8 string to a buffer at a specified position. * @param {Uint8Array} buff - The buffer to write to. * @param {number} p - The position in the buffer to start writing. * @param {string} str - The UTF-8 string to write. * @returns {number} The number of bytes written. * @throws {Error} If the string contains an invalid UTF-8 code point. */ export declare function writeUTF8(buff: Uint8Array, p: number, str: string): number; /** * Calculates the size in bytes of a UTF-8 string. * @param {string} str - The UTF-8 string to measure. * @returns {number} The size in bytes of the UTF-8 string. * @throws {Error} If the string contains an invalid UTF-8 character. */ export declare function sizeUTF8(str: string): number;