From 8da44fc45cf154c837d290a0c6917b1755467ccb Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 27 Nov 2024 20:13:08 +1300 Subject: [PATCH] Assume None if the line is all zeros --- src/png/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/png/mod.rs b/src/png/mod.rs index df695973..cd2d605b 100644 --- a/src/png/mod.rs +++ b/src/png/mod.rs @@ -360,6 +360,15 @@ impl PngImage { prev_line = line_data; } else { // Heuristic filter selection strategies + + if line_data.iter().all(|&x| x == 0) { + // Assume None if the line is all zeros + filtered.push(RowFilter::None as u8); + filtered.extend_from_slice(&line_data); + prev_line = line_data; + continue; + } + let mut best_line = Vec::new(); let mut best_line_raw = Vec::new(); // Avoid vertical filtering on first line of each interlacing pass