From 0265da1074405a3d26a6838ed795d54d0d1ff696 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Fri, 18 Jun 2021 12:27:39 +0100 Subject: [PATCH] Added support for JPEG backgrounds --- .gitattributes | 2 ++ assets/voxygen/background/bg_1.png | 3 --- assets/voxygen/background/bg_10.png | 3 --- assets/voxygen/background/bg_11.png | 3 --- assets/voxygen/background/bg_12.png | 3 --- assets/voxygen/background/bg_13.png | 3 --- assets/voxygen/background/bg_2.png | 3 --- assets/voxygen/background/bg_3.png | 3 --- assets/voxygen/background/bg_4.png | 3 --- assets/voxygen/background/bg_5.png | 3 --- assets/voxygen/background/bg_6.png | 3 --- assets/voxygen/background/bg_7.png | 3 --- assets/voxygen/background/bg_8.png | 3 --- assets/voxygen/background/bg_9.png | 3 --- assets/voxygen/background/bg_main.png | 3 --- common/assets/src/lib.rs | 13 +++++++------ 16 files changed, 9 insertions(+), 48 deletions(-) delete mode 100644 assets/voxygen/background/bg_1.png delete mode 100644 assets/voxygen/background/bg_10.png delete mode 100644 assets/voxygen/background/bg_11.png delete mode 100644 assets/voxygen/background/bg_12.png delete mode 100644 assets/voxygen/background/bg_13.png delete mode 100644 assets/voxygen/background/bg_2.png delete mode 100644 assets/voxygen/background/bg_3.png delete mode 100644 assets/voxygen/background/bg_4.png delete mode 100644 assets/voxygen/background/bg_5.png delete mode 100644 assets/voxygen/background/bg_6.png delete mode 100644 assets/voxygen/background/bg_7.png delete mode 100644 assets/voxygen/background/bg_8.png delete mode 100644 assets/voxygen/background/bg_9.png delete mode 100755 assets/voxygen/background/bg_main.png diff --git a/.gitattributes b/.gitattributes index dccc09d154..3e4661f797 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,6 @@ *.png filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text *.vox filter=lfs diff=lfs merge=lfs -text *.ttf filter=lfs diff=lfs merge=lfs -text *.wav filter=lfs diff=lfs merge=lfs -text diff --git a/assets/voxygen/background/bg_1.png b/assets/voxygen/background/bg_1.png deleted file mode 100644 index 48772268ba..0000000000 --- a/assets/voxygen/background/bg_1.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c2f501dcf2404832c9f713fc704c62bfa76b20b07b234755adb9198ff3d6893f -size 1042062 diff --git a/assets/voxygen/background/bg_10.png b/assets/voxygen/background/bg_10.png deleted file mode 100644 index 466e35655c..0000000000 --- a/assets/voxygen/background/bg_10.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:62a1fb6b416664dc346015492f4ed010eed55a4d59da25ea14837165ea5a8020 -size 2878018 diff --git a/assets/voxygen/background/bg_11.png b/assets/voxygen/background/bg_11.png deleted file mode 100644 index e4bee3831b..0000000000 --- a/assets/voxygen/background/bg_11.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9343b6be6caf0099edeac7260bf65103b7d1ec33211629988068b2f1412945d6 -size 3256584 diff --git a/assets/voxygen/background/bg_12.png b/assets/voxygen/background/bg_12.png deleted file mode 100644 index ef49a9452b..0000000000 --- a/assets/voxygen/background/bg_12.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ae98e12dbdb515556281313ac8d5e93be059aaafbd3f0578c3af58750841d682 -size 505241 diff --git a/assets/voxygen/background/bg_13.png b/assets/voxygen/background/bg_13.png deleted file mode 100644 index 7b7eccaf52..0000000000 --- a/assets/voxygen/background/bg_13.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:52edcbfe10dec67d5351d7940059591884f19bbc6acda7ffd3092aa7ed90ccf3 -size 1282505 diff --git a/assets/voxygen/background/bg_2.png b/assets/voxygen/background/bg_2.png deleted file mode 100644 index a33086f1e9..0000000000 --- a/assets/voxygen/background/bg_2.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f6149efbefa2c9acb45a5b20c36aa085e6e413ecd17c66929c2c3e20c62a3171 -size 961708 diff --git a/assets/voxygen/background/bg_3.png b/assets/voxygen/background/bg_3.png deleted file mode 100644 index 89a5200c38..0000000000 --- a/assets/voxygen/background/bg_3.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:27ab466038b11f3026452e0c3eb4480300a328e31a708c323dc3b0cae89c04e1 -size 2272839 diff --git a/assets/voxygen/background/bg_4.png b/assets/voxygen/background/bg_4.png deleted file mode 100644 index beed1bcbf8..0000000000 --- a/assets/voxygen/background/bg_4.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9ff1f9d09e04ca1343cb481403428d8a604e4090f2e1760caecb1a8aee149caa -size 897858 diff --git a/assets/voxygen/background/bg_5.png b/assets/voxygen/background/bg_5.png deleted file mode 100644 index 3c320bdacb..0000000000 --- a/assets/voxygen/background/bg_5.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0ccdede73a20ae6355782d9c10b18f868a515a27f8da79013109930b8c39bd8c -size 2044001 diff --git a/assets/voxygen/background/bg_6.png b/assets/voxygen/background/bg_6.png deleted file mode 100644 index 1bac40b2c7..0000000000 --- a/assets/voxygen/background/bg_6.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7ae41c4fac3190e13d1bfdafe6905ede9eeb2f8bdc6b5708d28b82a499aaa5ab -size 2079829 diff --git a/assets/voxygen/background/bg_7.png b/assets/voxygen/background/bg_7.png deleted file mode 100644 index 23de419292..0000000000 --- a/assets/voxygen/background/bg_7.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5f69f880541dbb2962060419c893b0ab061c8e429d2a836b5bdcf9733c10c7d8 -size 1100362 diff --git a/assets/voxygen/background/bg_8.png b/assets/voxygen/background/bg_8.png deleted file mode 100644 index b7db0e1bbb..0000000000 --- a/assets/voxygen/background/bg_8.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b8945a91805b8c0a6fbb9f7eee972c70a47ca1ac24d25ae9b91a3aa8fff5a336 -size 659820 diff --git a/assets/voxygen/background/bg_9.png b/assets/voxygen/background/bg_9.png deleted file mode 100644 index 3067fcb80c..0000000000 --- a/assets/voxygen/background/bg_9.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e101b354202f8d2fc872808041930b7b683d358b35cfe95203486e175f8cf6eb -size 1585712 diff --git a/assets/voxygen/background/bg_main.png b/assets/voxygen/background/bg_main.png deleted file mode 100755 index 7696d64216..0000000000 --- a/assets/voxygen/background/bg_main.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:31135eadd773c6846a749e661197c1e95f99808f75e34b74c357476d706a5a7e -size 936308 diff --git a/common/assets/src/lib.rs b/common/assets/src/lib.rs index b3031053d6..ee3156c5b9 100644 --- a/common/assets/src/lib.rs +++ b/common/assets/src/lib.rs @@ -97,19 +97,20 @@ impl Image { pub fn to_image(&self) -> Arc { Arc::clone(&self.0) } } -pub struct PngLoader; -impl Loader for PngLoader { - fn load(content: Cow<[u8]>, _: &str) -> Result { - let format = image::ImageFormat::Png; +pub struct ImageLoader; +impl Loader for ImageLoader { + fn load(content: Cow<[u8]>, ext: &str) -> Result { + let format = image::ImageFormat::from_extension(ext) + .ok_or_else(|| format!("Invalid file extension {}", ext))?; let image = image::load_from_memory_with_format(&content, format)?; Ok(Image(Arc::new(image))) } } impl Asset for Image { - type Loader = PngLoader; + type Loader = ImageLoader; - const EXTENSION: &'static str = "png"; + const EXTENSIONS: &'static [&'static str] = &["png", "jpg", "jpeg"]; } pub struct DotVoxAsset(pub DotVoxData);