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) 7.91 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 { PixelInt32 } from './pixel-int32.js'; /** * Class representing memory image data in Int32 format. * Implements MemoryImageData and Iterable interfaces. */ export declare class MemoryImageDataInt32 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); /** Data of the image in Int32Array format */ private readonly _data; /** Gets the data of the image */ get data(): Int32Array; /** 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 */ get rowStride(): number; /** Gets the iterator for the image data */ get iterator(): PixelInt32; /** 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 */ get maxChannelValue(): number; /** Gets the maximum index value */ get maxIndexValue(): number; /** Checks if the image has a palette */ get hasPalette(): boolean; /** Gets the palette of the image */ get palette(): Palette | undefined; /** Checks if the image is in HDR format */ get isHdrFormat(): boolean; /** Checks if the image is in LDR format */ get isLdrFormat(): boolean; /** Gets the bits per channel */ get bitsPerChannel(): number; /** * Constructor for MemoryImageDataInt32 * @param {number} width - Width of the image * @param {number} height - Height of the image * @param {number} numChannels - Number of channels in the image * @param {Int32Array} [data] - Optional data for the image */ constructor(width: number, height: number, numChannels: number, data?: Int32Array); /** * Creates a new MemoryImageDataInt32 from another instance * @param {MemoryImageDataInt32} other - Another MemoryImageDataInt32 instance * @param {boolean} [skipPixels=false] - Whether to skip copying pixel data * @returns {MemoryImageDataInt32} A new MemoryImageDataInt32 instance */ static from(other: MemoryImageDataInt32, skipPixels?: boolean): MemoryImageDataInt32; /** * Gets a range of pixels from the image * @param {number} x - X coordinate of the starting point * @param {number} y - Y coordinate of the starting point * @param {number} width - Width of the range * @param {number} height - Height of the range * @returns {Iterator<Pixel>} An iterator for the pixel range */ getRange(x: number, y: number, width: number, height: number): Iterator<Pixel>; /** * Gets a color object from the given RGBA values * @param {number} r - Red channel value * @param {number} g - Green channel value * @param {number} b - Blue channel value * @param {number} [a] - 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 given coordinates * @param {number} x - X coordinate * @param {number} y - Y coordinate * @param {Pixel} [pixel] - Optional pixel object to reuse * @returns {Pixel} A Pixel object */ getPixel(x: number, y: number, pixel?: Pixel): Pixel; /** * Sets a pixel at the given coordinates with the given color * @param {number} x - X coordinate * @param {number} y - Y coordinate * @param {Color} p - Color object */ setPixel(x: number, y: number, p: Color): void; /** * Sets the red channel of a pixel at the given coordinates * @param {number} x - X coordinate * @param {number} y - Y coordinate * @param {number} r - Red channel value */ setPixelR(x: number, y: number, r: number): void; /** * Sets the RGB channels of a pixel at the given coordinates * @param {number} x - X coordinate * @param {number} y - Y coordinate * @param {number} r - Red channel value * @param {number} g - Green channel value * @param {number} b - Blue channel value */ setPixelRgb(x: number, y: number, r: number, g: number, b: number): void; /** * Sets the RGBA channels of a pixel at the given coordinates * @param {number} x - X coordinate * @param {number} y - Y coordinate * @param {number} r - Red channel value * @param {number} g - Green channel value * @param {number} b - Blue channel value * @param {number} a - 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 given coordinates * @param {number} x - X coordinate * @param {number} y - Y coordinate * @param {number} r - Red channel value * @param {number} g - Green channel value * @param {number} b - 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 given coordinates * @param {number} x - X coordinate * @param {number} y - Y coordinate * @param {number} r - Red channel value * @param {number} g - Green channel value * @param {number} b - Blue channel value * @param {number} a - Alpha channel 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 {MemoryImageDataInt32} A new MemoryImageDataInt32 instance */ clone(skipPixels?: boolean): MemoryImageDataInt32; /** * 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 {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 data to be returned * @param {number} [opt.height] - The height of the image data to be returned * @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>; }