MCPcopy Create free account
hub / github.com/HiLab-git/SimpleCRF / color_tree_add

Function color_tree_add

dependency/densecrf/examples/lodepng.cpp:3048–3063  ·  view source on GitHub ↗

color is not allowed to already exist. Index should be >= 0 (it's signed to be compatible with using -1 for "doesn't exist")*/

Source from the content-addressed store, hash-verified

3046/*color is not allowed to already exist.
3047 Index should be >= 0 (it's signed to be compatible with using -1 for "doesn't exist")*/
3048static void color_tree_add(ColorTree* tree,
3049 unsigned char r, unsigned char g, unsigned char b, unsigned char a, unsigned index)
3050{
3051 int bit;
3052 for(bit = 0; bit < 8; ++bit)
3053 {
3054 int i = 8 * ((r >> bit) & 1) + 4 * ((g >> bit) & 1) + 2 * ((b >> bit) & 1) + 1 * ((a >> bit) & 1);
3055 if(!tree->children[i])
3056 {
3057 tree->children[i] = (ColorTree*)lodepng_malloc(sizeof(ColorTree));
3058 color_tree_init(tree->children[i]);
3059 }
3060 tree = tree->children[i];
3061 }
3062 tree->index = (int)index;
3063}
3064
3065/*put a pixel, given its RGBA color, into image of any color type*/
3066static unsigned rgba8ToPixel(unsigned char* out, size_t i,

Callers 2

lodepng_convertFunction · 0.85

Calls 2

lodepng_mallocFunction · 0.85
color_tree_initFunction · 0.85

Tested by

no test coverage detected