ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
lib/video/ascii/render/render.c
Go to the documentation of this file.
1#include <ascii-chat/common.h>
3#include "glyph.h"
4#include "luminance.h"
5
7 if (!options) {
8 SET_ERRNO(ERROR_INVALID_PARAM, "Missing ASCII rendering options");
9 return NULL;
10 }
11 const simd_cells_t *backend = options->backend ? options->backend : simd_cells_backend();
12 switch (options->kind) {
14 return ascii_luminance_render(image, options->palette, options->color, options->background, options->dither, backend);
16 return ascii_glyph_render(image, options->color, backend, options->palette, options->background);
17 }
18 SET_ERRNO(ERROR_INVALID_PARAM, "Unknown ASCII renderer");
19 return NULL;
20}
21
22bool ascii_render_palette_supported(ascii_renderer_t kind, const char *palette) {
23 if (kind == ASCII_RENDERER_GLYPH)
25 return kind == ASCII_RENDERER_LUMINANCE && palette && *palette;
26}
27
28char *ascii_render(const image_t *image, const char *palette, ascii_color_t color, bool background, bool dither, const simd_cells_t *ops) {
29 if (!ops) {
30 SET_ERRNO(ERROR_INVALID_PARAM, "Missing ASCII rendering backend");
31 return NULL;
32 }
33 const ascii_render_options_t options = {.kind = ASCII_RENDERER_LUMINANCE, .color = color, .palette = palette, .backend = ops, .background = background, .dither = dither};
34 return ascii_render_image(image, &options);
35}
36
37char *ascii_render_halfblocks(const uint8_t *rgb, int width, int height, int stride, ascii_color_t color, const simd_cells_t *ops) {
38 return ascii_luminance_halfblocks(rgb, width, height, stride, color, ops);
39}
#define SET_ERRNO(code,...)
const simd_cells_t * simd_cells_backend(void)
Definition cells.c:61
unsigned int height
Definition fft.c:24
unsigned int width
Definition fft.c:24
char * ascii_glyph_render(const image_t *image, ascii_color_t mode, const simd_cells_t *ops, const char *palette, bool background)
Definition glyph.c:198
bool ascii_glyph_palette_supported_impl(const char *palette)
Definition glyph.c:68
unsigned char uint8_t
@ ERROR_INVALID_PARAM
⚙️ Common definitions, error codes, macros, and types shared throughout the application
bool ascii_render_palette_supported(ascii_renderer_t kind, const char *palette)
char * ascii_render_image(const image_t *image, const ascii_render_options_t *options)
#define ascii_render
#define ascii_render_halfblocks
char * ascii_luminance_render(const image_t *image, const char *palette, ascii_color_t mode, bool background, bool dither, const simd_cells_t *ops)
char * ascii_luminance_halfblocks(const uint8_t *rgb, int width, int height, int stride, ascii_color_t mode, const simd_cells_t *ops)
SIMD-friendly storage for one RGB pixel. r, g, and b hold the color channels and padding keeps the la...
The useful part of simd cells is in luminance: together they describe what is pending,...
Definition cells.h:14