Last change
on this file since 68 was
68,
checked in by cbipsl, 14 years ago
|
commit v1 eccad
|
-
Property svn:eol-style set to
native
-
Property svn:executable set to
*
|
File size:
964 bytes
|
Line | |
---|
1 | #include "eccad.h" |
---|
2 | |
---|
3 | ptrRGB alloueColor(int id, int red, int green, int blue) |
---|
4 | { |
---|
5 | ptrRGB c; |
---|
6 | if(c=(ptrRGB) malloc (sizeof(RGB)) ) |
---|
7 | { |
---|
8 | c->id= id; |
---|
9 | c->red= red; |
---|
10 | c->green= green; |
---|
11 | c->blue= blue; |
---|
12 | } |
---|
13 | return c; |
---|
14 | } |
---|
15 | |
---|
16 | ptrInterval alloueInterval(ptrRGB c, unsigned int min, unsigned int max) |
---|
17 | { |
---|
18 | ptrInterval v; |
---|
19 | if(v=(ptrInterval) malloc (sizeof(Interval)) ) |
---|
20 | { |
---|
21 | v->min= min; |
---|
22 | v->max= max; |
---|
23 | v->color= c; |
---|
24 | } |
---|
25 | return v; |
---|
26 | } |
---|
27 | |
---|
28 | void freeMap(LIST cmap) |
---|
29 | { |
---|
30 | ptrInterval v; |
---|
31 | loop_through_list(cmap, v, ptrInterval) free(v); |
---|
32 | free_list(cmap); |
---|
33 | } |
---|
34 | |
---|
35 | int inColorId( int *id, ptrRGB c) { return (c->id == *id);} |
---|
36 | |
---|
37 | |
---|
38 | int val2Color(unsigned int pix, LIST cmap) |
---|
39 | { |
---|
40 | register int i=0; |
---|
41 | ptrInterval v; |
---|
42 | loop_through_list(cmap, v, ptrInterval) |
---|
43 | { |
---|
44 | if(pix <= v->max) |
---|
45 | { |
---|
46 | // fprintf(stderr, " v->max %ld v->min %ld pixel %ld -> color %d\n", v->max, v->min, pix, i); |
---|
47 | return i; |
---|
48 | } |
---|
49 | else i++; |
---|
50 | } |
---|
51 | return i-1; |
---|
52 | } |
---|
53 | |
---|
Note: See
TracBrowser
for help on using the repository browser.