ltk::theme::assets

Function decode_svg_bytes

Source
pub fn decode_svg_bytes(
    svg_bytes: &[u8],
    size: u32,
) -> Option<(Arc<Vec<u8>>, u32, u32)>
Expand description

Decode a UTF-8 SVG document into a premultiplied RGBA8 pixmap of the requested longest-edge size in physical pixels. The shorter edge is scaled proportionally so the icon’s aspect ratio is preserved; the returned (width, height) reflect the final pixmap.

Returns None for malformed SVG input or when the size is too small (≤ 0 px on the longest edge).

The implementation uses [resvg] (which bundles usvg and tiny-skia) so the rasteriser is the same as the rest of ltk’s software-canvas path. Use icon_rgba when you want path-resolution + caching against the active theme tree.