metadata: Report if image can be transparent
This feature was not implemented before and would always return true, triggering a line detection for the background color in large JPEG images. Part-of: <https://gitlab.gnome.org/GNOME/loupe/-/merge_requests/442>
This commit is contained in:
parent
daadbda4ee
commit
1ea4a3ad5d
2 changed files with 7 additions and 5 deletions
|
|
@ -69,7 +69,7 @@ impl Glycin {
|
||||||
let frame = image.next_frame().await?;
|
let frame = image.next_frame().await?;
|
||||||
|
|
||||||
let mut metadata: Metadata = Metadata::default();
|
let mut metadata: Metadata = Metadata::default();
|
||||||
metadata.set_frame_info(frame.details().clone());
|
metadata.set_frame_metadata(&frame);
|
||||||
updater.send(DecoderUpdate::Metadata(Box::new(metadata)));
|
updater.send(DecoderUpdate::Metadata(Box::new(metadata)));
|
||||||
tiles.set_original_dimensions((frame.width() as u32, frame.height() as u32));
|
tiles.set_original_dimensions((frame.width() as u32, frame.height() as u32));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ mod file;
|
||||||
mod gps;
|
mod gps;
|
||||||
|
|
||||||
pub use file::FileInfo;
|
pub use file::FileInfo;
|
||||||
|
use glycin::{Frame, MemoryFormat};
|
||||||
use glycin::{FrameDetails, ImageInfoDetails};
|
use glycin::{FrameDetails, ImageInfoDetails};
|
||||||
pub use gps::GPSLocation;
|
pub use gps::GPSLocation;
|
||||||
|
|
||||||
|
|
@ -39,6 +40,7 @@ pub struct Metadata {
|
||||||
file_info: Option<FileInfo>,
|
file_info: Option<FileInfo>,
|
||||||
image_info: Option<glycin::ImageInfoDetails>,
|
image_info: Option<glycin::ImageInfoDetails>,
|
||||||
frame_info: Option<FrameDetails>,
|
frame_info: Option<FrameDetails>,
|
||||||
|
memory_format: Option<MemoryFormat>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for Metadata {
|
impl std::fmt::Debug for Metadata {
|
||||||
|
|
@ -80,8 +82,9 @@ impl Metadata {
|
||||||
self.image_info = Some(image_info);
|
self.image_info = Some(image_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_frame_info(&mut self, frame_info: FrameDetails) {
|
pub fn set_frame_metadata(&mut self, frame: &Frame) {
|
||||||
self.frame_info = Some(frame_info);
|
self.frame_info = Some(frame.details().clone());
|
||||||
|
self.memory_format = Some(frame.memory_format());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_file_info(&mut self, file_info: FileInfo) {
|
pub fn set_file_info(&mut self, file_info: FileInfo) {
|
||||||
|
|
@ -144,8 +147,7 @@ impl Metadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_potentially_transparent(&self) -> bool {
|
pub fn is_potentially_transparent(&self) -> bool {
|
||||||
// TODO: Implement again
|
self.memory_format.is_some_and(|x| x.has_alpha())
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn transformations_applied(&self) -> bool {
|
pub fn transformations_applied(&self) -> bool {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue