ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
render.c File Reference

Go to the source code of this file.

Functions

char * ascii_render_image (const image_t *image, const ascii_render_options_t *options)
bool ascii_render_palette_supported (ascii_renderer_t kind, const char *palette)
char * ascii_render (const image_t *image, const char *palette, ascii_color_t color, bool background, bool dither, const simd_cells_t *ops)
char * ascii_render_halfblocks (const uint8_t *rgb, int width, int height, int stride, ascii_color_t color, const simd_cells_t *ops)

Function Documentation

◆ ascii_render()

char * ascii_render ( const image_t * image,
const char * palette,
ascii_color_t color,
bool background,
bool dither,
const simd_cells_t * ops )

Definition at line 28 of file lib/video/ascii/render/render.c.

28 {
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}
#define SET_ERRNO(code,...)
@ ERROR_INVALID_PARAM
char * ascii_render_image(const image_t *image, const ascii_render_options_t *options)
SIMD-friendly storage for one RGB pixel. r, g, and b hold the color channels and padding keeps the la...

References ascii_render_image(), ASCII_RENDERER_LUMINANCE, ERROR_INVALID_PARAM, and SET_ERRNO.

◆ ascii_render_halfblocks()

char * ascii_render_halfblocks ( const uint8_t * rgb,
int width,
int height,
int stride_bytes,
ascii_color_t color,
const simd_cells_t * ops )

Two source rows per terminal row; the supplied backend processes both rows.

Definition at line 37 of file lib/video/ascii/render/render.c.

37 {
38 return ascii_luminance_halfblocks(rgb, width, height, stride, color, ops);
39}
unsigned int height
Definition fft.c:24
unsigned int width
Definition fft.c:24
char * ascii_luminance_halfblocks(const uint8_t *rgb, int width, int height, int stride, ascii_color_t mode, const simd_cells_t *ops)

References ascii_luminance_halfblocks(), height, and width.

◆ ascii_render_image()

char * ascii_render_image ( const image_t * image,
const ascii_render_options_t * options )

Render an image using the chosen renderer. The caller frees the returned text. Luminance maps one input pixel to one terminal cell. Glyph matching consumes an 8×8 pixel region per cell and requires both image dimensions to be positive multiples of eight. Callers select and scale the input to their desired cell dimensions before calling this function.

Definition at line 6 of file lib/video/ascii/render/render.c.

6 {
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}
const simd_cells_t * simd_cells_backend(void)
Definition cells.c:61
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
char * ascii_luminance_render(const image_t *image, const char *palette, ascii_color_t mode, bool background, bool dither, const simd_cells_t *ops)
The useful part of simd cells is in luminance: together they describe what is pending,...
Definition cells.h:14

References ascii_glyph_render(), ascii_luminance_render(), ASCII_RENDERER_GLYPH, ASCII_RENDERER_LUMINANCE, ascii_render_options_t::backend, ascii_render_options_t::background, ascii_render_options_t::color, ascii_render_options_t::dither, ERROR_INVALID_PARAM, ascii_render_options_t::kind, ascii_render_options_t::palette, SET_ERRNO, and simd_cells_backend().

Referenced by ascii_convert_with_buffers_stabilized(), and ascii_render().

◆ ascii_render_palette_supported()

bool ascii_render_palette_supported ( ascii_renderer_t kind,
const char * palette )

Check whether a renderer accepts a nonempty palette.

Definition at line 22 of file lib/video/ascii/render/render.c.

22 {
23 if (kind == ASCII_RENDERER_GLYPH)
25 return kind == ASCII_RENDERER_LUMINANCE && palette && *palette;
26}
bool ascii_glyph_palette_supported_impl(const char *palette)
Definition glyph.c:68

References ascii_glyph_palette_supported_impl(), ASCII_RENDERER_GLYPH, and ASCII_RENDERER_LUMINANCE.

Referenced by acip_render_settings_prepare(), ascii_convert_with_buffers_stabilized(), mirror_convert_frame(), and validate_glyph_palette().