23static void write_new_colors(
FILE *,
struct Colors *);
24static void write_old_colors(
FILE *,
struct Colors *);
25static void forced_write_old_colors(
FILE *,
struct Colors *);
26static void format_min(
char *,
double);
27static void format_max(
char *,
double);
29#define FORMAT_STR_SZ 100
113 if (
getenv(
"FORCE_GRASS3_COLORS"))
114 forced_write_old_colors(fd, colors);
116 write_old_colors(fd, colors);
118 write_new_colors(fd, colors);
121static void write_new_colors(
FILE *fd,
struct Colors *colors)
125 format_min(
str1, (
double)colors->
cmin);
126 format_max(
str2, (
double)colors->
cmax);
156 if (colors->
fixed.rules)
157 write_rules(fd, colors->
fixed.rules, colors->
cmin, colors->
cmax);
173 for (; rule; rule = rule->
prev) {
174 if (rule->low.value == dmin)
175 format_min(str, (
double)rule->low.value);
180 fprintf(fd,
"%s:%d", str, (
int)rule->low.red);
181 if (rule->low.red != rule->low.grn || rule->low.red != rule->low.blu)
182 fprintf(fd,
":%d:%d", rule->low.grn, rule->low.blu);
184 if (rule->
high.value ==
dmax || rule->low.value != rule->
high.value) {
186 format_max(str, (
double)rule->
high.value);
192 if (rule->
high.red != rule->
high.grn ||
200static void write_old_colors(
FILE *fd,
struct Colors *colors)
204 fprintf(fd,
"#%ld first color\n", (
long)colors->
fixed.min);
212 n = colors->
fixed.max - colors->
fixed.min + 1;
214 for (i = 0; i < n; i++) {
216 if (colors->
fixed.lookup.red[i] != colors->
fixed.lookup.grn[i] ||
217 colors->
fixed.lookup.red[i] != colors->
fixed.lookup.blu[i])
219 (
int)colors->
fixed.lookup.blu[i]);
224static void forced_write_old_colors(
FILE *fd,
struct Colors *colors)
229 fprintf(fd,
"#%ld first color\n", (
long)colors->
cmin);
232 fprintf(fd,
"%d %d %d\n", red, grn, blu);
234 for (cat = colors->
cmin; cat <= colors->
cmax; cat++) {
237 if (red != grn || red != blu)
238 fprintf(fd,
" %d %d", grn, blu);
243static void format_min(
char *str,
double dval)
260static void format_max(
char *str,
double dval)
int G_name_is_fully_qualified(const char *, char *, char *)
Check if map name is fully qualified (map @ mapset)
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
FILE * G_fopen_new(const char *, const char *)
Open a new database file.
void G_trim_decimal(char *)
Removes trailing zeros from decimal number.
int G_remove(const char *, const char *)
Remove a database file.
const char * G_mapset(void)
Get current mapset name.
int Rast_get_c_color(const CELL *, int *, int *, int *, struct Colors *)
Gets color from raster map (CELL)
void Rast__write_colors(FILE *fd, struct Colors *colors)
Write map layer color table.
void Rast_write_colors(const char *name, const char *mapset, struct Colors *colors)
Write map layer color table.
struct _Color_Info_ fixed
struct _Color_Info_ modular
struct _Color_Rule_ * prev
struct _Color_Rule_ * next
struct _Color_Value_ low high