Byakuren 1.0.1
A theme color extracting library implemented by C.
|
#include "../bkr_common.h"
Go to the source code of this file.
Functions | |
bkr_octree_node * | bkr_build_octree (bkr_rgb *pixels, uint32_t pixel_count, uint32_t max_colors) |
Byakuren - A theme color extracting library implemented by C. | |
void | bkr_release_octree (bkr_octree_node *node) |
Releases the memory allocated for an octree structure. | |
int | bkr_octree_calculate_color_stats (bkr_octree_node *node, bkr_color_stats stats[]) |
Calculates color statistics from a built octree. | |
|
extern |
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
Builds an octree color quantization structure from an array of pixels.
This function constructs an octree representation of the color space for the given pixel array. The octree is used to efficiently quantize colors and reduce the color palette to a specified maximum number of colors.
The octree is built by iteratively adding colors and reducing the tree when necessary to maintain the maximum color limit. This process involves creating new nodes, updating leaf counts, and merging nodes when the tree exceeds the specified size.
pixels | Pointer to an array of bkr_rgb structures representing the input pixels. |
pixel_count | The number of pixels in the input array. |
max_colors | The maximum number of colors allowed in the final quantized palette. |
|
extern |
Calculates color statistics from a built octree.
This function traverses the octree structure and computes color statistics for each leaf node. It aggregates information such as color values and pixel counts, providing a summary of the quantized color palette.
The function performs the following steps:
node | Pointer to the root node of the octree to analyze. |
stats | Pointer to an array of bkr_color_stats structures where the results will be stored. |
|
extern |
Releases the memory allocated for an octree structure.
This function recursively frees all memory associated with the given octree, including all its child nodes. It should be called when the octree is no longer needed to prevent memory leaks.
The function traverses the entire tree structure, freeing each node in a depth-first manner. After calling this function, the passed node pointer and all its children become invalid and should not be accessed.
node | Pointer to the root node of the octree to be released. |