From 3f1a5b01ca4c1d15959aaf96c4e6bf8abd18bfb7 Mon Sep 17 00:00:00 2001 From: Kamal Ahmad Date: Sun, 23 Jun 2019 17:40:11 +0500 Subject: [PATCH] Account for filter size when pre-allocating in reduced_alpha_to_up --- Cargo.toml | 1 + src/reduction/alpha.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5c24e963..4938d02d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ zopfli = "^0.4.0" miniz_oxide = "0.2.0" rgb = "0.8.11" + [dependencies.rayon] optional = true version = "^1.0.0" diff --git a/src/reduction/alpha.rs b/src/reduction/alpha.rs index f0e62e22..b255e9f7 100644 --- a/src/reduction/alpha.rs +++ b/src/reduction/alpha.rs @@ -97,7 +97,7 @@ fn reduced_alpha_to_up(png: &PngImage, bpc: usize, bpp: usize) -> Vec { scan_lines.reverse(); let mut lines = Vec::with_capacity(scan_lines.len()); let mut last_line = Vec::new(); - let mut current_line = Vec::with_capacity(scan_lines[0].data.len()); + let mut current_line = Vec::with_capacity(scan_lines[0].data.len() + 1); // filter size + pixels for line in scan_lines { if line.data.len() != last_line.len() { last_line = vec![0; line.data.len()];