14#include "third-party/xmempool/xmempool.h"
23#define BKR_VERSION "1.0.1"
35#define SAFE_DESTROY_POOL(pool) \
37 xmem_destroy_pool(pool); \
47#define SAFE_FREE(pointer) \
56#define MAX_INT (2147483647)
61#define BKR_RGB_TO_INT32(r, g, b) (((r) << 16) + ((g) << 8) + (b))
67#define DIFF_A_B_GTE_OFFSET(item, a, b, offset) \
68 (abs((item)->a - (item)->b) <= offset)
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)
81#define BKR_IS_GRAY(item, offset) (BKR_IS_GRAY_INNER(item, offset))
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.
bkr_rgb color
RGB color values.
uint32_t value
32-bit integer representation of the color
uint32_t count
Frequency count of the color.
Parameters for the minimum difference color quantization method.
bkr_palette_array * palette
Pointer to a custom color palette.
int16_t gray_offset
Offset for determining grayscale colors.
Octree node structure for color quantization.
uint32_t pixel_count
Number of pixels represented by this node.
uint32_t blue_components
Sum of blue components.
uint32_t green_components
Sum of green components.
uint8_t is_leaf
Flag indicating if this node is a leaf.
uint32_t red_components
Sum of red components.
struct bkr_octree_node * children[8]
Pointers to child nodes.
Reducible list node structure for octree color quantization.
struct bkr_octree_reducible_list_node * next
Pointer to the next list node.
struct bkr_octree_node * node
Pointer to the octree node.
Color palette array structure.
bkr_rgb * colors
Pointer to an array of RGB colors.
uint32_t count
Number of colors in the palette.
uint8_t red
Red component of the color (0-255)
uint8_t blue
Blue component of the color (0-255)
uint8_t green
Green component of the color (0-255)