GRASS Programmer's Manual  6.4.2(2012)
Gvl3.c
Go to the documentation of this file.
00001 
00019 #include <grass/gis.h>
00020 #include <grass/G3d.h>
00021 #include <grass/gstypes.h>
00022 #include <grass/glocale.h>
00023 
00033 int Gvl_load_colors_data(void **color_data, const char *name)
00034 {
00035     const char *mapset;
00036     struct Colors *colors;
00037 
00038     if (NULL == (mapset = G_find_grid3(name, ""))) {
00039         G_warning(_("3D raster map <%s> not found"), name);
00040         return (-1);
00041     }
00042 
00043     if (NULL == (colors = (struct Colors *)G_malloc(sizeof(struct Colors))))
00044         return (-1);
00045 
00046     if (0 > G3d_readColors(name, mapset, colors)) {
00047         G_free(colors);
00048         return (-1);
00049     }
00050 
00051     *color_data = colors;
00052 
00053     return (1);
00054 }
00055 
00064 int Gvl_unload_colors_data(void *color_data)
00065 {
00066     if (!G_free_colors(color_data))
00067         return (-1);
00068 
00069     G_free(color_data);
00070 
00071     return (1);
00072 }
00073 
00082 int Gvl_get_color_for_value(void *color_data, float *value)
00083 {
00084     int r, g, b;
00085 
00086     G_get_f_raster_color((FCELL *) value, &r, &g, &b, color_data);
00087     return ((r & 0xff) | ((g & 0xff) << 8) | ((b & 0xff) << 16));
00088 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines