BmpEncoder

Struct BmpEncoder 

Source
pub struct BmpEncoder<'a, W>
where W: 'a,
{ /* private fields */ }
Expand description

The representation of a BMP encoder.

Implementations§

Source§

impl<'a, W> BmpEncoder<'a, W>
where W: Write + 'a,

Source

pub fn new(w: &'a mut W) -> BmpEncoder<'a, W>

Create a new encoder that writes its output to w.

Source

pub fn encode( &mut self, image: &[u8], width: u32, height: u32, c: ExtendedColorType, ) -> Result<(), ImageError>

Encodes the image image that has dimensions width and height and ExtendedColorType c.

§Panics

Panics if width * height * c.bytes_per_pixel() != image.len().

Source

pub fn encode_with_palette( &mut self, image: &[u8], width: u32, height: u32, c: ExtendedColorType, palette: Option<&[[u8; 3]]>, ) -> Result<(), ImageError>

Same as encode, but allow a palette to be passed in. The palette is ignored for color types other than Luma/Luma-with-alpha.

§Panics

Panics if width * height * c.bytes_per_pixel() != image.len().

Trait Implementations§

Source§

impl<W> ImageEncoder for BmpEncoder<'_, W>
where W: Write,

Source§

fn write_image( self, buf: &[u8], width: u32, height: u32, color_type: ExtendedColorType, ) -> Result<(), ImageError>

Writes all the bytes in an image to the encoder. Read more
Source§

fn set_icc_profile( &mut self, icc_profile: Vec<u8>, ) -> Result<(), UnsupportedError>

Set the ICC profile to use for the image. Read more

Auto Trait Implementations§

§

impl<'a, W> Freeze for BmpEncoder<'a, W>

§

impl<'a, W> RefUnwindSafe for BmpEncoder<'a, W>
where W: RefUnwindSafe,

§

impl<'a, W> Send for BmpEncoder<'a, W>
where W: Send,

§

impl<'a, W> Sync for BmpEncoder<'a, W>
where W: Sync,

§

impl<'a, W> Unpin for BmpEncoder<'a, W>

§

impl<'a, W> !UnwindSafe for BmpEncoder<'a, W>

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> RoundFrom<T> for T

Source§

fn round_from(x: T) -> T

Performs the conversion.
Source§

impl<T, U> RoundInto<U> for T
where U: RoundFrom<T>,

Source§

fn round_into(self) -> U

Performs the conversion.
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.