From f4aa48a11bd053e930662a9d934658a33975ddc1 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Fri, 1 Nov 2024 19:41:14 +0000 Subject: [PATCH] bevy_image: PCX image support (off by default) --- Cargo.toml | 3 +++ crates/bevy_image/Cargo.toml | 3 ++- crates/bevy_image/src/image.rs | 15 +++++++++++++-- crates/bevy_image/src/image_loader.rs | 2 ++ crates/bevy_internal/Cargo.toml | 1 + crates/bevy_render/Cargo.toml | 2 +- docs/cargo_features.md | 1 + 7 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4bb5ace1b9..068df9f53e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -277,6 +277,9 @@ ico = ["bevy_internal/ico"] # JPEG image format support jpeg = ["bevy_internal/jpeg"] +# PCX image format support +pcx = ["bevy_internal/pcx"] + # PNG image format support png = ["bevy_internal/png"] diff --git a/crates/bevy_image/Cargo.toml b/crates/bevy_image/Cargo.toml index b848e478dd..1ec3e99d9b 100644 --- a/crates/bevy_image/Cargo.toml +++ b/crates/bevy_image/Cargo.toml @@ -20,6 +20,7 @@ hdr = ["image/hdr"] ktx2 = ["dep:ktx2"] ico = ["image/ico"] jpeg = ["image/jpeg"] +pcx = ["image/pcx"] png = ["image/png"] pnm = ["image/pnm"] qoi = ["image/qoi"] @@ -44,7 +45,7 @@ bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev", features = [ bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" } # rendering -image = { version = "0.25.2", default-features = false } +image = { version = "*", git = "https://github.com/image-rs/image.git", default-features = false } # misc bitflags = { version = "2.3", features = ["serde"] } diff --git a/crates/bevy_image/src/image.rs b/crates/bevy_image/src/image.rs index abf504536e..88f9f71c59 100644 --- a/crates/bevy_image/src/image.rs +++ b/crates/bevy_image/src/image.rs @@ -49,6 +49,8 @@ pub enum ImageFormat { Jpeg, #[cfg(feature = "ktx2")] Ktx2, + #[cfg(feature = "pcx")] + Pcx, #[cfg(feature = "png")] Png, #[cfg(feature = "pnm")] @@ -99,10 +101,12 @@ impl ImageFormat { ImageFormat::Jpeg => &["jpg", "jpeg"], #[cfg(feature = "ktx2")] ImageFormat::Ktx2 => &["ktx2"], - #[cfg(feature = "pnm")] - ImageFormat::Pnm => &["pam", "pbm", "pgm", "ppm"], + #[cfg(feature = "pcx")] + ImageFormat::Pcx => &["pcx"], #[cfg(feature = "png")] ImageFormat::Png => &["png"], + #[cfg(feature = "pnm")] + ImageFormat::Pnm => &["pam", "pbm", "pgm", "ppm"], #[cfg(feature = "qoi")] ImageFormat::Qoi => &["qoi"], #[cfg(feature = "tga")] @@ -140,6 +144,8 @@ impl ImageFormat { ImageFormat::Jpeg => &["image/jpeg"], #[cfg(feature = "ktx2")] ImageFormat::Ktx2 => &["image/ktx2"], + #[cfg(feature = "pcx")] + ImageFormat::Pcx => &["image/vnd.zbrush.pcx", "image/x-pcx"], #[cfg(feature = "png")] ImageFormat::Png => &["image/png"], #[cfg(feature = "qoi")] @@ -177,6 +183,7 @@ impl ImageFormat { "image/x-icon" => feature_gate!("ico", Ico), "image/jpeg" => feature_gate!("jpeg", Jpeg), "image/ktx2" => feature_gate!("ktx2", Ktx2), + "image/vnd.zbrush.pcx" | "image/x-pcx" => feature_gate!("pcx", Pcx), "image/png" => feature_gate!("png", Png), "image/qoi" | "image/x-qoi" => feature_gate!("qoi", Qoi), "image/x-exr" => feature_gate!("exr", OpenExr), @@ -205,6 +212,7 @@ impl ImageFormat { "jpg" | "jpeg" => feature_gate!("jpeg", Jpeg), "ktx2" => feature_gate!("ktx2", Ktx2), "pam" | "pbm" | "pgm" | "ppm" => feature_gate!("pnm", Pnm), + "pcx" => feature_gate!("pcx", Pcx), "png" => feature_gate!("png", Png), "qoi" => feature_gate!("qoi", Qoi), "tga" => feature_gate!("tga", Tga), @@ -233,6 +241,8 @@ impl ImageFormat { ImageFormat::Ico => image::ImageFormat::Ico, #[cfg(feature = "jpeg")] ImageFormat::Jpeg => image::ImageFormat::Jpeg, + #[cfg(feature = "pcx")] + ImageFormat::Pcx => image::ImageFormat::Pcx, #[cfg(feature = "png")] ImageFormat::Png => image::ImageFormat::Png, #[cfg(feature = "pnm")] @@ -266,6 +276,7 @@ impl ImageFormat { image::ImageFormat::Hdr => feature_gate!("hdr", Hdr), image::ImageFormat::Ico => feature_gate!("ico", Ico), image::ImageFormat::Jpeg => feature_gate!("jpeg", Jpeg), + image::ImageFormat::Pcx => feature_gate!("pcx", Pcx), image::ImageFormat::Png => feature_gate!("png", Png), image::ImageFormat::Pnm => feature_gate!("pnm", Pnm), image::ImageFormat::Qoi => feature_gate!("qoi", Qoi), diff --git a/crates/bevy_image/src/image_loader.rs b/crates/bevy_image/src/image_loader.rs index b3ce3e35f6..8cee4ba6eb 100644 --- a/crates/bevy_image/src/image_loader.rs +++ b/crates/bevy_image/src/image_loader.rs @@ -30,6 +30,8 @@ impl ImageLoader { ImageFormat::Jpeg, #[cfg(feature = "ktx2")] ImageFormat::Ktx2, + #[cfg(feature = "pcx")] + ImageFormat::Pcx, #[cfg(feature = "png")] ImageFormat::Png, #[cfg(feature = "pnm")] diff --git a/crates/bevy_internal/Cargo.toml b/crates/bevy_internal/Cargo.toml index 74267a4797..c7ba456a9a 100644 --- a/crates/bevy_internal/Cargo.toml +++ b/crates/bevy_internal/Cargo.toml @@ -50,6 +50,7 @@ ff = ["bevy_image/ff"] gif = ["bevy_image/gif"] ico = ["bevy_image/ico"] jpeg = ["bevy_image/jpeg"] +pcx = ["bevy_image/pcx"] png = ["bevy_image/png"] pnm = ["bevy_image/pnm"] qoi = ["bevy_image/qoi"] diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index 0d49bf46a4..8a59b86765 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -59,7 +59,7 @@ bevy_image = { path = "../bevy_image", version = "0.15.0-dev" } bevy_mesh = { path = "../bevy_mesh", version = "0.15.0-dev" } # rendering -image = { version = "0.25.2", default-features = false } +image = { version = "*", git = "https://github.com/image-rs/image.git", default-features = false } # misc codespan-reporting = "0.11.0" diff --git a/docs/cargo_features.md b/docs/cargo_features.md index bb9d8d47ae..84f0574b83 100644 --- a/docs/cargo_features.md +++ b/docs/cargo_features.md @@ -85,6 +85,7 @@ The default feature set enables most of the expected features of a game engine, |pbr_multi_layer_material_textures|Enable support for multi-layer material textures in the `StandardMaterial`, at the risk of blowing past the global, per-shader texture limit on older/lower-end GPUs| |pbr_pcss|Enable support for PCSS, at the risk of blowing past the global, per-shader sampler limit on older/lower-end GPUs| |pbr_transmission_textures|Enable support for transmission-related textures in the `StandardMaterial`, at the risk of blowing past the global, per-shader texture limit on older/lower-end GPUs| +|pcx|PCX image format support| |pnm|PNM image format support, includes pam, pbm, pgm and ppm| |qoi|QOI image format support| |reflect_functions|Enable function reflection|