GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
color_range.c
Go to the documentation of this file.
1 #include <math.h>
2 #include <grass/gis.h>
3 
4 int G_set_color_range(CELL min, CELL max, struct Colors *colors)
5 {
6  if (min < max) {
7  colors->cmin = (DCELL) min;
8  colors->cmax = (DCELL) max;
9  }
10  else {
11  colors->cmin = (DCELL) max;
12  colors->cmax = (DCELL) min;
13  }
14 
15  return 0;
16 }
17 
18 int G_set_d_color_range(DCELL min, DCELL max, struct Colors *colors)
19 {
20  if (min < max) {
21  colors->cmin = min;
22  colors->cmax = max;
23  }
24  else {
25  colors->cmin = max;
26  colors->cmax = min;
27  }
28 
29  return 0;
30 }
31 
32 /* returns min and max category in the range or huge numbers
33  if the co,lor table is defined on floating cell values and
34  not on categories */
35 
36 
44 int G_get_color_range(CELL * min, CELL * max, const struct Colors *colors)
45 {
46  if (!colors->is_float) {
47  *min = (CELL) floor(colors->cmin);
48  *max = (CELL) ceil(colors->cmax);
49  }
50  else {
51  *min = -255 * 255 * 255;
52  *max = 255 * 255 * 255;
53  }
54 
55  return 0;
56 }
57 
58 /* returns min and max values in the range */
59 int G_get_d_color_range(DCELL * min, DCELL * max, const struct Colors *colors)
60 {
61  *min = colors->cmin;
62  *max = colors->cmax;
63 
64  return 0;
65 }
int G_set_color_range(CELL min, CELL max, struct Colors *colors)
Definition: color_range.c:4
#define min(x, y)
Definition: draw2.c:68
#define max(x, y)
Definition: draw2.c:69
int G_get_d_color_range(DCELL *min, DCELL *max, const struct Colors *colors)
Definition: color_range.c:59
int G_set_d_color_range(DCELL min, DCELL max, struct Colors *colors)
Definition: color_range.c:18
int G_get_color_range(CELL *min, CELL *max, const struct Colors *colors)
Definition: color_range.c:44