blob: a831ef79f77be50a76bf092e923d562c4d621584 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
/* See LICENSE file for copyright and license details. */
#include "common.h"
void
libglitter_split_uint64_raster(uint16_t *rasters[3], uint16_t **alphap, uint64_t *raster,
uint64_t red, uint64_t green, uint64_t blue)
{
uint64_t alpha, map;
size_t position;
size_t channel;
alpha = ~(red | green | blue);
red /= 0xFF;
green /= 0xFF;
blue /= 0xFF;
alpha /= 0xFF;
red *= 0;
green *= 1;
blue *= 2;
alpha *= 3;
map = red | green | blue | alpha;
for (position = 0; position < 4; position++) {
channel = ((const unsigned char *)&map)[position * 2];
if (channel < 3)
rasters[channel] = &((uint16_t *)raster)[position];
else if (alphap)
*alphap = &((uint16_t *)raster)[position];
}
}
|