enforced ASCII validation on '--map' flag
This commit is contained in:
parent
2b9817080e
commit
529b6a61e2
|
|
@ -17,7 +17,6 @@ fn to_ascii(char_map: String, image: DynamicImage) -> Vec<Vec<Ascii>> {
|
|||
|
||||
for pixel in image.pixels() {
|
||||
let ch = char_map.as_bytes()[((get_color(pixel.2) as f32-1.0)/255f32 * l) as usize];
|
||||
//fixme: might break with non-ASCII char_map
|
||||
str.push(Ascii::new(ch, pixel.2[0], pixel.2[1], pixel.2[2]));
|
||||
|
||||
if pixel.0 == image.width()-1 {
|
||||
|
|
|
|||
|
|
@ -92,6 +92,13 @@ impl Cli {
|
|||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(map) = self.map.clone() {
|
||||
if !map.is_ascii() {
|
||||
error!("map can not contain non-ASCII characters!");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init(&self) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue