resvg

https://github.com/RazrFalcon/resvg

Finally, an SVG rendering library that's actually usable on Windows. It builds in seconds and the code to render looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
auto input_data = /*...*/;
auto options = resvg_options_create();
resvg_render_tree *tree;
auto result = resvg_parse_tree_from_data(input_data.data(), input_data.size(), options, &tree);
//handle errors, destroy options
auto [width, height] = resvg_get_image_size(tree);
std::vector<char> output(width * height * 4);
resvg_render(
    tree,
    {
        RESVG_FIT_TO_TYPE_ORIGINAL,
        1,
    },
    resvg_transform_identity(),
    width,
    height,
    output.data()
);
//output contains raster in RGBA order 
Last edited on
Topic archived. No new replies allowed.