allow png files to be loaded via IndexedBitmap::load_file
This commit is contained in:
parent
6829800caa
commit
b6e69ca084
|
@ -26,6 +26,10 @@ impl IndexedBitmap {
|
||||||
if let Some(extension) = path.extension() {
|
if let Some(extension) = path.extension() {
|
||||||
let extension = extension.to_ascii_lowercase();
|
let extension = extension.to_ascii_lowercase();
|
||||||
match extension.to_str() {
|
match extension.to_str() {
|
||||||
|
Some("png") => {
|
||||||
|
let (bmp, palette) = Self::load_png_file(path)?;
|
||||||
|
Ok((bmp, palette.expect("Indexed color PNG loaded and should have returned a Palette")))
|
||||||
|
},
|
||||||
Some("pcx") => Ok(Self::load_pcx_file(path)?),
|
Some("pcx") => Ok(Self::load_pcx_file(path)?),
|
||||||
Some("gif") => Ok(Self::load_gif_file(path)?),
|
Some("gif") => Ok(Self::load_gif_file(path)?),
|
||||||
Some("iff") | Some("lbm") | Some("pbm") | Some("bbm") => {
|
Some("iff") | Some("lbm") | Some("pbm") | Some("bbm") => {
|
||||||
|
|
|
@ -32,6 +32,9 @@ pub enum BitmapError {
|
||||||
|
|
||||||
#[error("Bitmap GIF file error")]
|
#[error("Bitmap GIF file error")]
|
||||||
GifError(#[from] gif::GifError),
|
GifError(#[from] gif::GifError),
|
||||||
|
|
||||||
|
#[error("Bitmap PNG file error")]
|
||||||
|
PngError(#[from] png::PngError),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Container for 256 color 2D pixel/image data that can be rendered to the screen. Pixel data
|
/// Container for 256 color 2D pixel/image data that can be rendered to the screen. Pixel data
|
||||||
|
|
Loading…
Reference in a new issue