blob: 6eb8ee26ecf7cb47e2a5a0dc81ec408fee39e89a (
plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <bio.h>
static ulong
getval(char **p)
{
ulong v;
char *q;
v = strtoul(*p, &q, 0);
v |= v<<8;
v |= v<<16;
*p = q;
return v;
}
void
readcolmap(Display *d, RGB *colmap)
{
int i;
char *p, *q;
Biobuf *b;
char buf[128];
USED(screen);
sprint(buf, "/dev/draw/%d/colormap", d->dirno);
b = Bopen(buf, OREAD);
if(b == 0)
drawerror(d, "rdcolmap: can't open colormap device");
for(;;) {
p = Brdline(b, '\n');
if(p == 0)
break;
i = strtoul(p, &q, 0);
if(i < 0 || i > 255) {
fprint(2, "rdcolmap: bad index\n");
exits("bad");
}
p = q;
colmap[255-i].red = getval(&p);
colmap[255-i].green = getval(&p);
colmap[255-i].blue = getval(&p);
}
Bterm(b);
}
|