Added support for JPEG backgrounds

This commit is contained in:
Joshua Barretto 2021-06-18 12:27:39 +01:00
parent 1af6f685d1
commit 0265da1074
16 changed files with 9 additions and 48 deletions

2
.gitattributes vendored
View File

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

BIN
assets/voxygen/background/bg_1.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/background/bg_10.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/background/bg_11.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/background/bg_12.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/background/bg_13.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/background/bg_2.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/background/bg_3.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/background/bg_4.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/background/bg_5.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/background/bg_6.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/background/bg_7.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/background/bg_8.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/background/bg_9.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/background/bg_main.png (Stored with Git LFS)

Binary file not shown.

View File

@ -97,19 +97,20 @@ impl Image {
pub fn to_image(&self) -> Arc<DynamicImage> { Arc::clone(&self.0) }
}
pub struct PngLoader;
impl Loader<Image> for PngLoader {
fn load(content: Cow<[u8]>, _: &str) -> Result<Image, BoxedError> {
let format = image::ImageFormat::Png;
pub struct ImageLoader;
impl Loader<Image> for ImageLoader {
fn load(content: Cow<[u8]>, ext: &str) -> Result<Image, BoxedError> {
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);