Byakuren 1.0.1
A theme color extracting library implemented by C.
|
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "third-party/xmempool/xmempool.h"
Go to the source code of this file.
Data Structures | |
struct | bkr_rgb |
RGB color structure. More... | |
struct | bkr_color_stats |
Color statistics structure. More... | |
struct | bkr_octree_node |
Octree node structure for color quantization. More... | |
struct | bkr_octree_reducible_list_node |
Reducible list node structure for octree color quantization. More... | |
struct | bkr_palette_array |
Color palette array structure. More... | |
struct | bkr_mindiff_parameter |
Parameters for the minimum difference color quantization method. More... | |
Macros | |
#define | BKR_VERSION "1.0.1" |
Byakuren - A theme color extracting library implemented by C. | |
#define | NULL (0) |
#define | SAFE_DESTROY_POOL(pool) |
Safely destroy a memory pool. | |
#define | SAFE_FREE(pointer) |
Safely free allocated memory. | |
#define | MAX_INT (2147483647) |
Maximum value for a 32-bit signed integer. | |
#define | BKR_RGB_TO_INT32(r, g, b) |
Convert RGB values to a 32-bit integer representation. | |
#define | DIFF_A_B_GTE_OFFSET(item, a, b, offset) |
Check if the difference between two color components is within a given offset. | |
#define | BKR_IS_GRAY_INNER(item, offset) |
#define | BKR_IS_GRAY(item, offset) |
Check if a color is considered grayscale based on a given offset. | |
Typedefs | |
typedef struct bkr_rgb | bkr_rgb |
RGB color structure. | |
typedef struct bkr_color_stats | bkr_color_stats |
Color statistics structure. | |
typedef struct bkr_octree_node | bkr_octree_node |
Octree node structure for color quantization. | |
typedef struct bkr_octree_reducible_list_node | bkr_octree_reducible_list_node |
Reducible list node structure for octree color quantization. | |
typedef struct bkr_palette_array | bkr_palette_array |
Color palette array structure. | |
typedef struct bkr_mindiff_parameter | bkr_mindiff_parameter |
Parameters for the minimum difference color quantization method. | |
Functions | |
int | bkr_init () |
Initialize the Byakuren library. | |
void | bkr_destroy () |
Clean up and release resources used by the Byakuren library. | |
int | _stats_cmp (const void *a, const void *b) |
Comparison function for sorting color statistics. | |
Variables | |
xmem_pool_handle | bkr_rgb_pool |
Memory pool handle for RGB color structures. | |
#define BKR_IS_GRAY | ( | item, | |
offset ) |
Check if a color is considered grayscale based on a given offset.
This macro checks if the differences between red, green, and blue components are all within the specified offset.
Definition at line 81 of file bkr_common.h.
#define BKR_IS_GRAY_INNER | ( | item, | |
offset ) |
Definition at line 70 of file bkr_common.h.
#define BKR_RGB_TO_INT32 | ( | r, | |
g, | |||
b ) |
Convert RGB values to a 32-bit integer representation.
Definition at line 61 of file bkr_common.h.
#define BKR_VERSION "1.0.1" |
Byakuren - A theme color extracting library implemented by C.
Copyright (c) 2024 XadillaX i@233.nosp@m.3.mo.nosp@m.e
MIT License https://github.com/XadillaX/byakuren/blob/master/LICENSE
Version string of the Byakuren library.
Definition at line 23 of file bkr_common.h.
#define DIFF_A_B_GTE_OFFSET | ( | item, | |
a, | |||
b, | |||
offset ) |
Check if the difference between two color components is within a given offset.
Definition at line 67 of file bkr_common.h.
#define MAX_INT (2147483647) |
Maximum value for a 32-bit signed integer.
Definition at line 56 of file bkr_common.h.
#define NULL (0) |
Definition at line 26 of file bkr_common.h.
#define SAFE_DESTROY_POOL | ( | pool | ) |
Safely destroy a memory pool.
This macro checks if the pool exists before destroying it and sets the pointer to NULL afterwards.
Definition at line 35 of file bkr_common.h.
#define SAFE_FREE | ( | pointer | ) |
Safely free allocated memory.
This macro checks if the pointer is not NULL before freeing it and sets the pointer to NULL afterwards.
Definition at line 47 of file bkr_common.h.
typedef struct bkr_color_stats bkr_color_stats |
Color statistics structure.
This structure holds information about a specific color, including its RGB values, a 32-bit integer representation, and its frequency count. It is used to store results of color analysis operations.
typedef struct bkr_mindiff_parameter bkr_mindiff_parameter |
Parameters for the minimum difference color quantization method.
This structure holds parameters used in the minimum difference method for color quantization, including a custom palette and grayscale offset.
typedef struct bkr_octree_node bkr_octree_node |
Octree node structure for color quantization.
This structure represents a node in the octree used for color quantization. It stores color component sums, leaf status, pixel count, and pointers to child nodes.
typedef struct bkr_octree_reducible_list_node bkr_octree_reducible_list_node |
Reducible list node structure for octree color quantization.
This structure is used to maintain a list of reducible nodes in the octree. It is part of the mechanism for merging nodes during color reduction.
typedef struct bkr_palette_array bkr_palette_array |
Color palette array structure.
This structure represents a color palette, containing a count of colors and a pointer to an array of RGB color structures.
typedef struct bkr_rgb bkr_rgb |
RGB color structure.
This structure represents a color in the RGB color space. Each component (red, green, blue) is an 8-bit unsigned integer, allowing for 256 levels of intensity for each color channel.
|
extern |
Comparison function for sorting color statistics.
This function is used as a comparator for qsort to sort bkr_color_stats structures.
It first compares the count of colors, sorting in descending order. If the counts are equal, it then compares the color values, also in descending order.
a | Pointer to the first color statistic to compare. |
b | Pointer to the second color statistic to compare. |
|
extern |
Clean up and release resources used by the Byakuren library.
This function destroys the memory pools and frees any allocated resources.
It should be called when the Byakuren library is no longer needed to prevent memory leaks and ensure proper cleanup of resources.
|
extern |
Initialize the Byakuren library.
This function initializes the necessary resources for the Byakuren library.
It creates a memory pool for RGB color structures and initializes the octree environment. This function should be called before using any other Byakuren library functions.
|
extern |
Memory pool handle for RGB color structures.
This global variable holds the handle to a memory pool used for allocating bkr_rgb structures. It improves memory allocation efficiency for frequently used RGB color objects.