Added support for JPEG backgrounds
2
.gitattributes
vendored
@ -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
|
||||
|
Before Width: | Height: | Size: 1018 KiB |
Before Width: | Height: | Size: 2.7 MiB |
Before Width: | Height: | Size: 3.1 MiB |
Before Width: | Height: | Size: 493 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 939 KiB |
Before Width: | Height: | Size: 2.2 MiB |
Before Width: | Height: | Size: 877 KiB |
Before Width: | Height: | Size: 1.9 MiB |
Before Width: | Height: | Size: 2.0 MiB |
Before Width: | Height: | Size: 1.0 MiB |
Before Width: | Height: | Size: 644 KiB |
Before Width: | Height: | Size: 1.5 MiB |
Before Width: | Height: | Size: 914 KiB |
@ -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);
|
||||
|