gecko-dev/gfx/qcms
Jeff Muizelaar 1e008e0df3 Bug 1884381 - Use a single allocation for precache_output. r=gfx-reviewers,gw
We always want to either have all of these or none of these so
just put them all together. This will also make it easier for us to
store the output matrix along side.

Differential Revision: https://phabricator.services.mozilla.com/D204070
2024-03-11 13:36:59 +00:00
..
fuzz
profiles
src Bug 1884381 - Use a single allocation for precache_output. r=gfx-reviewers,gw 2024-03-11 13:36:59 +00:00
CONTRIBUTING.md Bug 1873525 - qcms: Add back COPYING, add CONTRIBUTING.md and bump the version. r=gfx-reviewers,aosmond,supply-chain-reviewers 2024-01-09 04:04:09 +00:00
COPYING Bug 1873525 - qcms: Add back COPYING, add CONTRIBUTING.md and bump the version. r=gfx-reviewers,aosmond,supply-chain-reviewers 2024-01-09 04:04:09 +00:00
Cargo.toml Bug 1882291. Switch to stdarch_arm_neon_intrinsics feature on rust >=1.78. r=glandium 2024-03-05 03:12:28 +00:00
ITU-709.icc
ITU-2020.icc
README.md
build.rs Bug 1882291. Switch to stdarch_arm_neon_intrinsics feature on rust >=1.78. r=glandium 2024-03-05 03:12:28 +00:00
moz.build
qcms.h Bug 1871185 - Add support for creating a displayP3 profile. r=aosmond 2023-12-21 15:00:54 +00:00
qcmsint.h
qcmstypes.h
sRGB_lcms.icc

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.