Skip to content

[Request] Support rendering existing usvg::Tree #7799

@sww1235

Description

@sww1235

Support loading SVG images directly from usvg::Tree that is already in memory.

Is your feature request related to a problem? Please describe.
I cannot render SVG images in egui with an already existing usvg::Tree.

Describe the solution you'd like
Some additional method on the svg_loader in egui_extras named something like from_tree() that would accept a usvg::Tree. Not quite sure how this would work, as I am not familiar with the internals of the library. Would be nice to not have to specify a URI in this function as it already knows what datatype is incoming.

Describe alternatives you've considered
My current solution is to use egui::widgets::Image::from_bytes() and convert the tree to a bytes array using tree.to_string().into_bytes() which introduces several additional conversion steps.

Additional context
I am building a library that uses usvg::Tree internally to parse custom data out of SVGs. As I already have the SVG parsed into a tree, it would be ideal to pass that directly to rendering code without having to go through converting to string, then bytes, then reparsing the SVG.

This is partially related to #7797.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions