returns -1 if color not present, its index otherwise*/
| 3129 | |
| 3130 | /*returns -1 if color not present, its index otherwise*/ |
| 3131 | static 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 |
| 3142 | static int color_tree_has(ColorTree* tree, unsigned char r, unsigned char g, unsigned char b, unsigned char a) { |
no outgoing calls
no test coverage detected