gecko-dev/gfx/qcms
Butkovits Atila 45016e9a4a Backed out changeset 1bba2e7410e1 (bug 1697818) as requested by Jeff. CLOSED TREE 2021-03-31 17:55:28 +03:00
..
fuzz Bug 1697858 - Use an additional src profile when fuzzing. r=aosmond 2021-03-11 18:45:05 +00:00
profiles Bug 1701457 - Rewrite compute_curve_gamma_table_type_parametric. r=aosmond 2021-03-29 16:41:09 +00:00
src Backed out changeset 1bba2e7410e1 (bug 1697818) as requested by Jeff. CLOSED TREE 2021-03-31 17:55:28 +03:00
Cargo.toml Bug 1702080 - Make RUSTC_BOOTSTRAP usage conditional on 'neon' feature. r=aosmond 2021-03-31 14:31:23 +00:00
README.md Bug 1685311 - Flesh out the documentation a little. r=aosmond 2021-01-06 17:11:21 +00:00
build.rs Bug 1702080 - Make RUSTC_BOOTSTRAP usage conditional on 'neon' feature. r=aosmond 2021-03-31 14:31:23 +00:00
moz.build Bug 1666057. Convert qcms to rust. r=aosmond 2020-09-21 18:40:51 +00:00
qcms.h Bug 1701758. Avoid identity sRGB transforms. r=aosmond 2021-03-31 13:15:26 +00:00
qcmsint.h Bug 1666057. Convert qcms to rust. r=aosmond 2020-09-21 18:40:51 +00:00
qcmstypes.h

README.md

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.