BSB Developer Docs
Loading...
Searching...
No Matches
xpm.h
Go to the documentation of this file.
1
9#pragma once
10
11#include <stddef.h>
12#include <stdbool.h>
13
14#ifndef XPM_MAX_WIDTH
15#define XPM_MAX_WIDTH 1024u
16#endif /* XPM_MAX_WIDTH */
17
18#ifndef XPM_MAX_HEIGHT
19#define XPM_MAX_HEIGHT 1024u
20#endif /* XPM_MAX_HEIGHT */
21
22#ifndef XPM_MAX_COLORS_COUNT
23#define XPM_MAX_COLORS_COUNT 256u
24#endif /* XPM_MAX_COLORS_COUNT */
25
26#ifndef XPM_MAX_CHARS_PER_PIXEL
27#define XPM_MAX_CHARS_PER_PIXEL 10u
28#endif /* XPM_MAX_CHARS_PER_PIXEL */
29
33typedef struct Xpm Xpm;
34
38typedef struct {
39 unsigned int width;
40 unsigned int height;
41 unsigned int colors_count;
42 unsigned int chars_per_pixel;
44
50typedef enum {
53
54 XpmPixelFormatsCount,
56
64Xpm* xpm_alloc(const char* xpm_string);
65
71void xpm_free(Xpm* instance);
72
82bool xpm_decode_header(Xpm* instance);
83
91
102bool xpm_decode_colors(Xpm* instance);
103
116void* xpm_decode_pixels(Xpm* instance, XpmPixelFormat format, size_t* size);
Parsed XPM2 header (values line).
Definition xpm.h:38
unsigned int chars_per_pixel
Characters per pixel key.
Definition xpm.h:42
unsigned int colors_count
Number of color table entries.
Definition xpm.h:41
unsigned int width
Image width in pixels.
Definition xpm.h:39
unsigned int height
Image height in pixels.
Definition xpm.h:40
Definition xpm.c:21
bool xpm_decode_header(Xpm *instance)
Parse the XPM2 header.
Definition xpm.c:503
void xpm_free(Xpm *instance)
Free a decoder instance and all associated resources.
Definition xpm.c:496
Xpm * xpm_alloc(const char *xpm_string)
Create an XPM decoder instance.
Definition xpm.c:474
XpmHeaderData xpm_get_header_data(Xpm *instance)
Retrieve the parsed header data.
Definition xpm.c:561
XpmPixelFormat
Output pixel format.
Definition xpm.h:50
@ XpmPixelFormatLA88
2 bytes per pixel: luma, alpha.
Definition xpm.h:52
@ XpmPixelFormatBGRA8888
4 bytes per pixel: blue, green, red, alpha.
Definition xpm.h:51
bool xpm_decode_colors(Xpm *instance)
Parse the color table.
Definition xpm.c:568
void * xpm_decode_pixels(Xpm *instance, XpmPixelFormat format, size_t *size)
Compose pixel data for a given output format.
Definition xpm.c:596