Skip to main content

encode_rgba

Function encode_rgba 

Source
pub fn encode_rgba(
    rgba: &[u8],
    width: u32,
    height: u32,
    opts: &Options,
) -> Result<Vec<u8>, Error>
Expand description

Encodes an RGBA buffer into the bytes of a WebP file.

rgba holds width * height pixels in row order, four bytes each, in the order red, green, blue, alpha.

ยงErrors

Error::DimensionsOutOfRange when a side falls outside 1 through MAX_DIMENSION, carrying the values passed. Error::BufferSizeMismatch when rgba runs to a length other than width * height * 4. The dimension check runs first, so a call that gets both wrong reports the dimensions.