UNPKG

vtf-js

Version:

A javascript IO library for the Valve Texture Format.

29 lines (28 loc) 2.2 kB
import { VFileHeader } from '../vtf.js'; import { VCompressionMethods } from './enums.js'; /** Returns the size of a given mipmap if mipmap 0 is of size `width`,`height` */ export declare function getMipSize(mipmap: number, width: number, height: number): [number, number]; /** Returns an estimated header length for the given vtf version and resource count. */ export declare function getHeaderLength(version: number, resources?: number): number; /** Returns the number of faces that should be expected with the given header. */ export declare function getFaceCount(info: VFileHeader): 1 | 6 | 7; /** Returns the first mipmap which does not exceed `target` in width or height. */ export declare function getThumbMip(width: number, height: number, target?: number): number; /** Clamps the value `x` between `a` and `b` */ export declare function clamp(x: number, a: number, b: number): number; /** The % operator in Javascript is for remainders. This does a proper modulo as defined by MDN. */ export declare function mod(n: number, d: number): number; /** Rounds the provided integer to the next multiple of 4. */ export declare function ceil4(x: number): number; /** Converts 0xAABBCC to 0xCCBBAA. */ export declare function byteswap3(x: number): number; /** Defines a data compression function. */ export type CompressFunction = (data: Uint8Array, method: VCompressionMethods, level: number) => Promise<Uint8Array> | Uint8Array; /** Defines a data decompression function. */ export type DecompressFunction = (data: Uint8Array, method: VCompressionMethods, level?: number) => Promise<Uint8Array> | Uint8Array; /** Sets the compression/decompression methods used when encoding/decoding Strata-compressed Vtfs. */ export declare function setCompressionMethod(fn_compress: CompressFunction, fn_decompress: DecompressFunction): void; /** Compresses the specified Uint8Array with the given options and returns the result. */ export declare let compress: CompressFunction; /** Decompresses the specified Uint8Array with the given options and returns the result. `level` is not currently used, but is included in the signature for future compatibility. */ export declare let decompress: DecompressFunction;