color_get.c

Go to the documentation of this file.
00001 #include "gis.h"
00002 
00003 /* return RGB for given category */
00004 /* works for null values too */
00005 
00031 int G_get_color (CELL n, int *red, int *grn, int *blu, struct Colors *colors)
00032 {
00033     CELL cat;
00034     unsigned char r, g, b, set;
00035 
00036     cat = n;
00037     G_lookup_colors (&cat, &r, &g, &b, &set, 1, colors);
00038 
00039     *red = (int) r;
00040     *grn = (int) g;
00041     *blu = (int) b;
00042 
00043     return (int)set;
00044 }
00045 
00046 
00062 int G_get_raster_color (void *rast,
00063     int *red, int *grn, int *blu,
00064     struct Colors *colors, RASTER_MAP_TYPE map_type)
00065 {
00066     unsigned char r, g, b, set;
00067 
00068     G_lookup_raster_colors (rast, &r, &g, &b, &set, 1, colors, map_type);
00069 
00070     *red = (int) r;
00071     *grn = (int) g;
00072     *blu = (int) b;
00073 
00074     return (int)set;
00075 }
00076 
00077 
00091 int G_get_c_raster_color (CELL *rast,
00092     int *red, int *grn, int *blu, struct Colors *colors)
00093 {
00094     unsigned char r, g, b, set;
00095 
00096     G_lookup_raster_colors (rast, &r, &g, &b, &set, 1, colors, CELL_TYPE);
00097 
00098     *red = (int) r;
00099     *grn = (int) g;
00100     *blu = (int) b;
00101 
00102     return (int)set;
00103 }
00104 
00105 
00120 int G_get_f_raster_color (FCELL *rast,
00121     int *red, int *grn, int *blu, struct Colors *colors)
00122 {
00123     unsigned char r, g, b, set;
00124 
00125     G_lookup_raster_colors (rast, &r, &g, &b, &set, 1, colors, FCELL_TYPE);
00126 
00127     *red = (int) r;
00128     *grn = (int) g;
00129     *blu = (int) b;
00130 
00131     return (int)set;
00132 }
00133 
00134 
00149 int G_get_d_raster_color (DCELL *rast,
00150     int *red, int *grn, int *blu, struct Colors *colors)
00151 {
00152     unsigned char r, g, b, set;
00153 
00154     G_lookup_raster_colors (rast, &r, &g, &b, &set, 1, colors, DCELL_TYPE);
00155 
00156     *red = (int) r;
00157     *grn = (int) g;
00158     *blu = (int) b;
00159 
00160     return (int)set;
00161 }
00162 
00163 
00177 int G_get_null_value_color (int *red, int *grn, int *blu,
00178     struct Colors *colors)
00179 {
00180   if(colors->null_set)
00181   {
00182       *red = (int) colors->null_red;
00183       *grn = (int) colors->null_grn;
00184       *blu = (int) colors->null_blu;
00185   }
00186   else if(colors->undef_set)
00187   {
00188       *red = (int) colors->undef_red;
00189       *grn = (int) colors->undef_grn;
00190       *blu = (int) colors->undef_blu;
00191   }
00192   else
00193       *red = *blu = *grn = 255; /* white */
00194 
00195   return 0;
00196 }
00197 
00198 
00212 int G_get_default_color (int *red, int *grn, int *blu,
00213     struct Colors *colors)
00214 {
00215   if(colors->undef_set)
00216   {
00217       *red = (int) colors->undef_red;
00218       *grn = (int) colors->undef_grn;
00219       *blu = (int) colors->undef_blu;
00220   }
00221   else
00222       *red = *blu = *grn = 255; /* white */
00223 
00224   return 0;
00225 }

Generated on Sat Jul 22 22:06:14 2006 for GRASS by  doxygen 1.4.7