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)

152 lines (151 loc) 6.32 kB
/** @format */ /** * Abstract class providing various bit manipulation utilities. */ export declare abstract class BitUtils { /** Uint8Array used for binary conversion. */ private static readonly _uint8; /** Int8Array view of the same buffer as _uint8 for conversion. */ private static readonly _uint8ToInt8; /** Int8Array used for binary conversion. */ private static readonly _int8; /** Uint8Array view of the same buffer as _int8 for conversion. */ private static readonly _int8ToUint8; /** Uint16Array used for binary conversion. */ private static readonly _uint16; /** Int16Array view of the same buffer as _uint16 for conversion. */ private static readonly _uint16ToInt16; /** Int16Array used for binary conversion. */ private static readonly _int16; /** Uint16Array view of the same buffer as _int16 for conversion. */ private static readonly _int16ToUint16; /** Uint32Array used for binary conversion. */ private static readonly _uint32; /** Int32Array view of the same buffer as _uint32 for conversion. */ private static readonly _uint32ToInt32; /** Float32Array view of the same buffer as _uint32 for conversion. */ private static readonly _uint32ToFloat32; /** Int32Array used for binary conversion. */ private static readonly _int32; /** Uint32Array view of the same buffer as _int32 for conversion. */ private static readonly _int32ToUint32; /** Float32Array used for binary conversion. */ private static readonly _float32; /** Uint32Array view of the same buffer as _float32 for conversion. */ private static readonly _float32ToUint32; /** BigUint64Array used for binary conversion. */ private static readonly _uint64; /** Float64Array view of the same buffer as _uint64 for conversion. */ private static readonly _uint64ToFloat64; /** Lookup table for reversing bytes. */ private static readonly _reverseByteTable; /** * Count the consecutive zero bits (trailing) on the right in parallel * https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightParallel * @param {number} v - The number to count trailing zero bits. * @returns {number} The number of trailing zero bits. */ static countTrailingZeroBits(v: number): number; /** * Reverse the bits of a byte. * @param {number} x - The byte to reverse. * @returns {number} The reversed byte. */ static reverseByte(x: number): number; /** * Signed shift right. * @param {number} v - The value to shift. * @param {number} n - The number of bits to shift. * @returns {number} The shifted value. */ static sshR(v: number, n: number): number; /** * Unsigned shift right. * @param {number} v - The value to shift. * @param {number} n - The number of bits to shift. * @returns {number} The shifted value. */ static ushR(v: number, n: number): number; /** * Signed shift left. * @param {number} v - The value to shift. * @param {number} n - The number of bits to shift. * @returns {number} The shifted value. */ static sshL(v: number, n: number): number; /** * Unsigned shift left. * @param {number} v - The value to shift. * @param {number} n - The number of bits to shift. * @returns {number} The shifted value. */ static ushL(v: number, n: number): number; /** * Binary conversion of a uint8 to an int8. This is equivalent in C to * typecasting an unsigned char to a char. * @param {number} d - The uint8 value to convert. * @returns {number} The converted int8 value. */ static uint8ToInt8(d: number): number; /** * Binary conversion of an int8 to a uint8. * @param {number} d - The int8 value to convert. * @returns {number} The converted uint8 value. */ static int8ToUint8(d: number): number; /** * Binary conversion of a uint16 to an int16. This is equivalent in C to * typecasting an unsigned short to a short. * @param {number} d - The uint16 value to convert. * @returns {number} The converted int16 value. */ static uint16ToInt16(d: number): number; /** * Binary conversion of an int16 to a uint16. This is equivalent in C to * typecasting a short to an unsigned short. * @param {number} d - The int16 value to convert. * @returns {number} The converted uint16 value. */ static int16ToUint16(d: number): number; /** * Binary conversion of a uint32 to an int32. This is equivalent in C to * typecasting an unsigned int to signed int. * @param {number} d - The uint32 value to convert. * @returns {number} The converted int32 value. */ static uint32ToInt32(d: number): number; /** * Binary conversion of a uint32 to a float32. This is equivalent in C to * typecasting an unsigned int to float. * @param {number} d - The uint32 value to convert. * @returns {number} The converted float32 value. */ static uint32ToFloat32(d: number): number; /** * Binary conversion of a uint64 to a float64. This is equivalent in C to * typecasting an unsigned long long to double. * @param {bigint} d - The uint64 value to convert. * @returns {number} The converted float64 value. */ static uint64ToFloat64(d: bigint): number; /** * Binary conversion of an int32 to a uint32. This is equivalent in C to * typecasting an int to an unsigned int. * @param {number} d - The int32 value to convert. * @returns {number} The converted uint32 value. */ static int32ToUint32(d: number): number; /** * Binary conversion of a float32 to a uint32. This is equivalent in C to * typecasting a float to unsigned int. * @param {number} d - The float32 value to convert. * @returns {number} The converted uint32 value. */ static float32ToUint32(d: number): number; /** * Debug method to get a binary string representation of a 32-bit number. * @param {number} value - The number to convert to binary string. * @returns {string} The binary string representation of the number. */ static debugBits32(value?: number): string; }