-
Notifications
You must be signed in to change notification settings - Fork 15
/
common.c
93 lines (84 loc) · 5.42 KB
/
common.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
*
* }: _、,r 、,,v \
* / \ 、,v'" ~ ゚~"''x、 \
* / 、r''" ,, 、,v、x。,, ~" 、,
* ...::::入,," ,,、イ: : : : : : : : :"'ミ、,
* ...::::/ y": : : : : : : : : :イ : : : : : : :"v '、
* } ....:::::イ /.: :/: : :/: :/ 八: : : : : : : : :\ ,"
* j / ,:': : : /: :/: / /: ハ: : }:\: : : : :´、, ォ
* 、'"~`"ゞ ,.: : : : : : : :イ≦" ̄'' 、;_:j : : : : : : : : トミ
* r" オ彡 {: : : {: : : Vfうか㍉ ル">ミ: : : : :!: !
* 、 ," 人: :八.: :从 ヒツ ん㍊: : : : : リ j
* ´、,, 、ノ'′ -‐:彡/: : : : :\ ヽ"" だン 从: : : イレ
* "¨ . . : : : : : : : : : : : {: : : : : :) ' `¨ ノ: :ノ: : :人ヽ
* /: /: : : / : : : :八: : : : :リ ` ー ー=彡:イ: : : : : : : :
* /: : : : : : : : : : : : イ: : :): : : : :| \ イ : : }: : : :}: :ハ: }
* ,': : : {: : : :厂¨¨<: 人: : : : : : : ! ー 爪: :i : : :} : : :ル: : :ソ
* {: : :八: > /: : : : : : : : リ {: : : i: : :r- < ¨¨ヽ: : .
* ..人: : / /: : : : : i: : : : :八 / 〉ミ: i: r┴ ヽ V: :\
* ソ /: : : : : : : i: : / ," \:.r-- 、 V: : : \
* /: :{ ,':ィ: /: : : /ノ/ ,, λ 、 ∨i: : : : : : .
* /:{ ル: : 彡" ≠===…-===彳 v´ ゝ冬。 : : : : : :
* . :∧ /: : :/" "s。 亥 ;" ヽミ Y: : : : : : :}
* .ノ: : 人 /: / { ドx。 。ζ 、 : :ハ Ⅳ: : : : :人
* : : : : : :У: ' 、 '; ≫≪゚゜ ; ;" }:^j i "、:ルイ: : \
* : : : : : (: :({ ;" ジ゚゜ .:: ヾ。," ", : ;"" 、, i "; :八: :}
* : :!: : :ハ:.入 v ;" .::::.. `; "、 人{、 "、,, )
* V{: : : : : ゝ j 、 ノ \ "; χ 〉"、,, ",、
* 、: : : Y¨¨≫> _) ,ж" ,,ゞ''::.. -‐ ".、 / "、,, "
* ヽ: :∧〃 ", π_゚≫=≦゚_ "、 V "、,, "、
* V ''、 ド¨ ¨=≧、,
* } y" "、,_ { }" ,"
* { ヽ ;i '`~え
* \、 ,'` ~ ", } ;"
* V \ ,,'` ~ ",
* ∧"'' 、_,、"~ ")彡' ;"
* j j==¨天⌒ミo。 、,,v '`"~ \ r'"
* ,,、'" 、。彳 ヾ 》'` "~ 、 ヽ、,v"
* / ,,r 、v~ "i{ 》添冬 ,, '` ~ "y
* r 、v~ "y 侔愛翔
* ,,^" 、,"^ \ ゞ趁彡' ,''` f"~
* 〈 r" )i ヽ ,,'` ,''`i
* j ..:::'′ ,、 '"|
* Y ",, ,,^ i 、 .) 、r~ ,、r~ j
* 彡ィ" `-ヽ_ゝ しY,`~ v "
* "、 、j ;i^ `~
* " ~| i| /
*
* Byakuren - A theme color extracting library implemented by C.
*
* Copyright (c) 2022 XadillaX <[email protected]>
*
* MIT LIcense <https://github.com/XadillaX/byakuren/blob/master/LICENSE>
*/
#include "common.h"
extern int _bkr_init_octree_env();
extern void _bkr_destroy_octree_env();
xmem_pool_handle bkr_rgb_pool = 0;
int bkr_init()
{
if(!bkr_rgb_pool)
{
bkr_rgb_pool = xmem_create_pool(sizeof(bkr_rgb));
}
if(!bkr_rgb_pool) return 0;
if(!_bkr_init_octree_env())
{
return 0;
}
return 1;
}
void bkr_destroy()
{
SAFE_DESTROY_POOL(bkr_rgb_pool);
_bkr_destroy_octree_env();
}
int _stats_cmp(const void* a, const void* b)
{
if(((bkr_color_stats*)a)->count != ((bkr_color_stats*)b)->count)
{
return -(((bkr_color_stats*)a)->count - ((bkr_color_stats*)b)->count);
}
return -(((bkr_color_stats*)a)->value - ((bkr_color_stats*)b)->value);
}