decoder: Only warn about invalid ICC profile
Before the image failed loading Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/190>
This commit is contained in:
parent
670329cd95
commit
7b6ee24651
3 changed files with 32 additions and 9 deletions
|
|
@ -190,11 +190,17 @@ impl<'a> Decoded<'a> {
|
|||
|
||||
if let Some(icc_profile) = &self.icc_profile {
|
||||
if memory_format == gdk::MemoryFormat::R8g8b8 {
|
||||
util::new_trafo::<rgb::RGB8>(icc_profile, lcms2::PixelFormat::RGB_8)?
|
||||
.transform_in_place(buffer.as_pixels_mut());
|
||||
util::appply_icc_profile::<rgb::RGB8>(
|
||||
icc_profile,
|
||||
lcms2::PixelFormat::RGB_8,
|
||||
buffer.as_pixels_mut(),
|
||||
);
|
||||
} else if memory_format == gdk::MemoryFormat::R8g8b8a8 {
|
||||
util::new_trafo::<rgb::RGBA8>(icc_profile, lcms2::PixelFormat::RGBA_8)?
|
||||
.transform_in_place(buffer.as_pixels_mut());
|
||||
util::appply_icc_profile::<rgb::RGBA8>(
|
||||
icc_profile,
|
||||
lcms2::PixelFormat::RGBA_8,
|
||||
buffer.as_pixels_mut(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -297,8 +297,11 @@ impl Decoded {
|
|||
}
|
||||
image_rs::DynamicImage::ImageRgb8(mut buffer) => {
|
||||
if let Some(icc_profile) = &self.icc_profile {
|
||||
util::new_trafo::<rgb::RGB8>(icc_profile, lcms2::PixelFormat::RGB_8)?
|
||||
.transform_in_place(buffer.as_pixels_mut());
|
||||
util::appply_icc_profile::<rgb::RGB8>(
|
||||
icc_profile,
|
||||
lcms2::PixelFormat::RGB_8,
|
||||
buffer.as_pixels_mut(),
|
||||
);
|
||||
}
|
||||
(
|
||||
1,
|
||||
|
|
@ -309,8 +312,11 @@ impl Decoded {
|
|||
}
|
||||
image_rs::DynamicImage::ImageRgba8(mut buffer) => {
|
||||
if let Some(icc_profile) = &self.icc_profile {
|
||||
util::new_trafo::<rgb::RGBA8>(icc_profile, lcms2::PixelFormat::RGBA_8)?
|
||||
.transform_in_place(buffer.as_pixels_mut());
|
||||
util::appply_icc_profile::<rgb::RGBA8>(
|
||||
icc_profile,
|
||||
lcms2::PixelFormat::RGBA_8,
|
||||
buffer.as_pixels_mut(),
|
||||
);
|
||||
}
|
||||
(
|
||||
1,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue