From 345232d30a6dad95c821e269a400c466e3bbd362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesi=C5=84ski?= Date: Tue, 13 Nov 2018 20:44:47 +0000 Subject: [PATCH] Update reductions flag when alpha changed --- src/lib.rs | 4 +++- src/png/mod.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6a9d43f6..f4b49097 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -768,7 +768,9 @@ fn perform_reductions(png: &mut PngData, opts: &Options, deadline: &Deadline) -> return reduction_occurred; } - png.try_alpha_reduction(&opts.alphas); + if png.try_alpha_reduction(&opts.alphas) { + reduction_occurred = true; + } reduction_occurred } diff --git a/src/png/mod.rs b/src/png/mod.rs index 50665e42..c4597350 100644 --- a/src/png/mod.rs +++ b/src/png/mod.rs @@ -587,7 +587,7 @@ impl PngData { changed } - pub fn try_alpha_reduction(&mut self, alphas: &HashSet) { + pub fn try_alpha_reduction(&mut self, alphas: &HashSet) -> bool { assert!(!alphas.is_empty()); let alphas = alphas.iter().collect::>(); let best_size = AtomicMin::new(None); @@ -623,7 +623,9 @@ impl PngData { if let Some(best) = best { self.raw_data = best.1.raw_data; + return true; } + false } pub fn reduce_alpha_channel(&mut self, optim: AlphaOptim) -> bool {