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)
190 lines (189 loc) • 7.86 kB
TypeScript
/** @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 { PixelFloat64 } from './pixel-float64.js';
/**
* Class representing a memory image data with Float64 precision.
* Implements MemoryImageData and Iterable interfaces.
*/
export declare class MemoryImageDataFloat64 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 array containing pixel values */
private readonly _data;
/** Getter for the data array */
get data(): Float64Array;
/** Number of channels in the image */
private readonly _numChannels;
/** Getter for the number of channels */
get numChannels(): number;
/** Getter for the format of the image */
get format(): Format;
/** Getter for the format type of the image */
get formatType(): FormatType;
/** Getter for the buffer of the image data */
get buffer(): ArrayBufferLike;
/** Getter for the row stride of the image data */
get rowStride(): number;
/** Getter for the iterator of the image data */
get iterator(): PixelFloat64;
/** Getter for the byte length of the image data */
get byteLength(): number;
/** Getter for the length of the image data */
get length(): number;
/** Getter for the maximum channel value */
get maxChannelValue(): number;
/** Getter for the maximum index value */
get maxIndexValue(): number;
/** Getter to check if the image has a palette */
get hasPalette(): boolean;
/** Getter for the palette of the image */
get palette(): Palette | undefined;
/** Getter to check if the image format is HDR */
get isHdrFormat(): boolean;
/** Getter to check if the image format is LDR */
get isLdrFormat(): boolean;
/** Getter for the bits per channel */
get bitsPerChannel(): number;
/**
* Constructor for MemoryImageDataFloat64
* @param {number} width - Width of the image
* @param {number} height - Height of the image
* @param {number} numChannels - Number of channels in the image
* @param {Float64Array} [data] - Optional data array containing pixel values
*/
constructor(width: number, height: number, numChannels: number, data?: Float64Array);
/**
* Creates a new MemoryImageDataFloat64 instance from another instance
* @param {MemoryImageDataFloat64} other - Another MemoryImageDataFloat64 instance
* @param {boolean} [skipPixels=false] - Whether to skip copying pixel data
* @returns {MemoryImageDataFloat64} A new MemoryImageDataFloat64 instance
*/
static from(other: MemoryImageDataFloat64, skipPixels?: boolean): MemoryImageDataFloat64;
/**
* Gets a range of pixels from the image
* @param {number} x - X coordinate of the starting pixel
* @param {number} y - Y coordinate of the starting pixel
* @param {number} width - Width of the range
* @param {number} height - 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 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 {MemoryImageDataFloat64} A new MemoryImageDataFloat64 instance
*/
clone(skipPixels?: boolean): MemoryImageDataFloat64;
/**
* Converts the image data to a Uint8Array
* @returns {Uint8Array} A Uint8Array containing 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 (optional)
* @param {number} [opt.height] - The height of the image (optional)
* @param {string} [opt.format] - The format of the image data (optional)
* @returns {Uint8Array} A Uint8Array containing 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>;
}