diff --git a/Cargo.toml b/Cargo.toml index 3280002be3532..21889920f8a2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,6 +58,7 @@ png = ["bevy_internal/png"] dds = ["bevy_internal/dds"] tga = ["bevy_internal/tga"] jpeg = ["bevy_internal/jpeg"] +bmp = ["bevy_internal/bmp"] # Audio format support (MP3 is enabled by default) flac = ["bevy_internal/flac"] @@ -378,4 +379,3 @@ icon = "@mipmap/ic_launcher" build_targets = ["aarch64-linux-android", "armv7-linux-androideabi"] min_sdk_version = 16 target_sdk_version = 29 - diff --git a/crates/bevy_internal/Cargo.toml b/crates/bevy_internal/Cargo.toml index 49cd22cb7715d..8387c7ba5ce3a 100644 --- a/crates/bevy_internal/Cargo.toml +++ b/crates/bevy_internal/Cargo.toml @@ -24,6 +24,7 @@ png = ["bevy_render/png"] dds = ["bevy_render/dds"] tga = ["bevy_render/tga"] jpeg = ["bevy_render/jpeg"] +bmp = ["bevy_render/bmp"] # Audio format support (MP3 is enabled by default) flac = ["bevy_audio/flac"] diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index 8732535ac271a..985759ebad0e6 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -56,3 +56,4 @@ hdr = ["image/hdr"] dds = ["image/dds"] tga = ["image/tga"] jpeg = ["image/jpeg"] +bmp = ["image/bmp"] diff --git a/crates/bevy_render/src/texture/image_texture_loader.rs b/crates/bevy_render/src/texture/image_texture_loader.rs index f866a0751843b..79fdceb9b0c84 100644 --- a/crates/bevy_render/src/texture/image_texture_loader.rs +++ b/crates/bevy_render/src/texture/image_texture_loader.rs @@ -4,12 +4,10 @@ use bevy_asset::{AssetLoader, LoadContext, LoadedAsset}; use bevy_utils::BoxedFuture; /// Loader for images that can be read by the `image` crate. -/// -/// Reads only PNG images for now. #[derive(Clone, Default)] pub struct ImageTextureLoader; -const FILE_EXTENSIONS: &[&str] = &["png", "dds", "tga", "jpg", "jpeg"]; +const FILE_EXTENSIONS: &[&str] = &["png", "dds", "tga", "jpg", "jpeg", "bmp"]; impl AssetLoader for ImageTextureLoader { fn load<'a>( @@ -163,3 +161,15 @@ impl AssetLoader for ImageTextureLoader { FILE_EXTENSIONS } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_supported_file_extensions() { + for ext in FILE_EXTENSIONS { + assert!(image::ImageFormat::from_extension(ext).is_some()) + } + } +}