propertiesView: Use decoder format

Use the format that we actually used when decoding.
The mime type is usually derived from the file extension
which might not always be correct.

Issue #43

Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/132>
This commit is contained in:
Sophie Herold 2023-03-09 22:10:08 +01:00 • committed by Marge Bot
parent f8e64d9805
commit a2a9b4134b
6 changed files with 44 additions and 38 deletions

View file

@ -7,3 +7,29 @@ pub use image_rs_other::ImageRsOther;
pub use svg::{Svg, RSVG_MAX_SIZE};
use super::{Decoder, UpdateSender};
#[derive(Clone, Copy, Debug)]
pub enum ImageFormat {
ImageRs(image_rs::ImageFormat),
// TODO: Add details about contained format
Heif,
Svg,
}
impl std::fmt::Display for ImageFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
match self {
Self::ImageRs(format) => {
let debug = format!("{:?}", format);
if debug.len() <= 4 {
// uppercase abbreviations
write!(f, "{}", debug.to_uppercase())
} else {
write!(f, "{}", debug)
}
}
Self::Heif => write!(f, "HEIF Container"),
Self::Svg => write!(f, "SVG"),
}
}
}

View file

@ -15,25 +15,7 @@ use gtk::graphene;
use std::io::Read;
use std::sync::Arc;
pub use formats::RSVG_MAX_SIZE;
#[derive(Clone, Copy, Debug)]
pub enum ImageFormat {
ImageRs(image_rs::ImageFormat),
// TODO: Add details about contained format
Heif,
Svg,
}
impl std::fmt::Display for ImageFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
match self {
Self::ImageRs(format) => write!(f, "{:?}", format),
Self::Heif => write!(f, "HEIF"),
Self::Svg => write!(f, "SVG"),
}
}
}
pub use formats::{ImageFormat, RSVG_MAX_SIZE};
#[derive(Clone, Copy, Debug)]
/// Renderer requests new tiles