Skip to content

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

Merge PR #5887: Effects: Gradient Overlay transparency follows Smoothness, midpoints and method (#1954)

aionggac9b33e8b98f
diff --cc crates/io/src/blocks.rs
index 3aa0afbcb,dbd4cfe84..1ae5e1fff
--- a/crates/io/src/blocks.rs
+++ b/crates/io/src/blocks.rs
@@@ -441,12 -415,11 +443,12 @@@ pub fn fill_from_desc(key: &[u8; 4], d
b"GdFl" => {
let angle = num(d.get("Angl")).unwrap_or(90.0) as f32;
let scale = num(d.get("Scl ")).map_or(1.0, |v| v as f32 / 100.0);
- let raw = get_desc(d, "Grad").map(|g| gradient_stops_editable(g, gradient_method(d)));
+ let gradient = get_desc(d, "Grad");
+ let raw = gradient.map(|g| gradient_stops_editable(g, gradient_method(d)));
let (mut stops, midpoints) = raw.map(|r| (r.stops, r.mids)).unwrap_or_default();
- // Opacity stops with Photoshop's smoothness and opacity midpoints applied (raw when
- // the interpolation is plain); none when fully opaque.
- let mut opacity_stops = get_desc(d, "Grad").map(smoothed_opacity_stops).unwrap_or_default();
+ // Opacity stops with Photoshop's smoothness, opacity midpoints and method applied
+ // (raw when the interpolation is plain); none when fully opaque.
+ let mut opacity_stops = get_desc(d, "Grad").map(|g| baked_opacity_stops(g, gradient_method(d))).unwrap_or_default();
if opacity_stops.iter().all(|o| o.1 >= 1.0 - 1e-4) {
opacity_stops.clear();
}