Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic when loading large image #350

Open
useyourfeelings opened this issue Jan 21, 2025 · 0 comments
Open

panic when loading large image #350

useyourfeelings opened this issue Jan 21, 2025 · 0 comments

Comments

@useyourfeelings
Copy link

I am not sure if it is bevy_egui related.
I think it's something wrong with the loading process or config.


good with raw egui.

use eframe::egui;

struct MyApp {
}

impl MyApp {
    pub fn new(_cc: &eframe::CreationContext) -> Self {
        Self {
        }
    }
}

impl eframe::App for MyApp {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            let image = egui::Image::new(format!(
                "file://{}",
                "E:/dev/game/bevy/1/final_effort/assets/anim/player/player_run_1_down.png"
            ));
            ui.add(image);
        });
    }
}

fn main() -> eframe::Result<()> {
    eframe::run_native(
        "wtf",
        eframe::NativeOptions::default(),
        Box::new(|ctx| {
            egui_extras::install_image_loaders(&ctx.egui_ctx);
            Ok(Box::new(MyApp::new(ctx)))
        }),
    )
}

bad code that panic at egui-0.30.0\src\context.rs:2099:9
"Texture xxx has size 4352x256, but the maximum texture side is 2048"

use bevy::prelude::*;
use bevy_egui::{EguiContexts, EguiPlugin};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(EguiPlugin)
        .add_systems(Startup, init_gui)
        .add_systems(Update, ui_example_system)
        .run();
}

fn init_gui(mut contexts: EguiContexts) {
    let ctx = contexts.ctx_mut();
    egui_extras::install_image_loaders(ctx);
}

fn ui_example_system(mut contexts: EguiContexts) {
    egui::Window::new("Hello").show(contexts.ctx_mut(), |ui| {
        ui.label("world");

        let image = egui::Image::new(format!(
            "file://{}",
            "E:/dev/game/bevy/1/final_effort/assets/anim/player/player_run_1_down.png"
        ));
        //ui.add_sized([300.0, 200.0], image);
        ui.add(image);
    });
}

save dependencies

bevy = "0.15.1"
egui = "0.30.0"
egui_extras = { version = "0.30.0", features = ["all_loaders"] }
eframe = "0.30.0"
image = { version = "0.25.5", features = ["bmp", "jpeg", "png"] }
bevy_egui = "0.32"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant