Byakuren 1.0.1
A theme color extracting library implemented by C.
Loading...
Searching...
No Matches
bkr_common.h
Go to the documentation of this file.
1
8#ifndef BKR_COMMON_H_
9#define BKR_COMMON_H_
10#include <stdint.h>
11#include <stdio.h>
12#include <stdlib.h>
13
14#include "third-party/xmempool/xmempool.h"
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
23#define BKR_VERSION "1.0.1"
24
25#ifndef NULL
26#define NULL (0)
27#endif
28
35#define SAFE_DESTROY_POOL(pool) \
36 if (pool) { \
37 xmem_destroy_pool(pool); \
38 pool = NULL; \
39 }
40
47#define SAFE_FREE(pointer) \
48 if (pointer) { \
49 free(pointer); \
50 pointer = NULL; \
51 }
52
56#define MAX_INT (2147483647)
57
61#define BKR_RGB_TO_INT32(r, g, b) (((r) << 16) + ((g) << 8) + (b))
62
67#define DIFF_A_B_GTE_OFFSET(item, a, b, offset) \
68 (abs((item)->a - (item)->b) <= offset)
69
70#define BKR_IS_GRAY_INNER(item, offset) \
71 DIFF_A_B_GTE_OFFSET(item, red, green, offset) && \
72 DIFF_A_B_GTE_OFFSET(item, red, blue, offset) && \
73 DIFF_A_B_GTE_OFFSET(item, green, blue, offset)
74
81#define BKR_IS_GRAY(item, offset) (BKR_IS_GRAY_INNER(item, offset))
82
90typedef struct bkr_rgb {
91 uint8_t red;
92 uint8_t green;
93 uint8_t blue;
95
108
126
138
149
160
171extern xmem_pool_handle bkr_rgb_pool;
172
185extern int bkr_init();
186
196extern void bkr_destroy();
197
213extern int _stats_cmp(const void* a, const void* b);
214
215#ifdef __cplusplus
216}
217#endif
218
219#endif // BKR_COMMON_H_
int bkr_init()
Initialize the Byakuren library.
int _stats_cmp(const void *a, const void *b)
Comparison function for sorting color statistics.
struct bkr_octree_node bkr_octree_node
Octree node structure for color quantization.
struct bkr_palette_array bkr_palette_array
Color palette array structure.
xmem_pool_handle bkr_rgb_pool
Memory pool handle for RGB color structures.
struct bkr_mindiff_parameter bkr_mindiff_parameter
Parameters for the minimum difference color quantization method.
struct bkr_rgb bkr_rgb
RGB color structure.
struct bkr_octree_reducible_list_node bkr_octree_reducible_list_node
Reducible list node structure for octree color quantization.
void bkr_destroy()
Clean up and release resources used by the Byakuren library.
struct bkr_color_stats bkr_color_stats
Color statistics structure.
Color statistics structure.
Definition bkr_common.h:103
bkr_rgb color
RGB color values.
Definition bkr_common.h:104
uint32_t value
32-bit integer representation of the color
Definition bkr_common.h:105
uint32_t count
Frequency count of the color.
Definition bkr_common.h:106
Parameters for the minimum difference color quantization method.
Definition bkr_common.h:156
bkr_palette_array * palette
Pointer to a custom color palette.
Definition bkr_common.h:157
int16_t gray_offset
Offset for determining grayscale colors.
Definition bkr_common.h:158
Octree node structure for color quantization.
Definition bkr_common.h:116
uint32_t pixel_count
Number of pixels represented by this node.
Definition bkr_common.h:122
uint32_t blue_components
Sum of blue components.
Definition bkr_common.h:119
uint32_t green_components
Sum of green components.
Definition bkr_common.h:118
uint8_t is_leaf
Flag indicating if this node is a leaf.
Definition bkr_common.h:121
uint32_t red_components
Sum of red components.
Definition bkr_common.h:117
struct bkr_octree_node * children[8]
Pointers to child nodes.
Definition bkr_common.h:124
Reducible list node structure for octree color quantization.
Definition bkr_common.h:133
struct bkr_octree_reducible_list_node * next
Pointer to the next list node.
Definition bkr_common.h:135
struct bkr_octree_node * node
Pointer to the octree node.
Definition bkr_common.h:134
Color palette array structure.
Definition bkr_common.h:145
bkr_rgb * colors
Pointer to an array of RGB colors.
Definition bkr_common.h:147
uint32_t count
Number of colors in the palette.
Definition bkr_common.h:146
RGB color structure.
Definition bkr_common.h:90
uint8_t red
Red component of the color (0-255)
Definition bkr_common.h:91
uint8_t blue
Blue component of the color (0-255)
Definition bkr_common.h:93
uint8_t green
Green component of the color (0-255)
Definition bkr_common.h:92