Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

ui: Dust & Scratches previews at full resolution, as it applies (#3265) (#3287)

Gert Pellin - GPEe26442657f39
diff --git a/crates/ui-egui/src/filter_dialog.rs b/crates/ui-egui/src/filter_dialog.rs
index 9c33ec87b..f6c116a82 100644
--- a/crates/ui-egui/src/filter_dialog.rs
+++ b/crates/ui-egui/src/filter_dialog.rs
@@ -187,7 +187,9 @@ fn is_pixel_param_of(command: &str, key: &str) -> bool {
}
/// Filters whose features have a fixed size in document pixels that no dialog parameter scales:
-/// per-pixel noise and dots (Add Noise, Diffuse, Mezzotint, Fibers), pixel kernels and scan lines
+/// per-pixel noise and dots (Add Noise, Diffuse, Mezzotint, Fibers, and Dust & Scratches, whose
+/// specks a proxy averages away — so the preview would show nothing removed at all, #3265 — while
+/// its radius stays in document pixels), pixel kernels and scan lines
/// (Custom, Reduce Noise, De-Interlace, Trace Contour's one-pixel lines), fixed lengths and
/// widths (Ripple, Oil Paint, Wind's streaks, Extrude's depth, Flame's length, width and
/// interval) and Tree, whose branches are built from 6 px segments. On a reduced proxy those
@@ -201,6 +203,7 @@ const FULL_RESOLUTION_PREVIEW: &[&str] = &[
"filter.render.fibers",
"filter.pixelate.mezzotint",
"filter.noise.addNoise",
+ "filter.noise.dustAndScratches",
"filter.noise.reduceNoise",
"filter.other.custom",
"filter.video.deInterlace",
@@ -1316,7 +1319,9 @@ mod tests {
/// #2063: these filters drew their features in proxy pixels (noise, dots, dither, strokes,
/// kernels, scan lines, contour lines, streaks, depths, a tree's segments), so a 1/4 preview
/// showed them 4x larger than OK applied them. Their preview now runs at full resolution and
- /// matches the applied result.
+ /// matches the applied result. Dust & Scratches (#3265) is the mirror image of those: a proxy
+ /// averages away the very specks the filter exists to remove, so its preview showed an
+ /// untouched image at a blocky scale.
#[test]
fn fixed_size_filters_preview_at_the_scale_they_apply() {
let doc = sharp(256);
@@ -1330,6 +1335,7 @@ mod tests {
("filter.render.fibers", json!({})),
("filter.pixelate.mezzotint", json!({"type": "mediumDots"})),
("filter.noise.addNoise", json!({"amount": 12.5})),
+ ("filter.noise.dustAndScratches", json!({"radius": 4.0, "threshold": 0.0})),
("filter.noise.reduceNoise", json!({})),
("filter.other.custom", json!({"kernel": edge})),
("filter.video.deInterlace", json!({})),