From 88b6efba2a40bd2ac6c5f7c133d6adc690ace2de Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Mon, 23 Nov 2026 17:42:54 +0100 Subject: [PATCH] Burn: test light above white when a 32-bit colour's luma isn't positive A 32-bit colour with a channel above 1.0 and a negative channel can have a non-positive luma; Burn with Protect Tones returned black for it. The merged Dodge fix gives such a colour the per-channel curve, which keeps the light above white; this pins that for Burn. Refs #12674. --- .../retouch_cmds/burn_32bit_linear_tests.rs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/engine/src/cmd/retouch_cmds/burn_32bit_linear_tests.rs b/crates/engine/src/cmd/retouch_cmds/burn_32bit_linear_tests.rs index 20e9edb5157..f17525adf04 100644 --- a/crates/engine/src/cmd/retouch_cmds/burn_32bit_linear_tests.rs +++ b/crates/engine/src/cmd/retouch_cmds/burn_32bit_linear_tests.rs @@ -146,6 +146,29 @@ fn burn_keeps_light_above_white_with_unmeasured_settings_in_32_bit() { assert!(after > 1.0, "32-bit Grayscale Burn clipped {before} to {after}"); } +#[test] +fn burn_keeps_light_above_white_when_luma_is_not_positive_in_32_bit() { + // A channel above white next to a negative one: luma <= 0, so Protect Tones can't scale the + // colour by luma. It takes the per-channel curve instead and keeps the light above white. + for exposure in [25, 100] { + for o in [[1.2f32, -0.7, 0.2], [1.01, -0.52, 0.02]] { + let mut s = patches(32); + s.edit("bright", |doc, active| { + let surf = doc.layer_mut(active.unwrap()).unwrap().surface_mut().unwrap(); + let px = photocraft_raster::from_rgba(&surf.format(), [o[0], o[1], o[2], 1.0]); + surf.write_region(photocraft_geom::Rect::new(0, 0, SIDE, SIDE), &px.repeat((SIDE * SIDE) as usize)); + Ok(()) + }) + .unwrap(); + assert_eq!(rgb(&s, SIDE / 2, SIDE / 2), o); + let c = burn_each(&mut s, json!({"exposure": exposure}))[0]; + assert!(c[0] > 1.0, "{exposure} % Burn of {o:?} clipped light above white: {c:?}"); + let e = dodge_burn(o, exposure as f32 / 100.0, ToneRange::Midtones, true, false); + assert!(c.iter().zip(e).all(|(c, e)| (c - e).abs() < 1e-5), "{exposure} % Burn of {o:?}: got {c:?}, the per-channel curve gives {e:?}"); + } + } +} + #[test] fn burn_keeps_tones_in_order_in_32_bit() { let mut s = Session::new();