diff --git a/C/src/ascii.c b/C/src/ascii.c index d6a1ddf..4b14ab3 100644 --- a/C/src/ascii.c +++ b/C/src/ascii.c @@ -388,8 +388,11 @@ static int emit_glyph(char *out, size_t out_size, int out_idx, int grayscale_to_ascii(const uint8_t *gray, const uint8_t *rgb, int src_w, int src_h, int dst_w, int dst_h, char *out, size_t out_size, const ascii_opts_t *opts) { + render_mode_t render_mode = opts ? opts->render_mode : RENDER_BRAILLE; + int safe_dst_w = dst_w - (dst_w % 2); - int safe_dst_h = dst_h - (dst_h % 4); + int safe_dst_h = (render_mode == RENDER_HALF_BLOCK) ? dst_h - (dst_h % 2) + : dst_h - (dst_h % 4); int brightness = opts ? opts->brightness : 0; int contrast = opts ? opts->contrast : 100; @@ -398,7 +401,6 @@ int grayscale_to_ascii(const uint8_t *gray, const uint8_t *rgb, int src_w, edge_mode_t edge_mode = opts ? opts->edges : EDGE_OFF; int do_dither = opts ? opts->dither : 0; int thresh_limit = opts ? opts->threshold_val : 35; - render_mode_t render_mode = opts ? opts->render_mode : RENDER_BRAILLE; const char *ramp = (opts && opts->charset && opts->charset[0]) ? opts->charset : ASCII_CHARS_DEFAULT; diff --git a/C/src/main.c b/C/src/main.c index 0d96f41..1b68b23 100644 --- a/C/src/main.c +++ b/C/src/main.c @@ -238,7 +238,7 @@ int main(int argc, char *argv[]) { .dither = 0, .threshold_val = 35, .charset = NULL, - .render_mode = RENDER_BRAILLE, + .render_mode = RENDER_DOTS, // RENDER_BRAILLE, .depth_pop = 0, .depth_invert = 0, }; @@ -579,14 +579,6 @@ int main(int argc, char *argv[]) { break; } - size_t out_size = ascii_out_size_for_mode(subpixel_w, subpixel_h, - opts.color, opts.render_mode); - char *out_buf = malloc(out_size); - if (!out_buf) { - perror("Failed to allocate text output buffer"); - break; - } - // Process frame mapping using dynamically calculated bounds int len = grayscale_to_ascii(gray, rgb, cam.width, cam.height, subpixel_w, subpixel_h, out_buf, out_size, &opts); @@ -600,8 +592,6 @@ int main(int argc, char *argv[]) { selected, opts.color, &opts, &charsets); } - free(out_buf); - if (webcam_requeue_buffer(&cam) < 0) { perror("requeue_buffer"); break;