color is not allowed to already exist. Index should be >= 0 (it's signed to be compatible with using -1 for "doesn't exist")*/
| 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")*/ |
| 3048 | static 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*/ |
| 3066 | static unsigned rgba8ToPixel(unsigned char* out, size_t i, |
no test coverage detected