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.69 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 { PixelInt16 } from './pixel-int16.js'; /** * Represents a memory image data with 16-bit integer channels. * Implements MemoryImageData and Iterable interfaces. */ export declare class MemoryImageDataInt16 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 image data stored as a 16-bit integer array. */ private readonly _data; /** Gets the image data stored as a 16-bit integer array. */ get data(): Int16Array; /** 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 data. */ get format(): Format; /** Gets the format type of the image data. */ 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(): PixelInt16; /** 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 for the image data. */ get maxChannelValue(): number; /** Gets the maximum index value for 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 data is in HDR format. */ get isHdrFormat(): boolean; /** Checks if the image data is in LDR format. */ get isLdrFormat(): boolean; /** Gets the bits per channel for the image data. */ get bitsPerChannel(): number; /** * Constructs a new MemoryImageDataInt16 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 {Int16Array} [data] - Optional initial data for the image. */ constructor(width: number, height: number, numChannels: number, data?: Int16Array); /** * Creates a new MemoryImageDataInt16 instance from another instance. * @param {MemoryImageDataInt16} other - The other MemoryImageDataInt16 instance. * @param {boolean} [skipPixels=false] - Whether to skip copying pixel data. * @returns {MemoryImageDataInt16} A new MemoryImageDataInt16 instance. */ static from(other: MemoryImageDataInt16, skipPixels?: boolean): MemoryImageDataInt16; /** * 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 channel values. * @param {number} r - The red channel value. * @param {number} g - The green channel value. * @param {number} b - The blue channel value. * @param {number} [a] - The alpha channel value (optional). * @returns {Color} A Color object. */ getColor(r: number, g: number, b: number, a?: number): Color; /** * Gets a pixel object 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 at the specified coordinates with the given color. * @param {number} x - The x-coordinate of the pixel. * @param {number} y - The y-coordinate of the pixel. * @param {Color} p - The color to set. */ setPixel(x: number, y: number, p: Color): void; /** * Sets the red channel of a pixel 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 channel value. */ setPixelR(x: number, y: number, r: number): void; /** * Sets the RGB channels of a pixel 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 channel value. * @param {number} g - The green channel value. * @param {number} b - The blue channel value. */ setPixelRgb(x: number, y: number, r: number, g: number, b: number): void; /** * Sets the RGBA channels of a pixel 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 channel value. * @param {number} g - The green channel value. * @param {number} b - The blue channel value. * @param {number} a - The alpha channel value. */ setPixelRgba(x: number, y: number, r: number, g: number, b: number, a: number): void; /** * Safely sets the RGB channels of a pixel 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 channel value. * @param {number} g - The green channel value. * @param {number} b - The blue channel value. */ setPixelRgbSafe(x: number, y: number, r: number, g: number, b: number): void; /** * Safely sets the RGBA channels of a pixel 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 channel value. * @param {number} g - The green channel value. * @param {number} b - The blue channel value. * @param {number} a - The alpha channel value. */ setPixelRgbaSafe(x: number, y: number, r: number, g: number, b: number, a: number): void; /** * Clears the image data with the specified color. * @param {Color} [_c] - The color to clear with (optional). */ clear(_c?: Color): void; /** * Clones the current MemoryImageDataInt16 instance. * @param {boolean} [skipPixels=false] - Whether to skip copying pixel data. * @returns {MemoryImageDataInt16} A new MemoryImageDataInt16 instance. */ clone(skipPixels?: boolean): MemoryImageDataInt16; /** * Converts the image data to a Uint8Array. * @returns {Uint8Array} A Uint8Array representing the image data. */ toUint8Array(): Uint8Array; /** * Gets the bytes of the image data with optional parameters. * @param {MemoryImageDataGetBytesOptions} [opt] - The options for getting the bytes. * @param {number} [opt.width] - The width of the image. If not provided, the default width is used. * @param {number} [opt.height] - The height of the image. If not provided, the default height is used. * @param {string} [opt.format] - The format of the image data. Can be 'RGBA', 'RGB', etc. * @param {boolean} [opt.flipY] - A boolean indicating whether to flip the image vertically. * @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>; }