MCPcopy Index your code
hub / github.com/ImageOptim/libimagequant / test_histogram

Function test_histogram

imagequant-sys/c_test/test.c:58–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58static void test_histogram() {
59 liq_attr *attr = liq_attr_create();
60 liq_histogram *hist = liq_histogram_create(attr);
61 assert(hist);
62
63 const unsigned char dummy1[4] = {255,0,255,255};
64 liq_image *const img1 = liq_image_create_rgba(attr, dummy1, 1, 1, 0);
65 assert(img1);
66
67 const liq_error err1 = liq_histogram_add_image(hist, attr, img1);
68 assert(LIQ_OK == err1);
69
70 const unsigned char dummy2[4] = {0,0,0,0};
71 liq_image *const img2 = liq_image_create_rgba(attr, dummy2, 1, 1, 0);
72 assert(img2);
73 liq_image_add_fixed_color(img2, (liq_color){255,255,255,255});
74
75
76 const liq_error err2 = liq_histogram_add_image(hist, attr, img2);
77 assert(LIQ_OK == err2);
78
79 liq_image_destroy(img1);
80 liq_image_destroy(img2);
81
82 liq_result *res;
83 liq_error err = liq_histogram_quantize(hist, attr, &res);
84 assert(LIQ_OK == err);
85 assert(res);
86
87 liq_attr_destroy(attr);
88
89 liq_histogram_destroy(hist);
90
91 const liq_palette *pal = liq_get_palette(res);
92 assert(pal);
93 assert(pal->count == 3);
94
95 liq_result_destroy(res);
96}
97
98static void test_fixed_colors() {
99 liq_attr *attr = liq_attr_create();

Callers 1

run_liq_testsFunction · 0.85

Calls 11

liq_attr_createFunction · 0.85
liq_histogram_createFunction · 0.85
liq_image_create_rgbaFunction · 0.85
liq_histogram_add_imageFunction · 0.85
liq_image_destroyFunction · 0.85
liq_histogram_quantizeFunction · 0.85
liq_attr_destroyFunction · 0.85
liq_histogram_destroyFunction · 0.85
liq_get_paletteFunction · 0.85
liq_result_destroyFunction · 0.85

Tested by

no test coverage detected