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)

191 lines (190 loc) 8.68 kB
/** @format */ import { Color } from '../color/color.js'; import { Format, FormatType } from '../color/format.js'; import { MemoryImageData, MemoryImageDataGetBytesOptions } from './image-data.js'; import { Palette } from './palette.js'; import { Pixel } from './pixel.js'; import { PixelFloat16 } from './pixel-float16.js'; /** * Class representing a memory image data with Float16 precision. * Implements MemoryImageData and Iterable interfaces. */ export declare class MemoryImageDataFloat16 implements MemoryImageData, Iterable<Pixel> { /** The width of the image. */ private _width; /** Gets the width of the image. */ get width(): number; /** Sets the width of the image. */ set width(v: number); /** The height of the image. */ private _height; /** Gets the height of the image. */ get height(): number; /** Sets the height of the image. */ set height(v: number); /** The data of the image stored as a Uint16Array. */ private readonly _data; /** Gets the data of the image. */ get data(): Uint16Array; /** The number of channels in the image. */ private readonly _numChannels; /** Gets the number of channels in the image. */ get numChannels(): number; /** Gets the format of the image. */ get format(): Format; /** Gets the format type of the image. */ get formatType(): FormatType; /** Gets the buffer of the image data. */ get buffer(): ArrayBufferLike; /** Gets the row stride of the image data. */ get rowStride(): number; /** Gets the iterator for the image data. */ get iterator(): PixelFloat16; /** Gets the byte length of the image data. */ get byteLength(): number; /** Gets the length of the image data. */ get length(): number; /** Gets the maximum channel value of the image data. */ get maxChannelValue(): number; /** Gets the maximum index value of the image data. */ get maxIndexValue(): number; /** Checks if the image data has a palette. */ get hasPalette(): boolean; /** Gets the palette of the image data. */ get palette(): Palette | undefined; /** Checks if the image format is HDR. */ get isHdrFormat(): boolean; /** Checks if the image format is LDR. */ get isLdrFormat(): boolean; /** Gets the bits per channel of the image data. */ get bitsPerChannel(): number; /** * Constructs a new MemoryImageDataFloat16 instance. * @param {number} width - The width of the image. * @param {number} height - The height of the image. * @param {number} numChannels - The number of channels in the image. * @param {Uint16Array} [data] - Optional data for the image. */ constructor(width: number, height: number, numChannels: number, data?: Uint16Array); /** * Creates a new MemoryImageDataFloat16 instance from another instance. * @param {MemoryImageDataFloat16} other - The other MemoryImageDataFloat16 instance. * @param {boolean} [skipPixels=false] - Whether to skip copying pixel data. * @returns {MemoryImageDataFloat16} A new MemoryImageDataFloat16 instance. */ static from(other: MemoryImageDataFloat16, skipPixels?: boolean): MemoryImageDataFloat16; /** * Gets a range of pixels from the image data. * @param {number} x - The x-coordinate of the starting pixel. * @param {number} y - The y-coordinate of the starting pixel. * @param {number} width - The width of the range. * @param {number} height - The height of the range. * @returns {Iterator<Pixel>} An iterator for the range of pixels. */ getRange(x: number, y: number, width: number, height: number): Iterator<Pixel>; /** * Gets a color object from the given RGBA values. * @param {number} r - The red component. * @param {number} g - The green component. * @param {number} b - The blue component. * @param {number} [a] - The alpha component (optional). * @returns {Color} A Color object. */ getColor(r: number, g: number, b: number, a?: number): Color; /** * Gets a pixel from the image data at the specified coordinates. * @param {number} x - The x-coordinate of the pixel. * @param {number} y - The y-coordinate of the pixel. * @param {Pixel} [pixel] - An optional Pixel object to reuse. * @returns {Pixel} A Pixel object. */ getPixel(x: number, y: number, pixel?: Pixel): Pixel; /** * Sets a pixel in the image data at the specified coordinates. * @param {number} x - The x-coordinate of the pixel. * @param {number} y - The y-coordinate of the pixel. * @param {Color} p - The Color object to set. */ setPixel(x: number, y: number, p: Color): void; /** * Sets the red component of a pixel in the image data at the specified coordinates. * @param {number} x - The x-coordinate of the pixel. * @param {number} y - The y-coordinate of the pixel. * @param {number} r - The red component value. */ setPixelR(x: number, y: number, r: number): void; /** * Sets the RGB components of a pixel in the image data at the specified coordinates. * @param {number} x - The x-coordinate of the pixel. * @param {number} y - The y-coordinate of the pixel. * @param {number} r - The red component value. * @param {number} g - The green component value. * @param {number} b - The blue component value. */ setPixelRgb(x: number, y: number, r: number, g: number, b: number): void; /** * Sets the RGBA components of a pixel in the image data at the specified coordinates. * @param {number} x - The x-coordinate of the pixel. * @param {number} y - The y-coordinate of the pixel. * @param {number} r - The red component value. * @param {number} g - The green component value. * @param {number} b - The blue component value. * @param {number} a - The alpha component value. */ setPixelRgba(x: number, y: number, r: number, g: number, b: number, a: number): void; /** * Sets the RGB components of a pixel in the image data at the specified coordinates safely. * @param {number} x - The x-coordinate of the pixel. * @param {number} y - The y-coordinate of the pixel. * @param {number} r - The red component value. * @param {number} g - The green component value. * @param {number} b - The blue component value. */ setPixelRgbSafe(x: number, y: number, r: number, g: number, b: number): void; /** * Sets the RGBA components of a pixel in the image data at the specified coordinates safely. * @param {number} x - The x-coordinate of the pixel. * @param {number} y - The y-coordinate of the pixel. * @param {number} r - The red component value. * @param {number} g - The green component value. * @param {number} b - The blue component value. * @param {number} a - The alpha component value. */ setPixelRgbaSafe(x: number, y: number, r: number, g: number, b: number, a: number): void; /** * Clears the image data. * @param {Color} [_c] - Optional color to clear with. */ clear(_c?: Color): void; /** * Clones the current image data. * @param {boolean} [skipPixels=false] - Whether to skip copying pixel data. * @returns {MemoryImageDataFloat16} A new MemoryImageDataFloat16 instance. */ clone(skipPixels?: boolean): MemoryImageDataFloat16; /** * Converts the image data to a Uint8Array. * @returns {Uint8Array} A Uint8Array representing the image data. */ toUint8Array(): Uint8Array; /** * Gets the bytes of the image data. * @param {MemoryImageDataGetBytesOptions} [opt] - Optional options for getting the bytes. * @param {string} [opt.format] - The format in which to get the bytes (e.g., 'png', 'jpeg'). * @param {number} [opt.quality] - The quality of the image data (e.g., 0.8 for 80% quality). * @param {number} [opt.width] - The width of the image to resize to (optional). * @param {number} [opt.height] - The height of the image to resize to (optional). * @returns {Uint8Array} A Uint8Array representing the image data bytes. */ getBytes(opt?: MemoryImageDataGetBytesOptions): Uint8Array; /** * Converts the image data to a string representation. * @returns {string} A string representing the image data. */ toString(): string; /** * Gets the iterator for the image data. * @returns {Iterator<Pixel, Pixel, undefined>} An iterator for the image data. */ [Symbol.iterator](): Iterator<Pixel, Pixel, undefined>; }