#Egui dynamic image loading

3 messages · Page 1 of 1 (latest)

pseudo hill
#

Hello,
I'm trying to make an image viewer using egui, so I started with the example provided in the github: https://github.com/emilk/egui/blob/master/examples/images/src/main.rs. This went well, so I moved on to trying the next logical step, loading an arbitrary image from a file path. Problem is, when I try to run it, I get an error in the egui::include_image!() macro, saying that "no rules expected this token in macro call" and that the parameters for the macro specify that it takes a literal (($path: literal) => {)

so in a nutshell, I was wondering if there's a better way to do it, or if I'm missing a really simple fix?
Thanks

If it would help, this is my update function, everything else is the same as the example:

fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
  egui::CentralPanel::default().show(ctx, |ui| {
    egui::ScrollArea::new([true, true]).show(ui, |ui| {
      //this is the problem passage
      let a = "path to jpg";
      ui.image(egui::include_image!(&a));
    });
  });
}```
vague salmon
#

Unless a is not going to change, in which case just move the path string to inside the macro instead of referencing it.