pub struct ImageEncoder { /* private fields */ }
Expand description
The ImageEncoder
struct is used to encode image buffers into image bytes with a specified format and color format.
Implementationsยง
Sourceยงimpl ImageEncoder
impl ImageEncoder
Sourcepub const fn new(format: ImageFormat, color_format: ColorFormat) -> Self
pub const fn new(format: ImageFormat, color_format: ColorFormat) -> Self
Sourcepub fn encode(
&self,
image_buffer: &[u8],
width: u32,
height: u32,
) -> Result<Vec<u8>, ImageEncoderError>
pub fn encode( &self, image_buffer: &[u8], width: u32, height: u32, ) -> Result<Vec<u8>, ImageEncoderError>
Encodes the image buffer into image bytes with the specified format.
ยงArguments
image_buffer
- The image buffer to encode.width
- The width of the image.height
- The height of the image.
ยงReturns
The encoded image bytes as a Vec<u8>
.
ยงErrors
Returns an ImageEncoderError
if the encoding fails or if the color format is unsupported.
Auto Trait Implementationsยง
impl Freeze for ImageEncoder
impl RefUnwindSafe for ImageEncoder
impl Send for ImageEncoder
impl Sync for ImageEncoder
impl Unpin for ImageEncoder
impl UnwindSafe for ImageEncoder
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
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more