Represents a color of color type ColorType.GRAY_SCALE_A
.
Represents a color of color type ColorType.PALETTE
.
Represents a color of color type ColorType.RGB
.
Represents a color of color type ColorType.RGBA
.
A palette used by libpng to lookup colors in.
Create a new color of type ColorGrayScale
.
The value for the gray
part of the color.
The color in gray scale representation.
Create a new color of type gray scale
with alpha channel.
The value for the gray
part of the color.
The value for the alpha channel part of the color.
The color in gray scale with alpha channel representation.
Create a new color of type ColorPalette
.
The value for the index on the palette.
The color in palette representation.
Create a new color of type number
.
The value for the red
part of the color.
The value for the green
part of the color.
The value for the blue
part of the color.
The color in rgb representation.
Create a new color of type number
.
The value for the red
part of the color.
The value for the green
part of the color.
The value for the blue
part of the color.
The value for the alpha channel part of the color.
The color in rgba representation.
Converts a color of type ColorGrayScaleAlpha
to ColorRGBA
.
The converted color in rgba format.
Converts a color of type ColorGrayScale
to ColorRGBA
.
The converted color in rgba format.
Converts the background color from the libpng bindings into a color.
The background color as returned by the native bindings.
The color type of the image of which the background color should be converted.
The converted background color in ColorRGB
, ColorPalette
or ColorGrayScale
format
or undefined if the background color was not set in the PNG.
Converts a native palette as returned by the bindings into a Map.
The native palette which should be converted.
The palette as a Palette
(Javascript Map with the key being the palette index and
the value being a color.
Converts the native time from the libpng bindings into a javascript Date
object.
The time as returned by the bindings.
The time converted to a javascript Date
object or undefined
if the time was
not set in the PNG's header.
Converts a color of type ColorPalette
to ColorRGBA
.
The color to convert.
The palette of the image the color originated from. Used to lookup the color.
The converted color in rgba format.
Convert a color in any format to rgba format.
The color to convert.
The palette to use if the color is in palette format. Will be ignored otherwise.
The color converted to rgba format or undefined
if the color couldn't be converted.
Decode a buffer of encoded PNG data into a PngImage
offering access to the raw image data.
The buffer to convert.
the decoded PNG as a PngImage
instance.
Encode a buffer of raw RGB or RGBA image data into PNG format.
Only RGB and RGBA color formats are supported. This function will automatically calculate whether an
alpha channel is present by calculating the amount of bytes per pixel from the length of the buffer
and the provided width
and height
. Only 8bit colors are supported.
The buffer of raw pixel data to encode.
Options used to encode the image.
the encoded PNG as a new buffer.
Checks if the given parameter is a color of type ColorGrayScale
.
The input to check.
true
if color
was of type ColorGrayScale
and false
otherwise.
Checks if the given parameter is a color of type ColorGrayScaleA
.
The input to check.
true
if color
was of type ColorGrayScaleA
and false
otherwise.
Checks if the given parameter is a color of type ColorPalette
.
The input to check.
true
if color
was of type ColorPalette
and false
otherwise.
Checks if the given parameter is a color of type ColorRGB
.
The input to check.
true
if color
was of type ColorRGB
and false
otherwise.
Checks if the given parameter is a color of type ColorRGBA
.
The input to check.
true
if color
was of type ColorRGBA
and false
otherwise.
Will check if the provided buffer contains a PNG image.
Under the hood this will call png_sig_cmp
and check for the
header of the buffer.
The buffer to check.
true
if the file was a PNG image file and false
otherwise.
Checks if the given parameter is a rectangle.
Parameter to check.
true
if the given parameter was a rectangle and false
otherwise.
Checks if the given parameter is a set of 2D coordinates.
Parameter to check.
true
if the given parameter was a set of coordinates and false
otherwise.
Invoke readPngFile
to asynchroneously read a png file into a decoded image.
For convenience, both Node.js callbacks and Promises are supported.
If no callback is provided as a second argument, a Promise is returned which will resolve
with the decoded image.
The path to the file to decode.
An optional callback to use instead of a returned Promise. Will be called with
an error as the first argument or null
if everything went well, and the decoded
image as a second argument if no error occured.
A Promise if no callback was provided and undefined
otherwise.
Invoke readPngFile
to asynchroneously read a png file into a decoded image.
For convenience, both Node.js callbacks and Promises are supported.
If no callback is provided as a second argument, a Promise is returned which will resolve
with the decoded image.
The path to the file to decode.
A Promise if no callback was provided and undefined
otherwise.
Decode a PNG file synchroneously.
The path to the file to decode.
The decoded image.
Invoke writePngFile
to asynchroneously write a raw buffer of pixel data as an encoded PNG image.
For convenience, both Node.js callbacks and Promises are supported.
If no callback is provided as a second argument, a Promise is returned which will resolve
once the file is written.
The path the file should be written to.
The buffer of raw pixel data which should be encoded and written to disk.
Options used to encode the image.
An optional callback to use instead of a returned Promise. Will be called with
an error as the first argument or null
if everything went well.
A Promise if no callback was provided and undefined
otherwise.
Invoke writePngFile
to asynchroneously write a raw buffer of pixel data as an encoded PNG image.
For convenience, both Node.js callbacks and Promises are supported.
If no callback is provided as a second argument, a Promise is returned which will resolve
once the file is written.
The path the file should be written to.
The buffer of raw pixel data which should be encoded and written to disk.
Options used to encode the image.
A Promise if no callback was provided and undefined
otherwise.
Encode and write a PNG file synchroneously.
The path the file should be written to.
The buffer of raw pixel data which should be encoded and written to disk.
Options used to encode the image.
The decoded image.
Creates a new set of 2D coordinates.
The x part of the coordinates.
The y part of the coordinates.
The new coordinates as an array which provides getters for x
and y
.
Generated using TypeDoc
Represents a color of color type
ColorType.GRAY_SCALE
.ColorType