mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'alphyr/guess_image_format' into 'master'
Guess image format from file extension See merge request veloren/veloren!2260
This commit is contained in:
commit
607f8b289b
@ -97,18 +97,19 @@ impl Image {
|
|||||||
pub fn to_image(&self) -> Arc<DynamicImage> { Arc::clone(&self.0) }
|
pub fn to_image(&self) -> Arc<DynamicImage> { Arc::clone(&self.0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ImageLoader;
|
pub struct PngLoader;
|
||||||
impl Loader<Image> for ImageLoader {
|
impl Loader<Image> for PngLoader {
|
||||||
fn load(content: Cow<[u8]>, _: &str) -> Result<Image, BoxedError> {
|
fn load(content: Cow<[u8]>, _: &str) -> Result<Image, BoxedError> {
|
||||||
let image = image::load_from_memory(&content)?;
|
let format = image::ImageFormat::Png;
|
||||||
|
let image = image::load_from_memory_with_format(&content, format)?;
|
||||||
Ok(Image(Arc::new(image)))
|
Ok(Image(Arc::new(image)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Asset for Image {
|
impl Asset for Image {
|
||||||
type Loader = ImageLoader;
|
type Loader = PngLoader;
|
||||||
|
|
||||||
const EXTENSIONS: &'static [&'static str] = &["png", "jpg"];
|
const EXTENSION: &'static str = "png";
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DotVoxAsset(pub DotVoxData);
|
pub struct DotVoxAsset(pub DotVoxData);
|
||||||
|
Loading…
Reference in New Issue
Block a user