diff --git a/Makefile b/Makefile index e22701e..2979d29 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,12 @@ yaitaa: lib obj/%.o: src/%.c $(CC) $(CFLAGS) $^ $(INCLUDES) -DVERSION="\"$(VERSION)\"" -c -o $@ -testbuild: - make clean all CC=clang +testbuild: use_clang use_tcc make clean all oclint src/*.c + +use_clang: + make clean all CC=clang + +use_tcc: + make clean all CC=tcc CFLAGS="$(CFLAGS) -DSTBI_NO_SIMD" diff --git a/src/args.h b/src/args.h index c6490d4..b23241a 100644 --- a/src/args.h +++ b/src/args.h @@ -1,5 +1,5 @@ /* - * yaitaa - yet another image to ascii art converter + * yaitaa - yet another image to ascii art converter * Copyright (C) 2022 hatkidchan * * This program is free software: you can redistribute it and/or modify diff --git a/src/colors.h b/src/colors.h index 07a2c44..e894285 100644 --- a/src/colors.h +++ b/src/colors.h @@ -1,5 +1,5 @@ /* - * yaitaa - yet another image to ascii art converter + * yaitaa - yet another image to ascii art converter * Copyright (C) 2022 hatkidchan * * This program is free software: you can redistribute it and/or modify diff --git a/src/fmt_strings.h b/src/fmt_strings.h index 1c28ed8..4719ecb 100644 --- a/src/fmt_strings.h +++ b/src/fmt_strings.h @@ -1,3 +1,20 @@ +/* + * yaitaa - yet another image to ascii art converter + * Copyright (C) 2022 hatkidchan + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #ifndef _FMT_STRINGS_H #define _FMT_STRINGS_H diff --git a/src/image.h b/src/image.h index 3e28073..ed41e01 100644 --- a/src/image.h +++ b/src/image.h @@ -1,5 +1,5 @@ /* - * yaitaa - yet another image to ascii art converter + * yaitaa - yet another image to ascii art converter * Copyright (C) 2022 hatkidchan * * This program is free software: you can redistribute it and/or modify diff --git a/src/mod_braille.c b/src/mod_braille.c index 22e072f..3d664cb 100644 --- a/src/mod_braille.c +++ b/src/mod_braille.c @@ -46,11 +46,8 @@ void mod_braille_main(asc_state_t state) { image_t *img = state.image; - uint8_t braille_char = 0x00; - rgba8 block[8]; - - rgba8 color_max, color_min; - int dist_max, dist_min, dist_min_d = 0xffffff, dist; + rgba8 bright, dark, block[8]; + int dist_max, dist_min, dist; __bra_start_output(state); for (int y = 0; y < img->height; y += 4) @@ -60,35 +57,33 @@ void mod_braille_main(asc_state_t state) for (int x = 0; x < img->width; x += 2) { __bra_update2x4(img, block, x, y); - color_max = color_min = block[0]; - dist_max = 0; - dist_min = dist_min_d; + bright = dark = block[0]; + dist_max = 0; dist_min = 0xFFFFFF; for (int i = 0; i < 8; i++) { dist = color_difference(block[i], PURE_BLACK); if (dist < dist_min) { dist_min = dist; - color_min = block[i]; + dark = block[i]; } if (dist > dist_max) { dist_max = dist; - color_max = block[i]; + bright = block[i]; } } - braille_char = 0x00; + uint8_t pixel = 0x00; for (int i = 0; i < 8; i++) { - if (__bra_best_match_i(color_min, color_max, block[i]) != 0) + if (__bra_best_match_i(dark, bright, block[i]) != 0) { - braille_char |= (1 << i); + pixel |= (1 << i); } } - __bra_put_pixel(state, color_min, color_max, - braille_char, x >= (img->width - 2)); + __bra_put_pixel(state, dark, bright, pixel, x >= (img->width - 2)); } __bra_end_line(state, final); } @@ -108,11 +103,6 @@ void __bra_putc_raw(asc_state_t state, uint8_t ch) fputc(0x80 | ((ccode >> 0) & 0x3f), state.out_file); } -void __bra_putc_esc(asc_state_t state, uint8_t ch) -{ - fprintf(state.out_file, "\\u28%02x", ch); -} - void __bra_start_output(asc_state_t state) { int w = state.image->width / 2, h = state.image->height / 4; diff --git a/src/version.h b/src/version.h index add3d47..5a8c946 100644 --- a/src/version.h +++ b/src/version.h @@ -1,3 +1,20 @@ +/* + * yaitaa - yet another image to ascii art converter + * Copyright (C) 2022 hatkidchan + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #ifndef _VERSION_H_ #define _VERSION_H_