egui is an easy-to-use immediate mode GUI in pure Rust. eframe is the official egui framework, allowing you to run egui on both web and native.
This release contains a simple and powerful image API:
// Load from web:
ui.image("https://www.example.com/some_image.png");
// Include image in the binary using `include_bytes`:
ui.image(egui::include_image!("../assets/ferris.svg"));
// With options:
ui.add(
egui::Image::new("file://path/to/image.jpg")
.max_width(200.0)
.rounding(10.0),
);
The API is based on a plugin-system, where you can tell egui
how to load the images, and from where.
egui_extras
comes with loaders for you, so all you need to do is add the following to your Cargo.toml
:
egui_extras = { version = "0.23", features = ["all_loaders"] }
image = { version = "0.24", features = ["jpeg", "png"] } # Add the types you want support for
And this to your code:
egui_extras::install_image_loaders(egui_ctx);
Try the live demo at https://www.egui.rs/