ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
video/rgba/image.h
Go to the documentation of this file.
1#pragma once
2
52#ifdef _WIN32
53#pragma pack(push, 1)
54#endif
55
56#include <stdio.h>
57#include <stdlib.h>
58#include <stdint.h>
59
61#include <ascii-chat/common.h>
62
63/* ============================================================================
64 * Data Structures
65 * ============================================================================
66 */
67
86
108
122
149
150/* ============================================================================
151 * Image Size Constants
152 * ============================================================================
153 */
154
166#define IMAGE_MAX_WIDTH 3840
167
179#define IMAGE_MAX_HEIGHT 2160
180
193#define IMAGE_MAX_PIXELS_SIZE (IMAGE_MAX_WIDTH * IMAGE_MAX_HEIGHT * sizeof(rgb_pixel_t))
194
195/* ============================================================================
196 * Image Allocation and Management Functions
197 * @{
198 */
199
206asciichat_error_t image_render_test_pattern(image_t *image, unsigned int *frame_counter);
207
233image_t *image_new(size_t width, size_t height);
234
249void image_destroy(image_t *p);
250
277image_t *image_new_from_pool(size_t width, size_t height);
278
293void image_destroy_to_pool(image_t *image);
294
307void image_clear(image_t *p);
308
326image_t *image_new_copy(const image_t *source);
327
330/* ============================================================================
331 * ASCII Conversion Functions
332 * @{
333 */
334
352char *image_print(const image_t *p, const char *palette);
353
372char *image_print_color(const image_t *p, const char *palette);
373
374/* ============================================================================
375 * Capability-Aware ASCII Conversion Functions
376 * @{
377 */
378
379// Capability-aware image printing functions
381
407char *image_print_with_capabilities(const image_t *image, const terminal_capabilities_t *caps, const char *palette);
408
426char *image_print_256color(const image_t *image, const char *palette);
427
445char *image_print_16color(const image_t *image, const char *palette);
446
470char *image_print_16color_dithered(const image_t *image, const char *palette);
471
496char *image_print_16color_dithered_with_background(const image_t *image, bool use_background, const char *palette);
497
500/* ============================================================================
501 * Color Processing Functions
502 * @{
503 */
504
528void quantize_color(int *r, int *g, int *b, int levels);
529
552void precalc_rgb_palettes(const float red, const float green, const float blue);
553
556/* ============================================================================
557 * Image Resizing Functions
558 * @{
559 */
560
582void image_resize(const image_t *source, image_t *dest);
583
605void image_resize_interpolation(const image_t *source, image_t *dest);
606
609/* ============================================================================
610 * ANSI Color Code Generation Functions
611 * @{
612 */
613
632char *rgb_to_ansi_fg(int r, int g, int b);
633
652char *rgb_to_ansi_bg(int r, int g, int b);
653
678void rgb_to_ansi_8bit(int r, int g, int b, int *fg_code, int *bg_code);
679
682#ifdef _WIN32
683#pragma pack(pop)
684#endif
Platform abstraction layer umbrella header providing unified cross-platform API.
⚙️ Common definitions, error codes, macros, and types shared throughout the application
unsigned char uint8_t
Definition common.h:56
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:49
#define ALIGNED_ATTR(x)
Memory alignment attribute (POSIX: attribute((aligned)))
#define PACKED_ATTR
Packed structure attribute (POSIX: attribute((packed)))
image_t * image_new_copy(const image_t *source)
Create a copy of an existing image.
void quantize_color(int *r, int *g, int *b, int levels)
Quantize color to specified number of levels.
Definition foreground.c:140
void precalc_rgb_palettes(const float red, const float green, const float blue)
Precalculate RGB palettes with color adjustment.
void image_resize_interpolation(const image_t *source, image_t *dest)
Resize image using bilinear interpolation.
char * image_print_16color_dithered(const image_t *image, const char *palette)
Print image using 16-color ANSI mode with dithering.
Definition foreground.c:646
char * image_print(const image_t *p, const char *palette)
Print image as ASCII art (monochrome)
Definition foreground.c:27
char * image_print_with_capabilities(const image_t *image, const terminal_capabilities_t *caps, const char *palette)
Convert image to ASCII art with terminal capabilities.
Definition ascii.c:978
void image_destroy_to_pool(image_t *image)
Destroy an image allocated from buffer pool.
char * image_print_color(const image_t *p, const char *palette)
Print image as ASCII art with color.
Definition foreground.c:194
char * rgb_to_ansi_bg(int r, int g, int b)
Convert RGB to ANSI background color code.
Definition foreground.c:375
void rgb_to_ansi_8bit(int r, int g, int b, int *fg_code, int *bg_code)
Convert RGB to 8-bit ANSI color codes.
Definition foreground.c:381
image_alloc_method_t
Pixel allocation method tracking.
char * image_print_16color(const image_t *image, const char *palette)
Print image using 16-color ANSI mode.
Definition foreground.c:533
asciichat_error_t image_render_test_pattern(image_t *image, unsigned int *frame_counter)
Render animated color bars and grid lines into an existing image.
char * rgb_to_ansi_fg(int r, int g, int b)
Convert RGB to ANSI foreground color code.
Definition foreground.c:369
void image_clear(image_t *p)
Clear image (set all pixels to black)
void image_resize(const image_t *source, image_t *dest)
Resize image using nearest-neighbor interpolation.
char * image_print_16color_dithered_with_background(const image_t *image, bool use_background, const char *palette)
Print image using 16-color ANSI mode with dithering and background colors.
Definition foreground.c:746
char * image_print_256color(const image_t *image, const char *palette)
Print image using 256-color ANSI mode.
Definition foreground.c:431
image_t * image_new_from_pool(size_t width, size_t height)
Create a new image from buffer pool.
void image_destroy(image_t *p)
Destroy an image allocated with image_new()
image_t * image_new(size_t width, size_t height)
Create a new image with standard allocation.
@ IMAGE_ALLOC_POOL
Pixels allocated with buffer_pool_alloc()
@ IMAGE_ALLOC_SIMD
Pixels allocated with SAFE_MALLOC_SIMD()
Image structure.
int w
Image width in pixels (must be > 0)
uint8_t alloc_method
Allocation method (image_alloc_method_t) for correct deallocation.
int h
Image height in pixels (must be > 0)
rgb_pixel_t * pixels
Pixel data array (width * height RGB pixels, row-major order)
SIMD-aligned RGB pixel structure for optimal NEON/AVX performance.
uint8_t r
Red color component (0-255)
uint8_t g
Green color component (0-255)
uint8_t padding
Padding byte to align to 4-byte boundary (SIMD alignment)
uint8_t b
Blue color component (0-255)
RGB pixel structure.
uint8_t b
Blue color component (0-255)
uint8_t g
Green color component (0-255)
uint8_t r
Red color component (0-255)
Complete terminal capabilities structure.
Definition terminal.h:709
🖥️ Cross-platform terminal interface for ascii-chat