gecko-dev/gfx/qcms
Jon Bauman 619acc91bb Bug 1729539 - Hit MOZ_CRASH(assertion failed: y2 > 1. / 12. && y2 <= 1.) at gfx/qcms/src/iccread.rs:1392. r=jrmuizel
The assertion is due to an inappropriate test of exact floating-point values.
build_trc_table() handles this saturating case, so there's no need to assert.
Add more test coverage to be certain no fuzzing inputs will lead to crashes.

Differential Revision: https://phabricator.services.mozilla.com/D125006
2021-09-17 17:41:26 +00:00
..
fuzz Bug 1721483 - qcms: Remove unneeded vim modelines. r=aosmond 2021-07-20 21:36:18 +00:00
profiles Bug 1706144 - Add support for CMYK. r=aosmond 2021-04-23 02:42:53 +00:00
src Bug 1729539 - Hit MOZ_CRASH(assertion failed: y2 > 1. / 12. && y2 <= 1.) at gfx/qcms/src/iccread.rs:1392. r=jrmuizel 2021-09-17 17:41:26 +00:00
build.rs Bug 1723253 - qcms: Clippy/costmetic changes. r=jrmuizel 2021-08-05 05:10:37 +00:00
Cargo.toml Bug 1706144 - Add support for CMYK. r=aosmond 2021-04-23 02:42:53 +00:00
ITU-709.icc Bug 1723253 - qcms: Add CICP (Coding-independent code points) support. r=jrmuizel 2021-08-05 05:10:37 +00:00
ITU-2020.icc Bug 1723253 - qcms: Add CICP (Coding-independent code points) support. r=jrmuizel 2021-08-05 05:10:37 +00:00
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 Bug 1551084 - Part 1. Minor reworking of QCMS to allow C files to compile as C++. r=miko 2019-05-27 15:43:59 -04:00
README.md Bug 1685311 - Flesh out the documentation a little. r=aosmond 2021-01-06 17:11:21 +00:00
sRGB_lcms.icc Bug 1723253 - qcms: Add CICP (Coding-independent code points) support. r=jrmuizel 2021-08-05 05:10:37 +00: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.