diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
| commit | 37da2899f40661e3e9631e497da8dc59b971cbd0 (patch) | |
| tree | cbc6d4680e347d906f5fa7fca73214418741df72 /libdraw/readcolmap.c | |
| parent | 54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff) | |
20060303a
Diffstat (limited to 'libdraw/readcolmap.c')
| -rw-r--r-- | libdraw/readcolmap.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/libdraw/readcolmap.c b/libdraw/readcolmap.c new file mode 100644 index 00000000..6bae5a24 --- /dev/null +++ b/libdraw/readcolmap.c @@ -0,0 +1,46 @@ +#include "lib9.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]; + + 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) { + _drawprint(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); +} |
