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
|
|
@ -25,6 +25,7 @@ mod file;
|
|||
mod gps;
|
||||
|
||||
pub use file::FileInfo;
|
||||
use glycin::{Frame, MemoryFormat};
|
||||
use glycin::{FrameDetails, ImageInfoDetails};
|
||||
pub use gps::GPSLocation;
|
||||
|
||||
|
|
@ -39,6 +40,7 @@ pub struct Metadata {
|
|||
file_info: Option<FileInfo>,
|
||||
image_info: Option<glycin::ImageInfoDetails>,
|
||||
frame_info: Option<FrameDetails>,
|
||||
memory_format: Option<MemoryFormat>,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for Metadata {
|
||||
|
|
@ -80,8 +82,9 @@ impl Metadata {
|
|||
self.image_info = Some(image_info);
|
||||
}
|
||||
|
||||
pub fn set_frame_info(&mut self, frame_info: FrameDetails) {
|
||||
self.frame_info = Some(frame_info);
|
||||
pub fn set_frame_metadata(&mut self, frame: &Frame) {
|
||||
self.frame_info = Some(frame.details().clone());
|
||||
self.memory_format = Some(frame.memory_format());
|
||||
}
|
||||
|
||||
pub fn set_file_info(&mut self, file_info: FileInfo) {
|
||||
|
|
@ -144,8 +147,7 @@ impl Metadata {
|
|||
}
|
||||
|
||||
pub fn is_potentially_transparent(&self) -> bool {
|
||||
// TODO: Implement again
|
||||
true
|
||||
self.memory_format.is_some_and(|x| x.has_alpha())
|
||||
}
|
||||
|
||||
pub fn transformations_applied(&self) -> bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue