MCPcopy Create free account
hub / github.com/DFHack/dfhack / color_tree_get

Function color_tree_get

depends/lodepng/lodepng.cpp:3131–3139  ·  view source on GitHub ↗

returns -1 if color not present, its index otherwise*/

Source from the content-addressed store, hash-verified

3129
3130/*returns -1 if color not present, its index otherwise*/
3131static int color_tree_get(ColorTree* tree, unsigned char r, unsigned char g, unsigned char b, unsigned char a) {
3132 int bit = 0;
3133 for(bit = 0; bit < 8; ++bit) {
3134 int i = 8 * ((r >> bit) & 1) + 4 * ((g >> bit) & 1) + 2 * ((b >> bit) & 1) + 1 * ((a >> bit) & 1);
3135 if(!tree->children[i]) return -1;
3136 else tree = tree->children[i];
3137 }
3138 return tree ? tree->index : -1;
3139}
3140
3141#ifdef LODEPNG_COMPILE_ENCODER
3142static int color_tree_has(ColorTree* tree, unsigned char r, unsigned char g, unsigned char b, unsigned char a) {

Callers 2

color_tree_hasFunction · 0.85
rgba8ToPixelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected