mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Image Mode: encode linear 32-bit docs tagged with encoded profiles on narrow, assert PNG pixels
This commit is contained in:
1 parent
df40314ea8
commit
e0534fcbcb
2 files changed
+9
-2
No files matched your search
@@ -1239,7 +1239,10 @@ fn plan_depth_crossing(doc: &Document, current: SampleType, depth: SampleType) -
|
||||
};
|
||||
(DepthTone::DefaultTransfer(default_transfer), Some(bytes))
|
||||
}
|
||||
Some(_) => (DepthTone::None, None),
|
||||
// 32-bit float documents always hold linear light (including older files tagged
|
||||
// with an encoded profile), so narrow through the transfer curve while keeping
|
||||
// the existing encoded profile.
|
||||
Some(_) => (DepthTone::DefaultTransfer(default_transfer), None),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1262,7 +1265,7 @@ fn plan_depth_crossing(doc: &Document, current: SampleType, depth: SampleType) -
|
||||
match own {
|
||||
None => (DepthTone::DefaultTransfer(default_transfer), None),
|
||||
Some(ref p) if is_linear(p) => (DepthTone::DefaultTransfer(default_transfer), Some(Builtin::DotGain20Compat.profile().to_bytes())),
|
||||
Some(_) => (DepthTone::None, None),
|
||||
Some(_) => (DepthTone::DefaultTransfer(default_transfer), None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1203,6 +1203,10 @@ fn thirty_two_bit_export_keeps_colour_in_exr_and_png() {
|
||||
craft_cms::Profile::parse(png_icc).unwrap().same_colors(craft_cms::Builtin::LinearSrgb.profile()),
|
||||
"PNG export of a 32-bit document must embed linear sRGB, not sRGB"
|
||||
);
|
||||
let png_px = png_doc.layers[0].surface().unwrap().pixel(0, 0);
|
||||
for (got, want) in png_px.iter().zip([0.23455f32, 0.57758, 0.02122]) {
|
||||
assert!((got - want).abs() < 1e-3, "PNG pixel {png_px:?} vs {want}");
|
||||
}
|
||||
|
||||
// Untagged / non-ICC export (BMP) converts from linear sRGB back to 8-bit sRGB 133/200/40.
|
||||
let bmp = photocraft_io::export(d, "out.bmp", &photocraft_io::ExportOptions::default()).unwrap();
|
||||
|
||||
Reference in new issue
Block a user