From c138c047ed4a2ef3de42bb5fcbd553ef23532ad8 Mon Sep 17 00:00:00 2001 From: djairoh Date: Thu, 9 Feb 2023 13:49:16 +0100 Subject: [PATCH] small rebase of to_ascii function --- src/ascii_manipulation.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ascii_manipulation.rs b/src/ascii_manipulation.rs index e228ca4..63ab46c 100644 --- a/src/ascii_manipulation.rs +++ b/src/ascii_manipulation.rs @@ -36,8 +36,10 @@ fn to_ascii(char_map: String, image: DynamicImage) -> Vec> { let mut out: Vec> = Vec::new(); for pixel in image.pixels() { - let ch = char_map.as_bytes()[((get_color(pixel.2) as f32-1.0)/255f32 * l) as usize]; - str.push(Ascii::new(ch, pixel.2[0], pixel.2[1], pixel.2[2])); + let mut ascii = Ascii::new(0, pixel.2[0], pixel.2[1], pixel.2[2]); + let ch = char_map.as_bytes()[((ascii.col_depth as f32-1.0)/255f32 * l) as usize]; + ascii.char = char::from(ch); + str.push(ascii); if pixel.0 == image.width()-1 { out.push(str);