mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
fix(color): Color Range's sampled colours judge in the space the canvas shows
The Lab box the sampled-colour rows compare against was built through the free composite_profile, so for an untagged document it stayed in the mode's built-in default while the same picture on the canvas was read in Color Settings' working space: the same two sampled colours marked the same columns no matter what the setting said. The new pin runs that box over a ramp of columns and fails when the marks do not move.
This commit is contained in:
1 parent
f8cf07d040
commit
5f59590516
2 files changed
+25
-2
No files matched your search
@@ -170,10 +170,12 @@ fn parse_color(p: &Value) -> [f32; 3] {
|
||||
}
|
||||
}
|
||||
|
||||
/// Composite RGB (the compositor's output profile for the document) → CIE Lab D50.
|
||||
/// Composite RGB (the profile the session shows the document's composite in) → CIE Lab D50.
|
||||
fn lab_transform(s: &Session) -> Result<std::sync::Arc<craft_cms::Transform>> {
|
||||
let d = s.active().ok_or(EngineError::NoDocument)?;
|
||||
let src = crate::color_cmds::composite_profile(&d.doc);
|
||||
// An untagged document's composite is the working space (#14224), so the hue rows and the
|
||||
// sampled colours select what the canvas actually shows.
|
||||
let src = s.color().composite_profile(&d.doc);
|
||||
craft_cms::cached(&src, craft_cms::Builtin::LabD50.profile(), craft_cms::TransformOptions::default())
|
||||
.map_err(|e| EngineError::Other(format!("colour management: {e}")))
|
||||
}
|
||||
|
||||
@@ -397,6 +397,27 @@ fn an_untagged_indexed_document_follows_the_mode_default_until_it_becomes_rgb()
|
||||
assert_eq!(reported(&mut s)["description"], s.color().working(ColorMode::Rgb).description, "and Profile Info agrees");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn colour_range_judges_sampled_colours_in_the_space_the_canvas_shows() {
|
||||
let mut s = crate::session();
|
||||
// A box spanned by two sampled colours and a ramp of columns across it. Membership is decided in
|
||||
// Lab, through the profile the composite is read in, so once the working space moves the box has
|
||||
// to move with the picture: with the ramp below one column drops out going from sRGB to
|
||||
// ProPhoto, and none of this changes at the default setting.
|
||||
let columns: Vec<[f32; 3]> = (0..8).map(|i| [0.55 + 0.03 * i as f32, 0.45 - 0.03 * i as f32, 0.45 - 0.02 * i as f32]).collect();
|
||||
s.open_document(untagged_rgb(&columns, SampleType::U8), None);
|
||||
let marked = |s: &mut Session| -> Vec<usize> {
|
||||
s.execute("select.colorRange", json!({"select": "sampledColors", "colors": ["#cc4d4d", "#996666"], "fuzziness": 40})).unwrap();
|
||||
let doc = s.active().unwrap().doc.clone();
|
||||
let selection = doc.selection.clone().expect("a selection was set");
|
||||
(0..columns.len()).filter(|i| selection.pixel(*i as i32 * 4 + 2, 2)[0] > 0.5).collect()
|
||||
};
|
||||
let as_built_in = marked(&mut s);
|
||||
s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap();
|
||||
let as_working = marked(&mut s);
|
||||
assert_ne!(as_built_in, as_working, "the sampled colour box marked the same columns whatever the working space: {as_built_in:?} vs {as_working:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_profile_commands_answer_the_same_for_a_tagged_document() {
|
||||
let mut replies = Vec::new();
|
||||
|
||||
Reference in new issue
Block a user