egui image loader fails to recognize png with blade-egui
apekros opened this issue · 5 comments
Using blade and attempting to draw an image similar to in eframe results with:
egui_extras::install_image_loaders(ctx); ui.add(Image::new(include_image!("assets/logo.png"));
Using image/egui_extras results in the image loader not registering (works with eframe)
Thanks for filing! Sorry it went under the radar for me. It's definitely something I want to fix.
Do you have a reproducible test case that I can run?
Appears to work fine for me. Test code in main...test-egui-image
Full test diff for the reference
diff --git a/Cargo.toml b/Cargo.toml
index d76c039..30f01f6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -89,6 +89,9 @@ strum = { workspace = true }
del-msh = "=0.1.25"
del-geo = "=0.1.19"
+egui_extras = { version = "0.28", features = ["all_loaders"] }
+image = { version = "0.25", features = ["jpeg", "png"] }
+
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
# see https://github.com/emilk/egui/issues/4270
egui-winit = "0.28"
diff --git a/examples/particle/main.rs b/examples/particle/main.rs
index b808d7d..02ccacb 100644
--- a/examples/particle/main.rs
+++ b/examples/particle/main.rs
@@ -122,6 +122,7 @@ fn main() {
.unwrap();
let egui_ctx = egui::Context::default();
+ egui_extras::install_image_loaders(&egui_ctx);
let viewport_id = egui_ctx.viewport_id();
let mut egui_winit = egui_winit::State::new(egui_ctx, viewport_id, &window, None, None);
@@ -166,6 +167,7 @@ fn main() {
let egui_output = egui_winit.egui_ctx().run(raw_input, |egui_ctx| {
egui::SidePanel::left("my_side_panel").show(egui_ctx, |ui| {
ui.heading("Particle System");
+ ui.add(egui::Image::new(egui::include_image!("../../docs/logo.png")));
example.particle_system.add_gui(ui);
if ui.button("Quit").clicked() {
target.exit();
Sorry I should have posted a reproducible reference. The issue was on my side with using a mismatching version of image / egui.
i.e I had bumped blade to 0.27 (before your changes) and was using an incompatible version of image crate, simple mistake.
Thanks!