Skip to main content

scale_to_width

Function scale_to_width 

Source
pub fn scale_to_width(
    w: u32,
    h: u32,
    rgba: &[u8],
    width: u32,
) -> Result<(u32, u32, Vec<u8>)>
Expand description

Scale an RGBA8 buffer to width pixels wide, keeping the aspect ratio.

Uses a Catmull-Rom filter, which keeps thin bright lines (most of what this engine draws) crisp. Returns the new size and pixels; a buffer that is already that width or narrower is returned unchanged.