GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
color_get.c
Go to the documentation of this file.
1 
17 #include <grass/gis.h>
18 
19 
36 int G_get_color(CELL n, int *red, int *grn, int *blu, struct Colors *colors)
37 {
38  CELL cat;
39  unsigned char r, g, b, set;
40 
41  cat = n;
42  G_lookup_colors(&cat, &r, &g, &b, &set, 1, colors);
43 
44  *red = (int)r;
45  *grn = (int)g;
46  *blu = (int)b;
47 
48  return (int)set;
49 }
50 
51 
67 int G_get_raster_color(const void *rast,
68  int *red, int *grn, int *blu,
69  struct Colors *colors, RASTER_MAP_TYPE map_type)
70 {
71  unsigned char r, g, b, set;
72 
73  G_lookup_raster_colors(rast, &r, &g, &b, &set, 1, colors, map_type);
74 
75  *red = (int)r;
76  *grn = (int)g;
77  *blu = (int)b;
78 
79  return (int)set;
80 }
81 
82 
97 int G_get_c_raster_color(const CELL * rast,
98  int *red, int *grn, int *blu, struct Colors *colors)
99 {
100  return G_get_raster_color(rast, red, grn, blu, colors, CELL_TYPE);
101 }
102 
103 
118 int G_get_f_raster_color(const FCELL * rast,
119  int *red, int *grn, int *blu, struct Colors *colors)
120 {
121  return G_get_raster_color(rast, red, grn, blu, colors, FCELL_TYPE);
122 }
123 
124 
139 int G_get_d_raster_color(const DCELL * rast,
140  int *red, int *grn, int *blu, struct Colors *colors)
141 {
142  return G_get_raster_color(rast, red, grn, blu, colors, DCELL_TYPE);
143 }
144 
145 
159 int G_get_null_value_color(int *red, int *grn, int *blu,
160  const struct Colors *colors)
161 {
162  if (colors->null_set) {
163  *red = (int)colors->null_red;
164  *grn = (int)colors->null_grn;
165  *blu = (int)colors->null_blu;
166  }
167  else if (colors->undef_set) {
168  *red = (int)colors->undef_red;
169  *grn = (int)colors->undef_grn;
170  *blu = (int)colors->undef_blu;
171  }
172  else
173  *red = *blu = *grn = 255; /* white */
174 
175  return 0;
176 }
177 
178 
192 int G_get_default_color(int *red, int *grn, int *blu,
193  const struct Colors *colors)
194 {
195  if (colors->undef_set) {
196  *red = (int)colors->undef_red;
197  *grn = (int)colors->undef_grn;
198  *blu = (int)colors->undef_blu;
199  }
200  else
201  *red = *blu = *grn = 255; /* white */
202 
203  return 0;
204 }
int G_lookup_raster_colors(const void *raster, unsigned char *red, unsigned char *grn, unsigned char *blu, unsigned char *set, int n, struct Colors *colors, RASTER_MAP_TYPE map_type)
If the cell_type is CELL_TYPE, calls G_lookup_colors((CELL *)cell, r, g, b, set, n, colors); If the cell_type is FCELL_TYPE, calls G_lookup_f_raster_colors(FCELL *)cell, r, g, b, set, n, colors); If the cell_type is DCELL_TYPE, calls G_lookup_d_raster_colors(DCELL *)cell, r, g, b, set, n, colors);.
Definition: color_look.c:118
float b
Definition: named_colr.c:8
int G_get_null_value_color(int *red, int *grn, int *blu, const struct Colors *colors)
Gets color for null value.
Definition: color_get.c:159
int G_lookup_colors(const CELL *cell, unsigned char *red, unsigned char *grn, unsigned char *blu, unsigned char *set, int n, struct Colors *colors)
lookup an array of colors
Definition: color_look.c:38
float r
Definition: named_colr.c:8
int G_get_raster_color(const void *rast, int *red, int *grn, int *blu, struct Colors *colors, RASTER_MAP_TYPE map_type)
Gets color from raster.
Definition: color_get.c:67
int G_get_c_raster_color(const CELL *rast, int *red, int *grn, int *blu, struct Colors *colors)
Gets color for a CELL raster.
Definition: color_get.c:97
int G_get_d_raster_color(const DCELL *rast, int *red, int *grn, int *blu, struct Colors *colors)
Gets color for a DCELL raster.
Definition: color_get.c:139
int G_get_default_color(int *red, int *grn, int *blu, const struct Colors *colors)
Gets default color.
Definition: color_get.c:192
int G_get_color(CELL n, int *red, int *grn, int *blu, struct Colors *colors)
Get a category color.
Definition: color_get.c:36
int G_get_f_raster_color(const FCELL *rast, int *red, int *grn, int *blu, struct Colors *colors)
Gets color for a FCELL raster.
Definition: color_get.c:118
float g
Definition: named_colr.c:8
int
Definition: g3dcolor.c:48
CELL cat
Definition: g3dcats.c:90
int n
Definition: dataquad.c:291
string set