Skip to content

Commit

Permalink
Fix extensionless image loading panic (bevyengine#13005)
Browse files Browse the repository at this point in the history
Remake of bevyengine#12938 targeting main
  • Loading branch information
VictorBulba authored Apr 17, 2024
1 parent cab1c57 commit 11afe16
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crates/bevy_render/src/texture/image_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ impl AssetLoader for ImageLoader {
settings: &'a ImageLoaderSettings,
load_context: &'a mut LoadContext<'_>,
) -> Result<Image, Self::Error> {
// use the file extension for the image type
let ext = load_context.path().extension().unwrap().to_str().unwrap();

let mut bytes = Vec::new();
reader.read_to_end(&mut bytes).await?;
let image_type = match settings.format {
ImageFormatSetting::FromExtension => ImageType::Extension(ext),
ImageFormatSetting::FromExtension => {
// use the file extension for the image type
let ext = load_context.path().extension().unwrap().to_str().unwrap();
ImageType::Extension(ext)
}
ImageFormatSetting::Format(format) => ImageType::Format(format),
};
Ok(Image::from_buffer(
Expand Down

0 comments on commit 11afe16

Please sign in to comment.