Skip to main content

resize_rgba

Function resize_rgba 

Source
pub fn resize_rgba(
    pixels: &[u8],
    (width, height): (u32, u32),
    (new_width, new_height): (u32, u32),
) -> Result<Vec<u8>, String>
Expand description

Straight-alpha RGBA pixels, width x height, resized to new_width x new_height: each axis resampled by a tent filter as wide as a source pixel or an output pixel, whichever is wider, so an axis that shrinks averages what each output pixel covers (as a proxy averages its blocks) and one that grows interpolates. Colour is weighted by alpha, so a transparent pixel’s colour does not bleed into its neighbours. An axis that keeps its size is left exactly as it is.

§Errors

Returns a message for an empty size or a buffer that is not width x height pixels.