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)

153 lines (152 loc) 5.74 kB
/** @format */ import { InputBuffer } from '../../common/input-buffer.js'; /** * Interface representing the options for reading. */ export interface ReadOptions { /** The input buffer containing the data. */ input: InputBuffer<Uint8Array>; /** The ID of the channel. */ id: number; /** The width of the image. */ width: number; /** The height of the image. */ height: number; /** The bit depth of the image. */ bitDepth: number; /** The compression type used. */ compression: number; /** The plane number. */ planeNumber: number; /** Optional array of line lengths. */ lineLengths?: Uint16Array; } /** * Interface representing the options for reading a plane. */ export interface ReadPlaneOptions { /** The input buffer containing the data. */ input: InputBuffer<Uint8Array>; /** The width of the image. */ width: number; /** The height of the image. */ height: number; /** The bit depth of the image. */ bitDepth: number; /** Optional compression type used. */ compression?: number; /** Optional array of line lengths. */ lineLengths?: Uint16Array; /** Optional plane number. */ planeNumber?: number; } /** * Class representing a PSD channel. */ export declare class PsdChannel { /** Red channel identifier. */ static readonly red = 0; /** Green channel identifier. */ static readonly green = 1; /** Blue channel identifier. */ static readonly blue = 2; /** Black channel identifier. */ static readonly black = 3; /** Alpha channel identifier. */ static readonly alpha = -1; /** Mask channel identifier. */ static readonly mask = -2; /** Real mask channel identifier. */ static readonly realMask = -3; /** No compression identifier. */ static readonly compressNone = 0; /** RLE compression identifier. */ static readonly compressRle = 1; /** ZIP compression identifier. */ static readonly compressZip = 2; /** ZIP predictor compression identifier. */ static readonly compressZipPredictor = 3; /** The ID of the channel. */ private _id; /** The length of the data. */ private _dataLength; /** The data of the channel. */ private _data; /** * Gets the ID of the channel. */ get id(): number; /** * Gets the length of the data. */ get dataLength(): number | undefined; /** * Gets the data of the channel. */ get data(): Uint8Array | undefined; /** * Constructs a new PSD channel. * @param {number} id - The ID of the channel. * @param {number} [dataLength] - The length of the data. */ constructor(id: number, dataLength?: number); /** * Reads a PSD channel from the given options. * @param {ReadOptions} opt - The options for reading. * @param {number} opt.id - The identifier for the PSD channel. * @param {InputBuffer<Uint8Array>} opt.input - The input data for the PSD channel. * @param {number} opt.width - The width of the PSD channel. * @param {number} opt.height - The height of the PSD channel. * @param {number} opt.bitDepth - The bit depth of the PSD channel. * @param {number} opt.compression - The compression method used for the PSD channel. * @param {Uint16Array} opt.lineLengths - The lengths of the lines in the PSD channel. * @param {number} opt.planeNumber - The plane number of the PSD channel. * @returns {PsdChannel} The PSD channel. */ static read(opt: ReadOptions): PsdChannel; /** * Reads the line lengths from the input buffer. * @param {InputBuffer<Uint8Array>} input - The input buffer. * @param {number} height - The height of the image. * @returns {Uint16Array} The array of line lengths. */ private readLineLengths; /** * Reads an uncompressed plane from the input buffer. * @param {InputBuffer<Uint8Array>} input - The input buffer. * @param {number} width - The width of the image. * @param {number} height - The height of the image. * @param {number} bitDepth - The bit depth of the image. */ private readPlaneUncompressed; /** * Reads an RLE compressed plane from the input buffer. * @param {InputBuffer<Uint8Array>} input - The input buffer. * @param {number} width - The width of the image. * @param {number} height - The height of the image. * @param {number} bitDepth - The bit depth of the image. * @param {Uint16Array} lineLengths - The array of line lengths. * @param {number} planeNum - The plane number. */ private readPlaneRleCompressed; /** * Decodes RLE compressed data. * @param {InputBuffer<Uint8Array>} src - The source input buffer. * @param {Uint8Array} dst - The destination array. * @param {number} dstIndex - The starting index in the destination array. */ private decodeRLE; /** * Reads a plane from the given options. * @param {ReadPlaneOptions} opt - The options for reading the plane. * @param {InputBuffer<Uint8Array>} opt.input - The input data stream. * @param {number} opt.width - The width of the plane. * @param {number} opt.height - The height of the plane. * @param {number} opt.bitDepth - The bit depth of the plane. * @param {number} [opt.planeNumber] - The number of the plane (optional). * @param {number} [opt.compression] - The compression type (optional). * @param {Uint16Array} [opt.lineLengths] - The lengths of the lines for RLE compression (optional). * @throws {LibError} If the compression type is unsupported. */ readPlane(opt: ReadPlaneOptions): void; }