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)

93 lines (92 loc) 3.12 kB
/** @format */ import { InputBuffer } from '../common/input-buffer.js'; import { MemoryImage } from '../image/image.js'; import { Decoder, DecoderDecodeOptions } from './decoder.js'; import { ImageFormat } from './image-format.js'; import { PnmInfo } from './pnm/pnm-info.js'; /** * Decode a PNM image. */ export declare class PnmDecoder implements Decoder { /** * Input buffer for the PNM decoder. */ private _input?; /** * Gets the input buffer. * @returns {InputBuffer<Uint8Array> | undefined} The input buffer or undefined if not set. */ get input(): InputBuffer<Uint8Array> | undefined; /** * Information about the PNM image. */ private _info?; /** * Gets the PNM image information. * @returns {PnmInfo | undefined} The PNM image information or undefined if not set. */ get info(): PnmInfo | undefined; /** * Gets the image format. * @returns {ImageFormat} The image format. */ get format(): ImageFormat; /** * Gets the number of frames in the image. * @returns {number} The number of frames. */ get numFrames(): number; /** * Tokens for parsing the PNM image. */ private _tokens; /** * Gets the next token from the input buffer. * @returns {string} The next token as a string. */ private getNextToken; /** * Parses the next integer from the input buffer. * @returns {number} The next integer. */ private parseNextInt; /** * Determines the format based on the maximum value. * @param {number} maxValue The maximum value. * @returns {Format} The format. */ private formatFromMaxValue; /** * Reads a value from the input buffer based on the format. * @param {PnmFormat} format The PNM format. * @param {number} _maxValue The maximum value. * @returns {number} The read value. */ private readValue; /** * Checks if the given file is a valid PNM image. * @param {Uint8Array} bytes The file bytes. * @returns {boolean} True if the file is a valid PNM image, otherwise false. */ isValidFile(bytes: Uint8Array): boolean; /** * Starts decoding the PNM image. * @param {Uint8Array} bytes The file bytes. * @returns {PnmInfo | undefined} The PNM image information or undefined if decoding fails. */ startDecode(bytes: Uint8Array): PnmInfo | undefined; /** * Decodes the PNM image. * @param {DecoderDecodeOptions} opt The decode options. * @param {Uint8Array} opt.bytes The file bytes. * @param {number} [opt.frameIndex] The frame index (optional). * @returns {MemoryImage | undefined} The decoded image or undefined if decoding fails. */ decode(opt: DecoderDecodeOptions): MemoryImage | undefined; /** * Decodes a specific frame of the PNM image. * @param {number} _frameIndex The frame index. * @returns {MemoryImage | undefined} The decoded image or undefined if decoding fails. */ decodeFrame(_frameIndex: number): MemoryImage | undefined; }