Add bmp as a supported texture format (#1081)

This commit is contained in:
Ryan Lee 2020-12-23 17:53:02 -05:00 committed by GitHub
parent 09c15ea890
commit acc29ec719
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 4 deletions

View file

@ -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"]
@ -382,4 +383,3 @@ icon = "@mipmap/ic_launcher"
build_targets = ["aarch64-linux-android", "armv7-linux-androideabi"]
min_sdk_version = 16
target_sdk_version = 29

View file

@ -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"]

View file

@ -56,3 +56,4 @@ hdr = ["image/hdr"]
dds = ["image/dds"]
tga = ["image/tga"]
jpeg = ["image/jpeg"]
bmp = ["image/bmp"]

View file

@ -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())
}
}
}