pub struct EncodingStream<W: Write> { /* private fields */ }Expand description
The main JPEG encoder.
Use the builder pattern to configure encoding options, then call
encode_rgb() or encode_gray()
to produce JPEG data.
§Presets
Use Encoder::new(preset) with a Preset to choose your settings:
Preset::ProgressiveBalanced- Progressive with all optimizations (default)Preset::BaselineBalanced- Baseline with all optimizationsPreset::BaselineFastest- No optimizations, maximum speedPreset::ProgressiveSmallest- Maximum compression (matches C mozjpeg)
§Example
use mozjpeg_rs::{Encoder, Preset};
let pixels: Vec<u8> = vec![0; 640 * 480 * 3];
let jpeg = Encoder::new(Preset::default())
.quality(85)
.encode_rgb(&pixels, 640, 480)?;Active streaming encoding session.
Created by StreamingEncoder::start_rgb() or StreamingEncoder::start_gray().
Accepts scanlines via write_scanlines() and must be
finalized with finish().
Implementations§
Source§impl<W: Write> EncodingStream<W>
impl<W: Write> EncodingStream<W>
Sourcepub fn write_scanlines(&mut self, data: &[u8]) -> Result<()>
pub fn write_scanlines(&mut self, data: &[u8]) -> Result<()>
Write scanlines to the encoder.
Scanlines are buffered until a complete MCU row is available, then encoded.
The number of bytes should be num_lines * width * bytes_per_pixel.
For best performance, write in multiples of the MCU height (8 or 16 lines).
Auto Trait Implementations§
impl<W> Freeze for EncodingStream<W>where
W: Freeze,
impl<W> RefUnwindSafe for EncodingStream<W>where
W: RefUnwindSafe,
impl<W> Send for EncodingStream<W>where
W: Send,
impl<W> Sync for EncodingStream<W>where
W: Sync,
impl<W> Unpin for EncodingStream<W>where
W: Unpin,
impl<W> UnwindSafe for EncodingStream<W>where
W: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more