Struct repng::Encoder
[−]
[src]
pub struct Encoder<W, F> { /* fields omitted */ }
The main object, which does all of the encoding work.
Methods
impl<W: Write, F> Encoder<W, F>
[src]
pub fn finish(&mut self) -> Result<()>
[src]
Finish encoding an image, writing any delayed data.
pub fn chunk(&mut self, kind: &[u8; 4], data: &[u8]) -> Result<()>
[src]
Write a chunk with the given type and data.
ⓘImportant traits for &'a mut Wpub fn writer(&mut self) -> &mut W
[src]
Get access to the writer that this was built with.
Be careful, because you can easily corrupt the image with this method.
impl<W: Write, F: Filter> Encoder<W, F>
[src]
pub fn new(opts: &Options, sink: W) -> Result<Self>
[src]
Make a new encoder, which writes to a given sink, with a custom filter.
This method also immediately writes the PNG headers to the sink.
pub fn write(&mut self, rows: &[u8]) -> Result<()>
[src]
Feed zero or more rows to the encoder.
Rows are specified in top-to-bottom and left-to-right order.
Panics
This method panics if you try to write data that doesn't fit into a whole number of rows.
pub fn reset(&mut self, opts: &Options) -> Result<()>
[src]
Reset the encoder to encode another image with the given options.
There's a good chance that, before calling this method, you'll want to
call writer()
to get a mutable reference to the writer, and swap that
out with a different writer. This method also writes the headers of the
new image to the sink.
Warning
This currently doesn't change the compression level!