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)

80 lines (79 loc) 2.3 kB
/** @format */ /** * The format of a color or image. */ export declare enum Format { /** 1-bit unsigned integer */ uint1 = 0, /** 2-bit unsigned integer */ uint2 = 1, /** 4-bit unsigned integer */ uint4 = 2, /** 8-bit unsigned integer */ uint8 = 3, /** 16-bit unsigned integer */ uint16 = 4, /** 32-bit unsigned integer */ uint32 = 5, /** 8-bit signed integer */ int8 = 6, /** 16-bit signed integer */ int16 = 7, /** 32-bit signed integer */ int32 = 8, /** 16-bit floating point */ float16 = 9, /** 32-bit floating point */ float32 = 10, /** 64-bit floating point */ float64 = 11 } /** * The format type of a color or image. */ export declare enum FormatType { /** * Unsigned integer format. */ uint = 0, /** * Signed integer format. */ int = 1, /** * Floating point format. */ float = 2 } /** * A map that associates each Format with its corresponding FormatType. */ export declare const FormatToFormatType: Map<Format, FormatType>; /** * A map that associates each Format with its corresponding size in bytes. */ export declare const FormatSize: Map<Format, number>; /** * A map that associates each Format with its maximum value. */ export declare const FormatMaxValue: Map<Format, number>; /** * Calculates the row stride (the number of bytes per row) for an image based on its width, * number of channels, and pixel format. * * @param {number} width - The width of the image in pixels. * @param {number} numChannels - The number of color channels per pixel. * @param {Format} format - The pixel format of the image. * @returns {number} - The row stride in bytes. */ export declare function getRowStride(width: number, numChannels: number, format: Format): number; /** * Converts a numeric value from one format to another. * * @param {number} value - The numeric value to be converted. * @param {Format} from - The format of the input value. * @param {Format} to - The format to which the value should be converted. * @returns {number} - The converted numeric value. * @throws {LibError} If the format conversion is unknown. */ export declare function convertFormatValue(value: number, from: Format, to: Format): number;