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)

337 lines (336 loc) 10 kB
/** @format */ import { Channel } from '../color/channel.js'; import { Color, ColorConvertOptions } from '../color/color.js'; import { Format } from '../color/format.js'; import { MemoryImage } from './image.js'; import { MemoryImageDataInt16 } from './image-data-int16.js'; import { Palette } from './palette.js'; import { Pixel } from './pixel.js'; /** * Class representing a Pixel with Int16 data. */ export declare class PixelInt16 implements Pixel, Iterable<Pixel>, Iterator<Pixel> { /** * The index of the pixel. * @private */ private _index; /** * The image data associated with the pixel. * @private */ private readonly _image; /** * Gets the image data associated with the pixel. * @returns {MemoryImageDataInt16} The image data. */ get image(): MemoryImageDataInt16; /** * The x-coordinate of the pixel. * @private */ private _x; /** * Gets the x-coordinate of the pixel. * @returns {number} The x-coordinate. */ get x(): number; /** * The y-coordinate of the pixel. * @private */ private _y; /** * Gets the y-coordinate of the pixel. * @returns {number} The y-coordinate. */ get y(): number; /** * Gets the normalized x-coordinate of the pixel. * @returns {number} The normalized x-coordinate. */ get xNormalized(): number; /** * Gets the normalized y-coordinate of the pixel. * @returns {number} The normalized y-coordinate. */ get yNormalized(): number; /** * Gets the index of the pixel. * @returns {number} The index. */ get index(): number; /** * Sets the index of the pixel. * @param {number} i - The index. */ set index(i: number); /** * Gets the data of the pixel. * @returns {Int16Array} The data. */ get data(): Int16Array; /** * Checks if the pixel is valid. * @returns {boolean} True if valid, otherwise false. */ get isValid(): boolean; /** * Gets the width of the image. * @returns {number} The width. */ get width(): number; /** * Gets the height of the image. * @returns {number} The height. */ get height(): number; /** * Gets the length of the pixel data. * @returns {number} The length. */ get length(): number; /** * Gets the number of channels in the pixel data. * @returns {number} The number of channels. */ get numChannels(): number; /** * Gets the maximum channel value. * @returns {number} The maximum channel value. */ get maxChannelValue(): number; /** * Gets the maximum index value. * @returns {number} The maximum index value. */ get maxIndexValue(): number; /** * Gets the format of the pixel data. * @returns {Format} The format. */ get format(): Format; /** * Checks if the format is LDR. * @returns {boolean} True if LDR format, otherwise false. */ get isLdrFormat(): boolean; /** * Checks if the format is HDR. * @returns {boolean} True if HDR format, otherwise false. */ get isHdrFormat(): boolean; /** * Checks if the image has a palette. * @returns {boolean} True if has a palette, otherwise false. */ get hasPalette(): boolean; /** * Gets the palette of the image. * @returns {Palette | undefined} The palette. */ get palette(): Palette | undefined; /** * Gets the red channel value. * @returns {number} The red channel value. */ get r(): number; /** * Sets the red channel value. * @param {number} r - The red channel value. */ set r(r: number); /** * Gets the green channel value. * @returns {number} The green channel value. */ get g(): number; /** * Sets the green channel value. * @param {number} g - The green channel value. */ set g(g: number); /** * Gets the blue channel value. * @returns {number} The blue channel value. */ get b(): number; /** * Sets the blue channel value. * @param {number} b - The blue channel value. */ set b(b: number); /** * Gets the alpha channel value. * @returns {number} The alpha channel value. */ get a(): number; /** * Sets the alpha channel value. * @param {number} a - The alpha channel value. */ set a(a: number); /** * Gets the normalized red channel value. * @returns {number} The normalized red channel value. */ get rNormalized(): number; /** * Sets the normalized red channel value. * @param {number} v - The normalized red channel value. */ set rNormalized(v: number); /** * Gets the normalized green channel value. * @returns {number} The normalized green channel value. */ get gNormalized(): number; /** * Sets the normalized green channel value. * @param {number} v - The normalized green channel value. */ set gNormalized(v: number); /** * Gets the normalized blue channel value. * @returns {number} The normalized blue channel value. */ get bNormalized(): number; /** * Sets the normalized blue channel value. * @param {number} v - The normalized blue channel value. */ set bNormalized(v: number); /** * Gets the normalized alpha channel value. * @returns {number} The normalized alpha channel value. */ get aNormalized(): number; /** * Sets the normalized alpha channel value. * @param {number} v - The normalized alpha channel value. */ set aNormalized(v: number); /** * Gets the luminance of the pixel. * @returns {number} The luminance. */ get luminance(): number; /** * Gets the normalized luminance of the pixel. * @returns {number} The normalized luminance. */ get luminanceNormalized(): number; /** * Creates an instance of PixelInt16. * @param {number} x - The x-coordinate. * @param {number} y - The y-coordinate. * @param {number} index - The index. * @param {MemoryImageDataInt16} image - The image data. */ constructor(x: number, y: number, index: number, image: MemoryImageDataInt16); /** * Creates a PixelInt16 instance from image data. * @param {MemoryImageDataInt16} image - The image data. * @returns {PixelInt16} The PixelInt16 instance. */ static imageData(image: MemoryImageDataInt16): PixelInt16; /** * Creates a PixelInt16 instance from an image. * @param {MemoryImage} image - The image. * @returns {PixelInt16} The PixelInt16 instance. */ static image(image: MemoryImage): PixelInt16; /** * Creates a PixelInt16 instance from another PixelInt16 instance. * @param {PixelInt16} other - The other PixelInt16 instance. * @returns {PixelInt16} The new PixelInt16 instance. */ static from(other: PixelInt16): PixelInt16; /** * Advances the iterator to the next pixel. * @returns {IteratorResult<Pixel>} The next pixel. */ next(): IteratorResult<Pixel>; /** * Sets the position of the pixel. * @param {number} x - The x-coordinate. * @param {number} y - The y-coordinate. */ setPosition(x: number, y: number): void; /** * Sets the normalized position of the pixel. * @param {number} x - The normalized x-coordinate. * @param {number} y - The normalized y-coordinate. */ setPositionNormalized(x: number, y: number): void; /** * Gets the value of a specific channel. * @param {number | Channel} channel - The channel. * @returns {number} The channel value. */ getChannel(channel: number | Channel): number; /** * Gets the normalized value of a specific channel. * @param {Channel} channel - The channel. * @returns {number} The normalized channel value. */ getChannelNormalized(channel: Channel): number; /** * Sets the value of a specific channel. * @param {number} channel - The channel. * @param {number} value - The value. */ setChannel(channel: number, value: number): void; /** * Sets the color of the pixel. * @param {Color} color - The color. */ set(color: Color): void; /** * Sets the RGB values of the pixel. * @param {number} r - The red value. * @param {number} g - The green value. * @param {number} b - The blue value. */ setRgb(r: number, g: number, b: number): void; /** * Sets the RGBA values of the pixel. * @param {number} r - The red value. * @param {number} g - The green value. * @param {number} b - The blue value. * @param {number} a - The alpha value. */ setRgba(r: number, g: number, b: number, a: number): void; /** * Converts the pixel data to an array. * @returns {number[]} The array of pixel data. */ toArray(): number[]; /** * Checks if the pixel is equal to another pixel or array. * @param {Pixel | number[]} other - The other pixel or array. * @returns {boolean} True if equal, otherwise false. */ equals(other: Pixel | number[]): boolean; /** * Clones the pixel. * @returns {PixelInt16} The cloned pixel. */ clone(): PixelInt16; /** * Converts the pixel to a different color format. * @param {ColorConvertOptions} opt - The conversion options. * @returns {Color} The converted color. */ convert(opt: ColorConvertOptions): Color; /** * Converts the pixel to a string representation. * @returns {string} The string representation. */ toString(): string; /** * Returns the iterator for the pixel. * @returns {Iterator<Pixel>} The iterator. */ [Symbol.iterator](): Iterator<Pixel>; }