Skip to content

Commit acc29ec

Browse files
authored
Add bmp as a supported texture format (#1081)
1 parent 09c15ea commit acc29ec

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ png = ["bevy_internal/png"]
5858
dds = ["bevy_internal/dds"]
5959
tga = ["bevy_internal/tga"]
6060
jpeg = ["bevy_internal/jpeg"]
61+
bmp = ["bevy_internal/bmp"]
6162

6263
# Audio format support (MP3 is enabled by default)
6364
flac = ["bevy_internal/flac"]
@@ -382,4 +383,3 @@ icon = "@mipmap/ic_launcher"
382383
build_targets = ["aarch64-linux-android", "armv7-linux-androideabi"]
383384
min_sdk_version = 16
384385
target_sdk_version = 29
385-

crates/bevy_internal/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ png = ["bevy_render/png"]
2424
dds = ["bevy_render/dds"]
2525
tga = ["bevy_render/tga"]
2626
jpeg = ["bevy_render/jpeg"]
27+
bmp = ["bevy_render/bmp"]
2728

2829
# Audio format support (MP3 is enabled by default)
2930
flac = ["bevy_audio/flac"]

crates/bevy_render/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ hdr = ["image/hdr"]
5656
dds = ["image/dds"]
5757
tga = ["image/tga"]
5858
jpeg = ["image/jpeg"]
59+
bmp = ["image/bmp"]

crates/bevy_render/src/texture/image_texture_loader.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ use bevy_asset::{AssetLoader, LoadContext, LoadedAsset};
44
use bevy_utils::BoxedFuture;
55

66
/// Loader for images that can be read by the `image` crate.
7-
///
8-
/// Reads only PNG images for now.
97
#[derive(Clone, Default)]
108
pub struct ImageTextureLoader;
119

12-
const FILE_EXTENSIONS: &[&str] = &["png", "dds", "tga", "jpg", "jpeg"];
10+
const FILE_EXTENSIONS: &[&str] = &["png", "dds", "tga", "jpg", "jpeg", "bmp"];
1311

1412
impl AssetLoader for ImageTextureLoader {
1513
fn load<'a>(
@@ -163,3 +161,15 @@ impl AssetLoader for ImageTextureLoader {
163161
FILE_EXTENSIONS
164162
}
165163
}
164+
165+
#[cfg(test)]
166+
mod tests {
167+
use super::*;
168+
169+
#[test]
170+
fn test_supported_file_extensions() {
171+
for ext in FILE_EXTENSIONS {
172+
assert!(image::ImageFormat::from_extension(ext).is_some())
173+
}
174+
}
175+
}

0 commit comments

Comments
 (0)