diff --git a/context.go b/context.go index b2cc402..c2e917e 100644 --- a/context.go +++ b/context.go @@ -5,6 +5,8 @@ import ( "image" "image/color" "image/draw" + "image/png" + "io" "math" "github.com/golang/freetype/raster" @@ -103,6 +105,11 @@ func (dc *Context) SavePNG(path string) error { return SavePNG(path, dc.im) } +// EncodePNG encodes the image as a PNG and writes it to the provided io.Writer. +func (dc *Context) EncodePNG(w io.Writer) error { + return png.Encode(w, dc.im) +} + // SetDash sets the current dash pattern to use. Call with zero arguments to // disable dashes. The values specify the lengths of each dash, with // alternating on and off lengths.