0

I tried building the svg example present in the iced libaray. The system in which it was build, it is working as exepected (i.e., the tiger SVG image is loading) but if I'm trying to run it in different machine(laptop), then the SVG image is not loading and only white screen is created.

Please help, how should I proceed in this case:

Working case: Machine 1( where this app was built) enter image description here

Failure case: Machine 2(where I was testing this app)

enter image description here

My OS is Windows and I'm using the lastest vesrion of iced library.

The code I'm using: https://github.com/iced-rs/iced/tree/master/examples/svg

I tried building the svg example present in the iced libaray. The system in which it was build, it is working as exepected (i.e., the tiger SVG image is loading) but if I'm trying to run it in different machine(laptop), then the SVG image is not loading and only white screen is created.

1 Answers1

1

Iced is trying to load your svg at runtime via let handle = svg::Handle::from_path. As this file doesn't exist on the new machine, it's unable to load it. You can instead build the file into the application using rust's include_bytes!(path) macro and replacing from_path with from_memory. The fixed code would look like this:

let handle = svg::Handle::from_memory(include_bytes!("../resources/tiger.svg").as_slice());

I've tested this code myself before and after moving the .exe to a different location on my computer and it seems to be working.