color is not allowed to already exist. Index should be >= 0 (it's signed to be compatible with using -1 for "doesn't exist") Returns error code, or 0 if ok*/
| 3148 | Index should be >= 0 (it's signed to be compatible with using -1 for "doesn't exist") |
| 3149 | Returns error code, or 0 if ok*/ |
| 3150 | static unsigned color_tree_add(ColorTree* tree, |
| 3151 | unsigned char r, unsigned char g, unsigned char b, unsigned char a, unsigned index) { |
| 3152 | int bit; |
| 3153 | for(bit = 0; bit < 8; ++bit) { |
| 3154 | int i = 8 * ((r >> bit) & 1) + 4 * ((g >> bit) & 1) + 2 * ((b >> bit) & 1) + 1 * ((a >> bit) & 1); |
| 3155 | if(!tree->children[i]) { |
| 3156 | tree->children[i] = (ColorTree*)lodepng_malloc(sizeof(ColorTree)); |
| 3157 | if(!tree->children[i]) return 83; /*alloc fail*/ |
| 3158 | color_tree_init(tree->children[i]); |
| 3159 | } |
| 3160 | tree = tree->children[i]; |
| 3161 | } |
| 3162 | tree->index = (int)index; |
| 3163 | return 0; |
| 3164 | } |
| 3165 | |
| 3166 | /*put a pixel, given its RGBA color, into image of any color type*/ |
| 3167 | static unsigned rgba8ToPixel(unsigned char* out, size_t i, |
no test coverage detected