mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
aaea911dc4
Backed out changeset 40351b5987a5 (bug 1799258) Backed out changeset 87f3532bfbcd (bug 1799258) Backed out changeset 9c1d9405e8bf (bug 1799258) Backed out changeset 60a0351d9092 (bug 1799258) Backed out changeset 5f911de66ec0 (bug 1799258) Backed out changeset 294a00d1c7b7 (bug 1799258) Backed out changeset 228200dcaf93 (bug 1799258) Backed out changeset b25110652394 (bug 1799258) Backed out changeset 3c3c7366cc40 (bug 1799258) |
||
---|---|---|
.. | ||
fuzz | ||
profiles | ||
src | ||
Cargo.toml | ||
ITU-709.icc | ||
ITU-2020.icc | ||
moz.build | ||
qcms.h | ||
qcmsint.h | ||
qcmstypes.h | ||
README.md | ||
sRGB_lcms.icc |
qcms
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.