color is not allowed to already exist. Index should be >= 0 (it's signed to be compatible with using -1 for "doesn't exist")*/
| 2962 | /*color is not allowed to already exist. |
| 2963 | Index should be >= 0 (it's signed to be compatible with using -1 for "doesn't exist")*/ |
| 2964 | static void color_tree_add(ColorTree* tree, |
| 2965 | unsigned char r, unsigned char g, unsigned char b, unsigned char a, int index) |
| 2966 | { |
| 2967 | int bit; |
| 2968 | for(bit = 0; bit < 8; bit++) |
| 2969 | { |
| 2970 | int i = 8 * ((r >> bit) & 1) + 4 * ((g >> bit) & 1) + 2 * ((b >> bit) & 1) + 1 * ((a >> bit) & 1); |
| 2971 | if(!tree->children[i]) |
| 2972 | { |
| 2973 | tree->children[i] = (ColorTree*)lodepng_malloc(sizeof(ColorTree)); |
| 2974 | color_tree_init(tree->children[i]); |
| 2975 | } |
| 2976 | tree = tree->children[i]; |
| 2977 | } |
| 2978 | tree->index = index; |
| 2979 | } |
| 2980 | |
| 2981 | /*put a pixel, given its RGBA color, into image of any color type*/ |
| 2982 | static unsigned rgba8ToPixel(unsigned char* out, size_t i, |
no test coverage detected