GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Gvl3.c
Go to the documentation of this file.
1 
19 #include <grass/gis.h>
20 #include <grass/G3d.h>
21 #include <grass/gstypes.h>
22 #include <grass/glocale.h>
23 
33 int Gvl_load_colors_data(void **color_data, const char *name)
34 {
35  const char *mapset;
36  struct Colors *colors;
37 
38  if (NULL == (mapset = G_find_grid3(name, ""))) {
39  G_warning(_("3D raster map <%s> not found"), name);
40  return (-1);
41  }
42 
43  if (NULL == (colors = (struct Colors *)G_malloc(sizeof(struct Colors))))
44  return (-1);
45 
46  if (0 > G3d_readColors(name, mapset, colors)) {
47  G_free(colors);
48  return (-1);
49  }
50 
51  *color_data = colors;
52 
53  return (1);
54 }
55 
64 int Gvl_unload_colors_data(void *color_data)
65 {
66  if (!G_free_colors(color_data))
67  return (-1);
68 
69  G_free(color_data);
70 
71  return (1);
72 }
73 
82 int Gvl_get_color_for_value(void *color_data, float *value)
83 {
84  int r, g, b;
85 
86  G_get_f_raster_color((FCELL *) value, &r, &g, &b, color_data);
87  return ((r & 0xff) | ((g & 0xff) << 8) | ((b & 0xff) << 16));
88 }
void G_free(void *buf)
Free allocated memory.
Definition: gis/alloc.c:142
float b
Definition: named_colr.c:8
string name
Definition: render.py:1314
int G_free_colors(struct Colors *colors)
free color structure memory
Definition: color_free.c:17
int Gvl_unload_colors_data(void *color_data)
Unload color table.
Definition: Gvl3.c:64
int Gvl_get_color_for_value(void *color_data, float *value)
Get color for value.
Definition: Gvl3.c:82
float r
Definition: named_colr.c:8
int Gvl_load_colors_data(void **color_data, const char *name)
Load color table.
Definition: Gvl3.c:33
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
char * value
Definition: env.c:30
return NULL
Definition: dbfopen.c:1394
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
char * G_find_grid3(const char *name, const char *mapset)
Definition: find_grid3.c:21