From a665f9498ddb87b8d239aa929e50321b5af97064 Mon Sep 17 00:00:00 2001 From: hkc Date: Mon, 30 Sep 2024 13:58:22 +0300 Subject: [PATCH] One can only hope --- img2cpi.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/img2cpi.c b/img2cpi.c index 29907f9..fb0b12f 100644 --- a/img2cpi.c +++ b/img2cpi.c @@ -84,7 +84,7 @@ struct image *image_load(const char *fp); struct image *image_new(int w, int h); struct image *image_resize(struct image *original, int new_w, int new_h); struct image_pal *image_quantize(struct image *original, const union color *colors, size_t n_colors); -float get_color_difference(union color a, union color b); +int get_color_difference(union color a, union color b); void image_unload(struct image *img); void get_size_keep_aspect(int w, int h, int dw, int dh, int *ow, int *oh); @@ -251,7 +251,7 @@ int main(int argc, char **argv) { // Oh boy... int min_diff = 0xffffff; char closest_sym = 0x00, closest_color = 0xae; - for (int sym = 0x01; sym <= 0xff; sym++) { + for (int sym = 0x01; sym <= 0xFF; sym++) { if (sym == '\t' || sym == '\n' || sym == '\r' || sym == '\x0e') { continue; } @@ -276,9 +276,6 @@ int main(int argc, char **argv) { } } } - if (closest_sym != 0) { - printf("HIT! %d\n", closest_sym); - } characters[x + y * args.width].character = closest_sym; characters[x + y * args.width].bg = closest_color & 0xF; characters[x + y * args.width].fg = closest_color >> 4; @@ -584,7 +581,7 @@ struct image_pal *image_quantize(struct image *original, const union color *colo return out; } -float get_color_difference(union color a, union color b) { +int get_color_difference(union color a, union color b) { int dr = a.rgba.r - b.rgba.r, dg = a.rgba.g - b.rgba.g, db = a.rgba.b - b.rgba.b;