decoder: Use glycin for image loading expect SVG
This gives us sandboxed image decoding and others the option to extend Loupe with other image formats.
This commit is contained in:
parent
d690c0e2d8
commit
1b2dde79b6
18 changed files with 536 additions and 1416 deletions
|
|
@ -246,31 +246,3 @@ pub fn spawn<R: 'static, F: std::future::Future<Output = R> + 'static>(
|
|||
let ctx = glib::MainContext::default();
|
||||
ctx.spawn_local(f)
|
||||
}
|
||||
|
||||
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).context("Invalid ICC profile")?;
|
||||
|
||||
let target_profile = lcms2::Profile::new_srgb();
|
||||
|
||||
Ok(lcms2::Transform::new(
|
||||
&src_profile,
|
||||
src_format,
|
||||
&target_profile,
|
||||
src_format,
|
||||
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