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§

source

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§

source§

impl<'a, W: Write> ImageEncoder for BmpEncoder<'a, W>

Available on crate feature bmp only.
source§

impl<W> ImageEncoder for OpenExrEncoder<W>
where W: Write + Seek,

Available on crate feature exr only.
source§

impl<W: Write + Seek> ImageEncoder for TiffEncoder<W>

Available on crate feature tiff only.
source§

impl<W: Write> ImageEncoder for AvifEncoder<W>

Available on crate feature avif and (crate features avif or avif-native) only.
source§

impl<W: Write> ImageEncoder for FarbfeldEncoder<W>

Available on crate feature ff only.
source§

impl<W: Write> ImageEncoder for IcoEncoder<W>

Available on crate feature ico only.
source§

impl<W: Write> ImageEncoder for JpegEncoder<W>

Available on crate feature jpeg only.
source§

impl<W: Write> ImageEncoder for PngEncoder<W>

Available on crate feature png only.
source§

impl<W: Write> ImageEncoder for PnmEncoder<W>

Available on crate feature pnm only.
source§

impl<W: Write> ImageEncoder for QoiEncoder<W>

Available on crate feature qoi only.
source§

impl<W: Write> ImageEncoder for TgaEncoder<W>

Available on crate feature tga only.
source§

impl<W: Write> ImageEncoder for WebPEncoder<W>

Available on crate feature webp only.