58 int *
r,
int *
g,
int *
b,
int *norm,
int *nval,
61 char value[80], color[80];
65 *norm = *nval = *dflt = 0;
67 if (sscanf(buf,
"%s %[^\n]", value, color) != 2)
87 if (sscanf(value,
"%lf%c", &
x, &c) == 2 && c ==
'%') {
96 if (sscanf(value,
"%lf", val) == 1) {
117 return _(
"syntax error in the color rule");
119 return _(
"syntax error in the color format");
127 return _(
"percentage not in range 0-100");
129 return _(
"invalid value");
131 return _(
"unknown error");
148 int *
r,
int *
g,
int *
b,
int *norm,
int *nval,
155 *norm = *nval = *dflt = 0;
158 if (!
G_getl2(buf,
sizeof(buf), fp))
162 G_debug(5,
"color buf = [%s]", buf);
194 struct rule *rule =
NULL;
196 struct rule dflt, null;
197 int set, is_null, is_dflt,
r,
g,
b;
207 dflt.r = dflt.g = dflt.b = dflt.set = 0;
208 null.r =
null.g =
null.b =
null.set = 0;
210 while ((*read_rule)(closure,
min,
max, &val, &
r, &
g, &
b, &set, &is_null,
212 struct rule *p =
NULL;
216 rule =
G_realloc(rule, nrules *
sizeof(
struct rule));
238 const struct rule *p = &rule[0];
243 for (n = 1; n < nrules; n++) {
244 struct rule *lo = &rule[n - 1];
245 struct rule *hi = &rule[n];
248 hi->g, hi->b, colors);
269 fp = fopen(
path,
"r");
313 return load_rules_file(colors,
path,
min,
max);
int G_str_to_color(const char *, int *, int *, int *)
Parse color string and set red,green,blue.
int G_getl2(char *, int, FILE *)
Gets a line of text from a file of any pedigree.
void G_free(void *)
Free allocated memory.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_strip(char *)
Removes all leading and trailing white space from string.
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
const char * G_gisbase(void)
Get full path name of the top level module directory.
char * G_chop(char *)
Chop leading and trailing white spaces.
int G_debug(int, const char *,...) __attribute__((format(printf
void Rast_add_d_color_rule(const DCELL *, int, int, int, const DCELL *, int, int, int, struct Colors *)
Adds the floating-point color rule (DCELL version)
void Rast_set_null_value_color(int, int, int, struct Colors *)
Set color for NULL-value.
int read_rule_fn(void *, DCELL, DCELL, DCELL *, int *, int *, int *, int *, int *, int *)
void Rast_set_d_color(DCELL, int, int, int, struct Colors *)
Set a category color (DCELL)
void Rast_init_colors(struct Colors *)
Initialize color structure.
void Rast_set_default_color(int, int, int, struct Colors *)
Set default color value.
int Rast_load_colors(struct Colors *colors, const char *path, CELL min, CELL max)
Load color rules from file.
int Rast_read_color_rule(void *closure, DCELL min, DCELL max, DCELL *val, int *r, int *g, int *b, int *norm, int *nval, int *dflt)
Read color rule.
int Rast_read_color_rules(struct Colors *colors, DCELL min, DCELL max, read_rule_fn *read_rule, void *closure)
Read color rules from file.
void Rast_make_fp_colors(struct Colors *colors, const char *name, DCELL min, DCELL max)
Load color rules from predefined floating-point color table.
int Rast_parse_color_rule(DCELL min, DCELL max, const char *buf, DCELL *val, int *r, int *g, int *b, int *norm, int *nval, int *dflt)
Read color rule.
const char * Rast_parse_color_rule_error(int code)
Parse color rule.
void Rast_make_colors(struct Colors *colors, const char *name, CELL min, CELL max)
Load color rules from predefined color table.
int Rast_load_fp_colors(struct Colors *colors, const char *path, DCELL min, DCELL max)
Load color floating-point rules from file.