formats.png

PNG encoding/decoding interface.

package ubyte[] encodePNG(const ubyte[] data, const uint width, const uint height, const ColorFormat format);

Encode image data to PNG format, ready to write to a file.

Parameters:
ubyte[] data Data to encode. Size of the array must correspond with specified width, height and color format.
uint width Image width in pixels.
uint height Image height in pixels.
ColorFormat format Color format of the image.
Returns:
Manually allocated array with encoded data. Must be manually freed.
Throws:
ImageFileException in case of an encoding error.
package ubyte[] decodePNG(const ubyte[] data, out uint width, out uint height, out ColorFormat format);

Decode data in PNG format to raw image data.

Parameters:
ubyte[] data Data to decode. Must be valid PNG data (e.g. loaded from a file).
uint width Image width in pixels will be written here.
uint height Image height in pixels will be written here.
ColorFormat format Color format of the image will be written here.
Returns:
Manually allocated decoded image data. Must be manually freed.
Throws:
ImageFileException on failure.