Skip to content

Commit 58e2b16

Browse files
author
Nathan Jeffords
committed
update handling of image file type based on feedback from review
1 parent 4a77705 commit 58e2b16

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

crates/bevy_render/src/texture/image_texture_loader.rs

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,7 @@ use bevy_utils::BoxedFuture;
99
#[derive(Clone, Default)]
1010
pub struct ImageTextureLoader;
1111

12-
macro_rules! define_file_extensions {
13-
( $( $s:literal => $v:ident ),+ $(,)? ) => {
14-
15-
const FILE_EXTENSIONS: &'static [&'static str] = &[
16-
$( $s ),+
17-
];
18-
19-
fn match_file_extension (ext: &str) -> Option<image::ImageFormat>
20-
{
21-
if false { None } $(
22-
23-
else if ext.eq_ignore_ascii_case ($s) {
24-
Some(image::ImageFormat::$v)
25-
}
26-
27-
)+ else { None }
28-
}
29-
30-
};
31-
}
32-
33-
define_file_extensions! {
34-
"png" => Png, "dds" => Dds,
35-
"tga" => Tga, "jpg" => Jpeg,
36-
"jpeg" => Jpeg,
37-
}
12+
const FILE_EXTENSIONS: &[&str] = &["png", "dds", "tga", "jpg", "jpeg"];
3813

3914
impl AssetLoader for ImageTextureLoader {
4015
fn load<'a>(
@@ -50,7 +25,7 @@ impl AssetLoader for ImageTextureLoader {
5025

5126
let ext = load_context.path().extension().unwrap().to_str().unwrap();
5227

53-
let img_format = match_file_extension(ext)
28+
let img_format = image::ImageFormat::from_extension(ext)
5429
.ok_or_else(|| {
5530
format!(
5631
"Unexpected image format {:?} for file {}, this is an error in `bevy_render`.",

0 commit comments

Comments
 (0)