Added support for JPEG encoding

This commit is contained in:
xeoncross 2019-08-26 14:04:06 -05:00
parent f194ddec6f
commit 068da56c91

View File

@ -5,6 +5,7 @@ import (
"errors" "errors"
"image" "image"
"image/color" "image/color"
"image/jpeg"
"image/png" "image/png"
"io" "io"
"math" "math"
@ -150,6 +151,13 @@ func (dc *Context) EncodePNG(w io.Writer) error {
return png.Encode(w, dc.im) return png.Encode(w, dc.im)
} }
// EncodeJPG encodes the image as a JPG and writes it to the provided io.Writer
// in JPEG 4:2:0 baseline format with the given options.
// Default parameters are used if a nil *jpeg.Options is passed.
func (dc *Context) EncodeJPG(w io.Writer, o *jpeg.Options) error {
return jpeg.Encode(w, dc.im, o)
}
// SetDash sets the current dash pattern to use. Call with zero arguments to // SetDash sets the current dash pattern to use. Call with zero arguments to
// disable dashes. The values specify the lengths of each dash, with // disable dashes. The values specify the lengths of each dash, with
// alternating on and off lengths. // alternating on and off lengths.