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.86 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 { PixelUint32 } from './pixel-uint32.js'; /** * Class representing memory image data with Uint32 format. * Implements MemoryImageData and Iterable interfaces. */ export declare class MemoryImageDataUint32 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 Uint32Array format */ private readonly _data; /** Gets the data of the image */ get data(): Uint32Array; /** 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(): PixelUint32; /** 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 format is HDR */ get isHdrFormat(): boolean; /** Checks if the image format is LDR */ get isLdrFormat(): boolean; /** Gets the bits per channel */ get bitsPerChannel(): number; /** * Constructor for MemoryImageDataUint32 * @param {number} width - Width of the image * @param {number} height - Height of the image * @param {number} numChannels - Number of channels in the image * @param {Uint32Array} [data] - Optional data for the image */ constructor(width: number, height: number, numChannels: number, data?: Uint32Array); /** * Creates a new MemoryImageDataUint32 from another instance * @param {MemoryImageDataUint32} other - The other MemoryImageDataUint32 instance * @param {boolean} [skipPixels=false] - Whether to skip copying pixel data * @returns {MemoryImageDataUint32} A new MemoryImageDataUint32 instance */ static from(other: MemoryImageDataUint32, skipPixels?: boolean): MemoryImageDataUint32; /** * 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 component * @param {number} g - Green component * @param {number} b - Blue component * @param {number} [a] - Alpha component (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 component of a pixel at the given coordinates * @param {number} x - X coordinate * @param {number} y - Y coordinate * @param {number} r - Red component */ setPixelR(x: number, y: number, r: number): void; /** * Sets the RGB components of a pixel at the given coordinates * @param {number} x - X coordinate * @param {number} y - Y coordinate * @param {number} r - Red component * @param {number} g - Green component * @param {number} b - Blue component */ setPixelRgb(x: number, y: number, r: number, g: number, b: number): void; /** * Sets the RGBA components of a pixel at the given coordinates * @param {number} x - X coordinate * @param {number} y - Y coordinate * @param {number} r - Red component * @param {number} g - Green component * @param {number} b - Blue component * @param {number} a - Alpha component */ setPixelRgba(x: number, y: number, r: number, g: number, b: number, a: number): void; /** * Safely sets the RGB components of a pixel at the given coordinates * @param {number} x - X coordinate * @param {number} y - Y coordinate * @param {number} r - Red component * @param {number} g - Green component * @param {number} b - Blue component */ setPixelRgbSafe(x: number, y: number, r: number, g: number, b: number): void; /** * Safely sets the RGBA components of a pixel at the given coordinates * @param {number} x - X coordinate * @param {number} y - Y coordinate * @param {number} r - Red component * @param {number} g - Green component * @param {number} b - Blue component * @param {number} a - Alpha component */ 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 {MemoryImageDataUint32} A new MemoryImageDataUint32 instance */ clone(skipPixels?: boolean): MemoryImageDataUint32; /** * 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 retrieved * @param {number} [opt.height] - The height of the image data to be retrieved * @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; /** * Iterator for the image data * @returns {Iterator<Pixel, Pixel, undefined>} An iterator for the image data */ [Symbol.iterator](): Iterator<Pixel, Pixel, undefined>; }