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)

238 lines (237 loc) 8.89 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 { PixelUint16 } from './pixel-uint16.js'; /** * Class representing memory image data with 16-bit unsigned integer channels. */ export declare class MemoryImageDataUint16 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. */ private readonly _data; /** * Gets the image data. */ 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 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(): PixelUint16; /** * 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; /** * The palette of the image data. */ private _palette; /** * 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 of the image data. */ get bitsPerChannel(): number; /** * Creates an instance of MemoryImageDataUint16. * @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] - The image data. */ constructor(width: number, height: number, numChannels: number, data?: Uint16Array); /** * Creates a palette-based MemoryImageDataUint16. * @param {number} width - The width of the image. * @param {number} height - The height of the image. * @param {Palette} [palette] - The palette of the image. * @returns {MemoryImageDataUint16} A new MemoryImageDataUint16 instance. */ static palette(width: number, height: number, palette?: Palette): MemoryImageDataUint16; /** * Creates a new MemoryImageDataUint16 from another instance. * @param {MemoryImageDataUint16} other - The other MemoryImageDataUint16 instance. * @param {boolean} [skipPixels=false] - Whether to skip copying pixel data. * @returns {MemoryImageDataUint16} A new MemoryImageDataUint16 instance. */ static from(other: MemoryImageDataUint16, skipPixels?: boolean): MemoryImageDataUint16; /** * Gets a range of pixels from the image data. * @param {number} x - The x-coordinate of the range. * @param {number} y - The y-coordinate of the range. * @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 from the image data. * @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. * @returns {Color} A Color instance. */ getColor(r: number, g: number, b: number, a?: number): Color; /** * Gets a pixel from the image data. * @param {number} x - The x-coordinate of the pixel. * @param {number} y - The y-coordinate of the pixel. * @param {Pixel} [pixel] - An optional Pixel instance to reuse. * @returns {Pixel} A Pixel instance. */ getPixel(x: number, y: number, pixel?: Pixel): Pixel; /** * Sets a pixel in the image data. * @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 in the image data. * @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 in the image data. * @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 in the image data. * @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 in the image data. * @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 in the image data. * @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. * @param {Color} [_c] - The color to clear with. */ clear(_c?: Color): void; /** * Clones the image data. * @param {boolean} [skipPixels=false] - Whether to skip copying pixel data. * @returns {MemoryImageDataUint16} A new MemoryImageDataUint16 instance. */ clone(skipPixels?: boolean): MemoryImageDataUint16; /** * Converts the image data to a Uint8Array. * @returns {Uint8Array} A Uint8Array representation of the image data. */ toUint8Array(): Uint8Array; /** * Gets the bytes of the image data. * @param {MemoryImageDataGetBytesOptions} [opt] - Options for getting the bytes. * @param {number} [opt.width] - The width of the image. * @param {number} [opt.height] - The height of the image. * @param {string} [opt.format] - The format of the image data. * @param {number} [opt.quality] - The quality of the image data. * @returns {Uint8Array} A Uint8Array of the image data bytes. */ getBytes(opt?: MemoryImageDataGetBytesOptions): Uint8Array; /** * Converts the image data to a string representation. * @returns {string} A string representation of 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>; }