@thi.ng/pixel-io-netpbm
Version:
Multi-format NetPBM reader & writer support for @thi.ng/pixel
97 lines • 3.28 kB
TypeScript
import type { Maybe } from "@thi.ng/api";
/**
* Parses header information from given NetPBM file byte buffer.
*
* @param src -
*/
export declare const parseHeader: (src: Uint8Array) => {
type: string;
width: number;
height: number;
max: Maybe<number>;
start: number;
comments: string[];
};
/**
* Takes a PBM/PGM/PPM file as byte array and parses it into a
* [`IntBuffer`](https://docs.thi.ng/umbrella/pixel/classes/IntBuffer.html) of
* corresponding format.
*
* @remarks
* Depending on header information, the following rules apply:
*
* - only binary NetPBM formats are supported (P4,P5,P6 types)
* - 1bit PBM (P4) => {@link readPBM}
* - grayscale PGM (P5) => {@link readPGM8} or {@link readPGM16}
* - 24bit RGB (P6) => {@link readPPM}
*
* Function will throw an error if image is of any other type or header is
* corrupt otherwise. Any embedded comments will be discarded.
*
* @param src -
*/
export declare const read: (src: Uint8Array) => import("@thi.ng/pixel").IntBuffer;
/**
* Reads pixels from given 1bit PBM file byte buffer, starting at index `i` and
* returns
* [`IntBuffer`](https://docs.thi.ng/umbrella/pixel/classes/IntBuffer.html) in
* `GRAY8` format (due to current lack of true 1bit format).
*
* @param src -
* @param i -
* @param width -
* @param height -
*/
export declare const readPBM: (src: Uint8Array, i: number, width: number, height: number) => import("@thi.ng/pixel").IntBuffer;
/**
* Reads pixels from given 8bit PGM file byte buffer, starting at index `i` and
* returns
* [`IntBuffer`](https://docs.thi.ng/umbrella/pixel/classes/IntBuffer.html) in
* `GRAY8` format. If needed, pixel values are rescaled given `max` value
* defined in PGM header (MUST be <= 0xff).
*
* @remarks
* Reference: http://netpbm.sourceforge.net/doc/pbm.html
*
* @param src -
* @param i -
* @param width -
* @param height -
* @param max -
*/
export declare const readPGM8: (src: Uint8Array, i: number, width: number, height: number, max?: number) => import("@thi.ng/pixel").IntBuffer;
/**
* Reads pixels from given 16bit PGM file byte buffer, starting at index `i` and
* returns
* [`IntBuffer`](https://docs.thi.ng/umbrella/pixel/classes/IntBuffer.html) in
* `GRAY16` format. Pixel values are rescaled given `max` value defined in PGM
* header (MUST be <= 0xffff).
*
* @remarks
* Reference: http://netpbm.sourceforge.net/doc/pgm.html
*
* @param src -
* @param i -
* @param width -
* @param height -
* @param max -
*/
export declare const readPGM16: (src: Uint8Array, i: number, width: number, height: number, max?: number) => import("@thi.ng/pixel").IntBuffer;
/**
* Reads pixels from given 24bit PPM file byte buffer, starting at index `i` and
* returns
* [`IntBuffer`](https://docs.thi.ng/umbrella/pixel/classes/IntBuffer.html) in
* `RGB888` format. Color channel values are rescaled given `max` value defined
* in PGM header (MUST be <= 0xff).
*
* @remarks
* Reference: http://netpbm.sourceforge.net/doc/pgm.html
*
* @param src -
* @param i -
* @param width -
* @param height -
* @param max -
*/
export declare const readPPM: (src: Uint8Array, i: number, width: number, height: number, max?: number) => import("@thi.ng/pixel").IntBuffer;
//# sourceMappingURL=read.d.ts.map