Merge pull request #83 from Xeoncross/master

Add support for JPEG encoding
This commit is contained in:
Michael Fogleman 2019-08-26 15:13:58 -04:00 committed by GitHub
commit 4dc34561c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import (
"errors"
"image"
"image/color"
"image/jpeg"
"image/png"
"io"
"math"
@ -150,6 +151,13 @@ func (dc *Context) EncodePNG(w io.Writer) error {
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
// disable dashes. The values specify the lengths of each dash, with
// alternating on and off lengths.