FrenchCurve.Png (FrenchCurve v0.1.3)

Copy Markdown View Source

Encodes raw RGBA pixels as a PNG.

Only what FrenchCurve.Backend.Iterm2 needs to wrap a raster in the one image format iTerm2's inline-image protocol accepts. Encoding only; there is no decoder.

png = FrenchCurve.Png.encode(width, height, FrenchCurve.Raster.to_rgba_binary(raster))

Summary

Functions

Encodes a dense RGBA buffer as a complete PNG binary.

Functions

encode(width, height, rgba)

@spec encode(pos_integer(), pos_integer(), binary()) :: binary()

Encodes a dense RGBA buffer as a complete PNG binary.

rgba must be exactly width * height * 4 bytes, four bytes per pixel in red, green, blue, alpha order and rows top to bottom; a mismatched size raises FunctionClauseError, as do non-positive dimensions.

The result is an 8-bit-per-channel truecolour-with-alpha PNG whose scanlines all use filter type 0 and whose pixel data sits in a single zlib-compressed IDAT chunk.