20static void write_new_colors(
FILE *,
struct Colors *);
21static void write_old_colors(
FILE *,
struct Colors *);
22static void forced_write_old_colors(
FILE *,
struct Colors *);
23static void format_min(
char *,
double);
24static void format_max(
char *,
double);
26#define FORMAT_STR_SZ 100
110 if (
getenv(
"FORCE_GRASS3_COLORS"))
111 forced_write_old_colors(fd, colors);
113 write_old_colors(fd, colors);
115 write_new_colors(fd, colors);
118static void write_new_colors(
FILE *fd,
struct Colors *colors)
122 format_min(
str1, (
double)colors->
cmin);
123 format_max(
str2, (
double)colors->
cmax);
153 if (colors->
fixed.rules)
154 write_rules(fd, colors->
fixed.rules, colors->
cmin, colors->
cmax);
170 for (; rule; rule = rule->
prev) {
171 if (rule->low.value == dmin)
172 format_min(str, (
double)rule->low.value);
177 fprintf(fd,
"%s:%d", str, (
int)rule->low.red);
178 if (rule->low.red != rule->low.grn || rule->low.red != rule->low.blu)
179 fprintf(fd,
":%d:%d", rule->low.grn, rule->low.blu);
181 if (rule->
high.value ==
dmax || rule->low.value != rule->
high.value) {
183 format_max(str, (
double)rule->
high.value);
189 if (rule->
high.red != rule->
high.grn ||
197static void write_old_colors(
FILE *fd,
struct Colors *colors)
201 fprintf(fd,
"#%ld first color\n", (
long)colors->
fixed.min);
209 n = colors->
fixed.max - colors->
fixed.min + 1;
211 for (i = 0; i < n; i++) {
213 if (colors->
fixed.lookup.red[i] != colors->
fixed.lookup.grn[i] ||
214 colors->
fixed.lookup.red[i] != colors->
fixed.lookup.blu[i])
216 (
int)colors->
fixed.lookup.blu[i]);
221static void forced_write_old_colors(
FILE *fd,
struct Colors *colors)
226 fprintf(fd,
"#%ld first color\n", (
long)colors->
cmin);
229 fprintf(fd,
"%d %d %d\n", red, grn, blu);
231 for (cat = colors->
cmin; cat <= colors->
cmax; cat++) {
234 if (red != grn || red != blu)
235 fprintf(fd,
" %d %d", grn, blu);
240static void format_min(
char *str,
double dval)
257static 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