Trait cosmic::iced_winit::graphics::image::image_rs::ImageEncoder

source ·
pub trait ImageEncoder {
    // Required method
    fn write_image(
        self,
        buf: &[u8],
        width: u32,
        height: u32,
        color_type: ColorType,
    ) -> Result<(), ImageError>;
}
Expand description

The trait all encoders implement

Required Methods§

source

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

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> ImageEncoder for BmpEncoder<'a, W>
where W: Write,

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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