diff --git a/encode.go b/encode.go index 0dd3a3e..c01322b 100644 --- a/encode.go +++ b/encode.go @@ -72,7 +72,8 @@ const ( ) type Writer struct { - dst io.Writer + dst io.Writer + options WriterOptions params encoderParams hasher_ hasherHandle diff --git a/writer.go b/writer.go index 92c128c..22f0faf 100644 --- a/writer.go +++ b/writer.go @@ -50,11 +50,8 @@ func NewWriterLevel(dst io.Writer, level int) *Writer { // NewWriterOptions is like NewWriter but specifies WriterOptions func NewWriterOptions(dst io.Writer, options WriterOptions) *Writer { w := new(Writer) + w.options = options w.Reset(dst) - w.params.quality = options.Quality - if options.LGWin > 0 { - w.params.lgwin = uint(options.LGWin) - } return w } @@ -63,6 +60,10 @@ func NewWriterOptions(dst io.Writer, options WriterOptions) *Writer { // instead. This permits reusing a Writer rather than allocating a new one. func (w *Writer) Reset(dst io.Writer) { encoderInitState(w) + w.params.quality = w.options.Quality + if w.options.LGWin > 0 { + w.params.lgwin = uint(w.options.LGWin) + } w.dst = dst }