node-libpng
Version:
Unofficial bindings for node to libpng.
40 lines (39 loc) • 1.19 kB
TypeScript
import { ColorRGB } from "./rgb";
import { ColorRGBA } from "./rgba";
/**
* A palette used by libpng to lookup colors in.
*/
export declare type Palette = Map<number, ColorRGB>;
/**
* Represents a color of color type `ColorType.PALETTE`.
*
* @see ColorType
*/
export declare type ColorPalette = [number] & {
index: number;
};
/**
* Create a new color of type `ColorPalette`.
*
* @param index The value for the index on the palette.
*
* @return The color in palette representation.
*/
export declare function colorPalette(index: number): ColorPalette;
/**
* Checks if the given parameter is a color of type `ColorPalette`.
*
* @param color The input to check.
*
* @return `true` if `color` was of type `ColorPalette` and `false` otherwise.
*/
export declare function isColorPalette(color: any): color is ColorPalette;
/**
* Converts a color of type `ColorPalette` to `ColorRGBA`.
*
* @param color The color to convert.
* @param palette The palette of the image the color originated from. Used to lookup the color.
*
* @return The converted color in rgba format.
*/
export declare function convertPaletteToRGBA(color: ColorPalette, palette: Palette): ColorRGBA;