[][src]Function ravif::encode_rgba

pub fn encode_rgba(
    buffer: Img<&[RGBA8]>,
    config: &EncConfig
) -> Result<(Vec<u8>, usize, usize), Box<dyn Error + Send + Sync>>

Make a new AVIF image from RGBA pixels

Make the Img for the buffer like this:

Img::new(&pixels_rgba[..], width, height)

If you have pixels as u8 slice, then:

use rgb::ComponentSlice;
let pixels_rgba = pixels.as_rgba();

If all pixels are opaque, alpha channel will be left out automatically.

It's highly recommended to apply cleared_alpha first.