RgbEncoder

Struct RgbEncoder 

Source
pub struct RgbEncoder<P: Pixel> { /* private fields */ }
Expand description

Encoder for rgb crate pixel types.

Type parameter P determines pixel layout at compile time. For RGBA/BGRA types, 4th channel is ignored.

Implementations§

Source§

impl<P: Pixel> RgbEncoder<P>

Source

pub fn push( &mut self, data: &[P], rows: usize, stride: usize, stop: impl Stop, ) -> Result<()>

Push rows with explicit stride (in pixels).

  • data: Pixel slice
  • rows: Number of scanlines to push
  • stride: Pixels per row in buffer (>= width)
  • stop: Cancellation token
Source

pub fn push_packed(&mut self, data: &[P], stop: impl Stop) -> Result<()>

Push contiguous (packed) data.

Stride assumed to be width. Rows inferred from data.len() / width.

Source

pub fn width(&self) -> u32

Get image width.

Source

pub fn height(&self) -> u32

Get image height.

Source

pub fn rows_pushed(&self) -> u32

Get number of rows pushed so far.

Source

pub fn rows_remaining(&self) -> u32

Get number of rows remaining.

Source

pub fn finish(self) -> Result<Vec<u8>>

Finish encoding, return JPEG bytes.

Source

pub fn finish_to<W: Write>(self, output: W) -> Result<W>

Finish encoding to Write destination.

Source

pub fn finish_to_vec(self, output: &mut Vec<u8>) -> Result<()>

Finish encoding, appending JPEG bytes to an existing Vec.

Useful for no_std environments or buffer reuse.

Auto Trait Implementations§

§

impl<P> Freeze for RgbEncoder<P>

§

impl<P> RefUnwindSafe for RgbEncoder<P>
where P: RefUnwindSafe,

§

impl<P> Send for RgbEncoder<P>
where P: Send,

§

impl<P> Sync for RgbEncoder<P>
where P: Sync,

§

impl<P> Unpin for RgbEncoder<P>
where P: Unpin,

§

impl<P> UnwindSafe for RgbEncoder<P>
where P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.