From 6019791c3bfff868d9e5644a79b0f21ab67d5059 Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Fri, 31 Dec 2021 10:20:26 +0300 Subject: [PATCH] In the bench suite, check for 3/4 channels --- qoi-bench/src/main.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/qoi-bench/src/main.rs b/qoi-bench/src/main.rs index bc7803e..8bda609 100644 --- a/qoi-bench/src/main.rs +++ b/qoi-bench/src/main.rs @@ -91,12 +91,9 @@ fn read_png(filename: &Path) -> Result { let mut buf = vec![0; reader.output_buffer_size()]; let info = reader.next_frame(&mut buf)?; let bytes = &buf[..info.buffer_size()]; - Ok(Image { - width: info.width, - height: info.height, - channels: info.color_type.samples() as u8, - data: bytes.to_vec(), - }) + let channels = info.color_type.samples() as u8; + ensure!(channels == 3 || channels == 4, "invalid channels: {}", channels); + Ok(Image { width: info.width, height: info.height, channels, data: bytes.to_vec() }) } trait Codec {