GRASS Programmer's Manual 6.4.1(2011)
|
00001 00017 #include <grass/gis.h> 00018 00019 00036 int G_get_color(CELL n, int *red, int *grn, int *blu, struct Colors *colors) 00037 { 00038 CELL cat; 00039 unsigned char r, g, b, set; 00040 00041 cat = n; 00042 G_lookup_colors(&cat, &r, &g, &b, &set, 1, colors); 00043 00044 *red = (int)r; 00045 *grn = (int)g; 00046 *blu = (int)b; 00047 00048 return (int)set; 00049 } 00050 00051 00067 int G_get_raster_color(const void *rast, 00068 int *red, int *grn, int *blu, 00069 struct Colors *colors, RASTER_MAP_TYPE map_type) 00070 { 00071 unsigned char r, g, b, set; 00072 00073 G_lookup_raster_colors(rast, &r, &g, &b, &set, 1, colors, map_type); 00074 00075 *red = (int)r; 00076 *grn = (int)g; 00077 *blu = (int)b; 00078 00079 return (int)set; 00080 } 00081 00082 00097 int G_get_c_raster_color(const CELL * rast, 00098 int *red, int *grn, int *blu, struct Colors *colors) 00099 { 00100 return G_get_raster_color(rast, red, grn, blu, colors, CELL_TYPE); 00101 } 00102 00103 00118 int G_get_f_raster_color(const FCELL * rast, 00119 int *red, int *grn, int *blu, struct Colors *colors) 00120 { 00121 return G_get_raster_color(rast, red, grn, blu, colors, FCELL_TYPE); 00122 } 00123 00124 00139 int G_get_d_raster_color(const DCELL * rast, 00140 int *red, int *grn, int *blu, struct Colors *colors) 00141 { 00142 return G_get_raster_color(rast, red, grn, blu, colors, DCELL_TYPE); 00143 } 00144 00145 00159 int G_get_null_value_color(int *red, int *grn, int *blu, 00160 const struct Colors *colors) 00161 { 00162 if (colors->null_set) { 00163 *red = (int)colors->null_red; 00164 *grn = (int)colors->null_grn; 00165 *blu = (int)colors->null_blu; 00166 } 00167 else if (colors->undef_set) { 00168 *red = (int)colors->undef_red; 00169 *grn = (int)colors->undef_grn; 00170 *blu = (int)colors->undef_blu; 00171 } 00172 else 00173 *red = *blu = *grn = 255; /* white */ 00174 00175 return 0; 00176 } 00177 00178 00192 int G_get_default_color(int *red, int *grn, int *blu, 00193 const struct Colors *colors) 00194 { 00195 if (colors->undef_set) { 00196 *red = (int)colors->undef_red; 00197 *grn = (int)colors->undef_grn; 00198 *blu = (int)colors->undef_blu; 00199 } 00200 else 00201 *red = *blu = *grn = 255; /* white */ 00202 00203 return 0; 00204 }