mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
Add bmp as a supported texture format (#1081)
This commit is contained in:
parent
09c15ea890
commit
acc29ec719
4 changed files with 16 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -56,3 +56,4 @@ hdr = ["image/hdr"]
|
|||
dds = ["image/dds"]
|
||||
tga = ["image/tga"]
|
||||
jpeg = ["image/jpeg"]
|
||||
bmp = ["image/bmp"]
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue