Trait image::ImageEncoder
source · pub trait ImageEncoder {
// Required method
fn write_image(
self,
buf: &[u8],
width: u32,
height: u32,
color_type: ExtendedColorType
) -> ImageResult<()>;
}
Expand description
The trait all encoders implement
Required Methods§
sourcefn write_image(
self,
buf: &[u8],
width: u32,
height: u32,
color_type: ExtendedColorType
) -> ImageResult<()>
fn write_image( self, buf: &[u8], width: u32, height: u32, color_type: ExtendedColorType ) -> ImageResult<()>
Writes all the bytes in an image to the encoder.
This function takes a slice of bytes of the pixel data of the image and encodes them. Unlike particular format encoders inherent impl encode methods where endianness is not specified, here image data bytes should always be in native endian. The implementor will reorder the endianness as necessary for the target encoding format.
See also ImageDecoder::read_image
which reads byte buffers into
native endian.
§Panics
Panics if width * height * color_type.bytes_per_pixel() != buf.len()
.
Implementors§
impl<'a, W: Write> ImageEncoder for BmpEncoder<'a, W>
Available on crate feature
bmp
only.impl<W> ImageEncoder for OpenExrEncoder<W>
Available on crate feature
exr
only.impl<W: Write + Seek> ImageEncoder for TiffEncoder<W>
Available on crate feature
tiff
only.impl<W: Write> ImageEncoder for AvifEncoder<W>
Available on crate feature
avif
and (crate features avif
or avif-native
) only.impl<W: Write> ImageEncoder for FarbfeldEncoder<W>
Available on crate feature
ff
only.impl<W: Write> ImageEncoder for IcoEncoder<W>
Available on crate feature
ico
only.impl<W: Write> ImageEncoder for JpegEncoder<W>
Available on crate feature
jpeg
only.impl<W: Write> ImageEncoder for PngEncoder<W>
Available on crate feature
png
only.impl<W: Write> ImageEncoder for PnmEncoder<W>
Available on crate feature
pnm
only.impl<W: Write> ImageEncoder for QoiEncoder<W>
Available on crate feature
qoi
only.impl<W: Write> ImageEncoder for TgaEncoder<W>
Available on crate feature
tga
only.impl<W: Write> ImageEncoder for WebPEncoder<W>
Available on crate feature
webp
only.