gecko-dev/gfx/qcms
Mike Hommey 7ce663eb08 Bug 1772048 - Update rustc_version and semver crates. r=emilio,webdriver-reviewers,kinetik,whimboo
semver 1.0 doesn't and won't support Clone on semver::Error[1], so we
convert the mozversion error type to store the string version of the
error, which is an incompatible change requiring a version bump on the
crate.

1. https://github.com/dtolnay/semver/pull/280

Differential Revision: https://phabricator.services.mozilla.com/D147825
2022-06-07 10:01:32 +00:00
..
fuzz
profiles
src Bug 1771827 - Don't enable the aarch64_target_feature feature on rustc 1.61.0. r=gfx-reviewers,jrmuizel 2022-05-31 00:50:09 +00:00
build.rs Bug 1771827 - Don't enable the aarch64_target_feature feature on rustc 1.61.0. r=gfx-reviewers,jrmuizel 2022-05-31 00:50:09 +00:00
Cargo.toml Bug 1772048 - Update rustc_version and semver crates. r=emilio,webdriver-reviewers,kinetik,whimboo 2022-06-07 10:01:32 +00:00
ITU-709.icc
ITU-2020.icc
moz.build
qcms.h Bug 1696045 - Add AVIF telemetry for unimplemented features and performance. r=aosmond 2021-08-24 22:34:32 +00:00
qcmsint.h
qcmstypes.h
README.md
sRGB_lcms.icc

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.