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
|
|
@ -251,7 +251,7 @@ pub fn new_trafo<F: Copy>(
|
|||
icc_profile: &[u8],
|
||||
src_format: lcms2::PixelFormat,
|
||||
) -> anyhow::Result<lcms2::Transform<F, F>> {
|
||||
let src_profile = lcms2::Profile::new_icc(icc_profile)?;
|
||||
let src_profile = lcms2::Profile::new_icc(icc_profile).context("Invalid ICC profile")?;
|
||||
|
||||
let target_profile = lcms2::Profile::new_srgb();
|
||||
|
||||
|
|
@ -263,3 +263,14 @@ pub fn new_trafo<F: Copy>(
|
|||
lcms2::Intent::Perceptual,
|
||||
)?)
|
||||
}
|
||||
|
||||
pub fn appply_icc_profile<F: Copy>(
|
||||
icc_profile: &[u8],
|
||||
src_format: lcms2::PixelFormat,
|
||||
buf: &mut [F],
|
||||
) {
|
||||
match new_trafo(icc_profile, src_format) {
|
||||
Ok(trafo) => trafo.transform_in_place(buf),
|
||||
Err(err) => log::warn!("Failed to apply ICC profile: {err}"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue