Byakuren 1.0.1
A theme color extracting library implemented by C.
Loading...
Searching...
No Matches
mindiff.h File Reference
#include "../bkr_common.h"

Go to the source code of this file.

Data Structures

struct  _bkr_palette_stats
 Byakuren - A theme color extracting library implemented by C. More...
 

Typedefs

typedef struct _bkr_palette_stats _bkr_palette_stats
 Byakuren - A theme color extracting library implemented by C.
 

Functions

int bkr_mindiff_calculate_color_stats (bkr_rgb *pixels, uint32_t pixel_count, bkr_color_stats stats[], bkr_mindiff_parameter *param)
 Calculate color statistics using the minimum difference method.
 

Typedef Documentation

◆ _bkr_palette_stats

typedef struct _bkr_palette_stats _bkr_palette_stats

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

Color palette statistics structure.

This structure is used to store information about a color in the palette and its frequency of occurrence in the image being processed.

Function Documentation

◆ bkr_mindiff_calculate_color_stats()

int bkr_mindiff_calculate_color_stats ( bkr_rgb * pixels,
uint32_t pixel_count,
bkr_color_stats stats[],
bkr_mindiff_parameter * param )
extern

Calculate color statistics using the minimum difference method.

This function processes an array of pixels and calculates color statistics based on a given or default color palette. It uses the minimum difference method to map each pixel to the closest color in the palette.

The function separates colors into colored and grayscale palettes based on the gray_offset parameter. It then processes each pixel, finding the closest color in the appropriate palette, and updates the count for that color.

After processing all pixels, it compiles the final color statistics, including only colors with non-zero counts, and sorts them for consistent output.

Parameters
pixelsPointer to an array of bkr_rgb structures representing the pixels to process.
pixel_countThe number of pixels in the pixels array.
statsPointer to an array of bkr_color_stats structures where the results will be stored.
paramPointer to a bkr_mindiff_parameter structure containing processing parameters.
Returns
The number of unique colors found in the statistics, or -1 if an error occurred.