arsd.png

PNG file read and write. Leverages color.d's Image interfaces for interop.

Public Imports

arsd.color
public import arsd.color;
Undocumented in source.

Members

Enums

PngType
enum PngType

Functions

imageFromPng
MemoryImage imageFromPng(PNG* png)

The return value should be casted to indexed or truecolor depending on what the file is. You can also use getAsTrueColorImage to forcibly convert it if needed.

pngFromBytes
auto pngFromBytes(Range r)

Given an input range of bytes, return a lazy PNG file

readPng
MemoryImage readPng(string filename)

Easily reads a png file into a MemoryImage

readPngChunks
LazyPngChunks!(Range) readPngChunks(Range r)

Lazily breaks the buffered input range into png chunks, as defined in the PNG spec

readPngChunks
auto readPngChunks(Range r)

Same as above, but takes a regular input range instead of a buffered one. Provided for easier compatibility with standard input ranges (for example, std.stdio.File.byChunk)

writePng
void writePng(string filename, MemoryImage mi)

Saves a MemoryImage to a png. See also: writeImageToPngFile which uses memory a little more efficiently

writePng
void writePng(string filename, ubyte[] data, int width, int height, PngType type, ubyte depth)

Saves an image from an existing array. Note that depth other than 8 may not be implemented yet. Also note depth of 16 must be stored big endian

Static variables

PNG_MAGIC_NUMBER
immutable(ubyte[]) PNG_MAGIC_NUMBER;

All PNG files are supposed to open with these bytes according to the spec

Structs

BufferedInputRange
struct BufferedInputRange(Range)

Allows appending to front on a regular input range, if that range is an array. It appends to the array rather than creating an array of arrays; it's meant to make the illusion of one continuous front rather than simply adding capability to walk backward to an existing input range.

Chunk
struct Chunk

A PNG file consists of the magic number then a stream of chunks. This struct represents those chunks.

LazyPngFile
struct LazyPngFile(LazyPngChunksProvider)

Lazily reads out basic info from a png (header, palette, image data) It will only allocate memory to read a palette, and only copies on the header and the palette. It ignores everything else.

PngHeader
struct PngHeader

The first chunk in a PNG file is a header that contains this info

Templates

isBufferedInputRange
template isBufferedInputRange(R)

* Buffered input range - generic, non-image code Is the given range a buffered input range? That is, an input range that also provides consumeFromFront(int) and appendToFront()

Meta