fixed resizing image

This commit is contained in:
2023-02-08 17:04:22 +01:00
parent 5a1eda07da
commit b00ef93c1c
5 changed files with 86 additions and 30 deletions

View File

@@ -1,4 +1,6 @@
use std::process::exit;
use image::{DynamicImage, GenericImageView, Rgba};
use log::error;
//todo: consider how to take care of the a channel => do we want to render that as background?
fn get_color(pixel: (u32, u32, Rgba<u8>)) -> u8 {
@@ -8,7 +10,6 @@ fn get_color(pixel: (u32, u32, Rgba<u8>)) -> u8 {
}
fn to_ascii(char_map: String, image: DynamicImage) -> Vec<String> {
//todo: add color support
let l = char_map.len() as f32;
let mut str = String::new();
let mut out: Vec<String> = Vec::new();
@@ -39,6 +40,11 @@ pub fn to_braille_ascii(image: DynamicImage) -> Vec<String> {
}
pub fn to_custom_ascii(char_map: String, image: DynamicImage) -> Vec<String> {
//todo: this
vec!["not implemented".to_owned()]
if char_map.is_empty() {
error!("Custom map can not be empty!");
exit(1);
}
to_ascii(char_map, image)
}
//todo: replace Vec<String> with a custom struct containing rgb information as well as character (for coloured output)