gecko-dev/gfx/qcms
Csoregi Natalia f822f99642 Backed out 6 changesets (bug 1799258) for failures on gfx.color_management.display_profile. CLOSED TREE
Backed out changeset 22351f36b74b (bug 1799258)
Backed out changeset 9bbbe3ed2794 (bug 1799258)
Backed out changeset e05c809f58d0 (bug 1799258)
Backed out changeset 791eeb52f034 (bug 1799258)
Backed out changeset 353ef4721bba (bug 1799258)
Backed out changeset b5157d950aa7 (bug 1799258)
2023-01-24 02:08:51 +02: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 Backed out 6 changesets (bug 1799258) for failures on gfx.color_management.display_profile. CLOSED TREE 2023-01-24 02:08:51 +02:00
Cargo.toml Bug 1783985 - Remove compat with rustc < 1.61 from qcms. r=gfx-reviewers,jgilbert,jrmuizel 2022-08-16 00:56:24 +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
README.md
moz.build
qcms.h Backed out 6 changesets (bug 1799258) for failures on gfx.color_management.display_profile. CLOSED TREE 2023-01-24 02:08:51 +02:00
qcmsint.h
qcmstypes.h
sRGB_lcms.icc Bug 1723253 - qcms: Add CICP (Coding-independent code points) support. r=jrmuizel 2021-08-05 05:10:37 +00:00

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.