LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Merge PR #528
Brandon Thomasdb03b4a58632
diff --cc crates/engine/src/camera_preview.rsindex 990c2cdc7,6bc2eeb91..badd6f293--- a/crates/engine/src/camera_preview.rs+++ b/crates/engine/src/camera_preview.rs@@@ -104,25 -162,19 +170,29 @@@ fn proxies(raw: &RawImage, bytes: &[u8]sensor.map_in_place(to_working);// Canon's JPEG can be cropped differently from the sensor. Estimate only that common// framing from edge directions, independently of the subsequent colour fit.- sensor = align_cr3_framing(sensor, &reference);+ (sensor, clipped) = align_cr3_framing(sensor, clipped, &reference);}let mut sensor = fit(&sensor, size, size, Filter::Box);- let reference = fit(&reference, sensor.width, sensor.height, Filter::Box);+ let reference = reference_at(&reference, &sensor);+ // A proxy pixel is clipped when any sample it averages is (outside the CR3 framing the mask is- // NaN: those pixels are left out of the pairs anyway).- let clipped: Vec<bool> = fit(&clipped, sensor.width, sensor.height, Filter::Box).data.iter().map(|p| p[0] > 0.0).collect();++ // NaN: those pixels are left out of the pairs anyway). Resized to exactly the proxy's size, like++ // the reference, so the mask pairs pixel for pixel.++ let clipped: Vec<bool> = resize(&clipped, sensor.width, sensor.height, Filter::Box).data.iter().map(|p| p[0] > 0.0).collect();if raw.format != RawFormat::Cr3 {sensor.map_in_place(to_working);}- Some((sensor, reference))+ Some((sensor, reference, clipped))}+/// The camera JPEG at exactly the sensor proxy's size, so the two pair pixel for pixel. Fitting it+/// into the proxy's box instead keeps its own aspect, which can round a pixel short: an ILCE-7RM4's+/// 1616×1080 preview, decoded at 384×257, fits a 192×128 proxy as 191×128, and `collect_pairs`+/// then rejected every file `lightcraft-cli calibrate` was given. `proxies` has already checked+/// that the aspects agree within 2 %.+fn reference_at(reference: &Rgb32f, sensor: &Rgb32f) -> Rgb32f {+ resize(reference, sensor.width, sensor.height, Filter::Box)+}+#[derive(Clone, Copy, Debug)]struct Cr3Framing {scale: f32,diff --cc crates/engine/src/media.rsindex 8a3dc2497,e45191375..9a28bf7e2--- a/crates/engine/src/media.rs+++ b/crates/engine/src/media.rs@@@ -62,7 -62,7 +62,7 @@@ impl SettingsHashes}/// Bump when the pipeline's output changes, to invalidate cached thumbnails.- pub const RENDER_CACHE_VERSION: u64 = 26;-pub const RENDER_CACHE_VERSION: u64 = 23;++pub const RENDER_CACHE_VERSION: u64 = 27;/// Thumbnails render at one of these long edges (so window/cell size changes reuse the cache).pub const THUMB_SIZES: [usize; 4] = [128, 256, 384, 512];