Trait ImageEncoder
trait ImageEncoder
The trait all encoders implement
Required Methods
fn write_image(self: 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_imagewhich reads byte buffers into native endian.Panics
Panics if
width * height * color_type.bytes_per_pixel() != buf.len().
Provided Methods
fn set_icc_profile(self: &mut Self, icc_profile: Vec<u8>) -> Result<(), UnsupportedError>Set the ICC profile to use for the image.
This function is a no-op for formats that don't support ICC profiles. For formats that do support ICC profiles, the profile will be embedded in the image when it is saved.
Errors
This function returns an error if the format does not support ICC profiles.
Implementors
impl<W: Write> ImageEncoder for WebPEncoder<W>impl<W: Write> ImageEncoder for AvifEncoder<W>impl<W: Write> ImageEncoder for QoiEncoder<W>impl<W: Write> ImageEncoder for JpegEncoder<W>impl<W: Write> ImageEncoder for HdrEncoder<W>impl<W: Write + Seek> ImageEncoder for TiffEncoder<W>impl<W: Write> ImageEncoder for TgaEncoder<W>impl<W: Write> ImageEncoder for PngEncoder<W>impl<W: Write> ImageEncoder for FarbfeldEncoder<W>impl<W: Write> ImageEncoder for IcoEncoder<W>impl<W> ImageEncoder for OpenExrEncoder<W>impl<W: Write> ImageEncoder for PnmEncoder<W>impl<W: Write> ImageEncoder for BmpEncoder<'_, W>