small change to image resizing

This commit is contained in:
2023-02-08 19:08:59 +01:00
parent 5f01bfa485
commit 7d33d72401
5 changed files with 16 additions and 32 deletions

View File

@@ -15,7 +15,8 @@ fn to_ascii(char_map: String, image: DynamicImage) -> Vec<Vec<Ascii>> {
let mut out: Vec<Vec<Ascii>> = Vec::new();
for pixel in image.pixels() {
let ch = char_map.as_bytes()[((get_color(pixel) as f32-1.0)/255f32 * l) as usize]; //fixme: might break with non-ASCII char_map (ie braille chars, possibly)
let ch = char_map.as_bytes()[((get_color(pixel) as f32-1.0)/255f32 * l) as usize];
//fixme: might break with non-ASCII char_map (ie braille chars, possibly)
str.push(Ascii::new(ch, pixel.2[0], pixel.2[1], pixel.2[2]));
if pixel.0 == image.width()-1 {