firefox-desktop/gfx/qcms
2025-03-05 19:56:11 +01:00
..
fuzz Update On 202107231202 2021-07-23 12:02:49 +08:00
profiles Update On 202106020807 2021-06-02 08:07:58 +08:00
src Update On Wed Mar 5 19:56:10 CET 2025 2025-03-05 19:56:11 +01:00
build.rs Update On Tue Aug 27 20:48:38 CEST 2024 2024-08-27 20:48:39 +02:00
Cargo.toml Update On Tue Mar 5 19:42:22 CET 2024 2024-03-05 19:42:22 +01:00
CONTRIBUTING.md Update On Tue Jan 9 19:41:40 CET 2024 2024-01-09 19:41:41 +01:00
COPYING Update On Tue Jan 9 19:41:40 CET 2024 2024-01-09 19:41:41 +01:00
ITU-709.icc Update On 202108060525 2021-08-06 05:25:41 +08:00
ITU-2020.icc Update On 202108060525 2021-08-06 05:25:41 +08:00
moz.build Update On 202106020807 2021-06-02 08:07:58 +08:00
qcms.h Update On Fri Dec 22 19:42:29 CET 2023 2023-12-22 19:42:30 +01:00
qcmsint.h Update On 202106020807 2021-06-02 08:07:58 +08:00
qcmstypes.h Update On 202106020807 2021-06-02 08:07:58 +08:00
README.md Update On 202106020807 2021-06-02 08:07:58 +08:00
sRGB_lcms.icc Update On 202108060525 2021-08-06 05:25:41 +08:00

qcms

Crates.io Documentation

Firefox's library for transforming image data between ICC profiles.

Example

    // Decode the jpeg
    let mut d = jpeg_decoder::Decoder::new(std::fs::File::open("/Users/jrmuizel/Desktop/DSCF2460.jpg").unwrap());
    let mut data = d.decode().unwrap();
    let info = d.info().unwrap();

    // Extract the profile after decode
    let profile = d.icc_profile().unwrap();

    // Create a new qcms Profile
    let input = qcms::Profile::new_from_slice(&profile).unwrap();
    let mut output = qcms::Profile::new_sRGB();
    output.precache_output_transform();

    // Create a transform between input and output profiles and apply it.
    let xfm = qcms::Transform::new(&input, &output, qcms::DataType::RGB8, qcms::Intent::default()).unwrap();
    xfm.apply(&mut data);

    // write the result to a PNG
    let mut encoder = png::Encoder::new(std::fs::File::create("out.png").unwrap(), info.width as u32, info.height as u32);
    encoder.set_color(png::ColorType::Rgb);
    encoder.set_srgb(png::SrgbRenderingIntent::Perceptual);
    let mut writer = encoder.write_header().unwrap();
    writer.write_image_data(&data).unwrap(); // Save

This library was originally written in C, was converted to Rust using c2rust, and then refactored to be mostly safe and more idiomatic Rust.