mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 12:43:34 +00:00
Fix extensionless image loading panic (#13005)
Remake of #12938 targeting main
This commit is contained in:
parent
cab1c5702a
commit
11afe16079
1 changed files with 5 additions and 4 deletions
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue