6 #include <grass/display.h>
7 #include <grass/colors.h>
8 #include <grass/raster.h>
9 #include <grass/glocale.h>
11 static struct color_rgb *colors;
32 for (i = 0; i < num_names; i++) {
58 static int translate_or_add_color(
const char *str)
62 int i, preallocated, ret;
63 char lowerstr[MAX_COLOR_LEN];
77 colors = G_malloc(nalloc *
sizeof(
struct color_rgb));
78 for (i = 0; i < ncolors; i++)
91 for (i = 1; i < ncolors; i++)
92 if (colors[i].
r == red && colors[i].
g == grn && colors[i].
b == blu)
95 if (ncolors >= nalloc) {
97 colors = G_realloc(colors, nalloc *
sizeof(
struct color_rgb));
102 colors[index].r = red;
103 colors[index].g = grn;
104 colors[index].b = blu;
127 color = translate_or_add_color(str);
130 if (color == 0 && !none_acceptable)
156 if (color < ncolors) {
157 const struct color_rgb *c = &colors[color];
185 const struct color_rgb *c;
203 if (color >= ncolors)