13 static int read_colors(
const char *,
const char *,
struct Colors *);
14 static int read_new_colors(FILE *,
struct Colors *);
15 static int read_old_colors(FILE *,
struct Colors *);
56 switch (read_colors(
name, mapset, colors)) {
77 static int read_colors(
const char *
name,
const char *mapset,
93 if (fgets(buf,
sizeof buf, fd) ==
NULL) {
101 stat = read_new_colors(fd, colors);
105 stat = read_old_colors(fd, colors);
124 static int read_new_colors(FILE *fd,
struct Colors *colors)
131 char word1[256], word2[256];
137 if (fgets(buf,
sizeof buf, fd) ==
NULL)
141 if (sscanf(buf + 1,
"%lf %lf", &val1, &val2) == 2)
145 while (fgets(buf,
sizeof buf, fd)) {
146 null = undef = fp_rule = 0;
148 n = sscanf(buf,
"%s %s", word1, word2);
152 if (sscanf(word1,
"shift:%lf", &shift) == 1 ||
153 (strcmp(word1,
"shift:") == 0 &&
154 sscanf(word2,
"%lf", &shift) == 1)) {
158 if (strcmp(word1,
"invert") == 0) {
162 if (strcmp(word1,
"%%") == 0) {
167 switch (sscanf(word1,
"nv:%d:%d:%d", &r1, &g1, &b1)) {
177 switch (sscanf(word1,
"*:%d:%d:%d", &r1, &g1, &b1)) {
187 switch (sscanf(word1,
"%ld:%d:%d:%d", &cat1, &r1, &g1, &b1)) {
194 if (sscanf(word1,
"%lf:%d:%d:%d", &val1, &r1, &g1, &b1) == 4)
196 else if (sscanf(word1,
"%lf:%d", &val1, &r1) == 2) {
204 switch (sscanf(word2,
"%ld:%d:%d:%d", &cat2, &r2, &g2, &b2)) {
215 if (sscanf(word2,
"%lf:%d:%d:%d", &val2, &r2, &g2, &b2) == 4) {
220 else if (sscanf(word2,
"%lf:%d", &val2, &r2) == 2) {
247 (
DCELL *)&val2, r2, g2, b2,
251 (
CELL *)&cat2, r2, g2, b2,
257 (
DCELL *)&val2, r2, g2, b2, colors);
270 static int read_old_colors(FILE *fd,
struct Colors *colors)
275 float red_f, grn_f, blu_f;
285 if (fgets(buf,
sizeof buf, fd) ==
NULL)
291 if (sscanf(buf + 1,
"%ld", &
min) != 1)
303 while (fgets(buf,
sizeof buf, fd)) {
305 if (sscanf(buf,
"%f %f %f", &red_f, &grn_f, &blu_f) != 3)
313 switch (sscanf(buf,
"%d %d %d", &red, &grn, &blu)) {
335 colors->
cmax = n - 1;
357 if (strcmp(mapset,
G_mapset()) != 0) {
358 G_warning(
_(
"mapset <%s> is not the current mapset"), mapset);
FILE * G_fopen_old_misc(const char *, const char *, const char *, const char *)
open a database misc file for reading
void G_warning(const char *,...) __attribute__((format(printf
void G_fseek(FILE *, off_t, int)
Change the file position of the stream.
FILE * G_fopen_new_misc(const char *, const char *, const char *)
open a new database misc file
const char * G_mapset(void)
Get current mapset name.
int G_remove_misc(const char *, const char *, const char *)
Remove a database misc file.
void G_strip(char *)
Removes all leading and trailing white space from string.
int Rast3d_read_range(const char *, const char *, struct FPRange *)
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)
int Rast__insert_color_into_lookup(CELL, int, int, int, struct _Color_Info_ *)
void Rast_set_null_value_color(int, int, int, struct Colors *)
Set color for NULL-value.
int Rast_add_modular_c_color_rule(const CELL *, int, int, int, const CELL *, int, int, int, struct Colors *)
Add modular integer color rule (CELL version)
void Rast_mark_colors_as_fp(struct Colors *)
Mark colors as floating-point.
void Rast_get_fp_range_min_max(const struct FPRange *, DCELL *, DCELL *)
Get minimum and maximum value from fp range.
void Rast_add_c_color_rule(const CELL *, int, int, int, const CELL *, int, int, int, struct Colors *)
Adds the integer color rule (CELL version)
void Rast_init_colors(struct Colors *)
Initialize color structure.
void Rast_set_d_color_range(DCELL, DCELL, struct Colors *)
Set color range (DCELL version)
void Rast__write_colors(FILE *, struct Colors *)
Write map layer color table.
int Rast_add_modular_d_color_rule(const DCELL *, int, int, int, const DCELL *, int, int, int, struct Colors *)
Add modular floating-point color rule (DCELL version)
void Rast_make_fp_colors(struct Colors *, const char *, DCELL, DCELL)
Load color rules from predefined floating-point color table.
#define Rast_is_d_null_value(dcellVal)
void Rast_invert_colors(struct Colors *)
void Rast_set_default_color(int, int, int, struct Colors *)
Set default color value.
void Rast_shift_d_colors(DCELL, struct Colors *)
#define DEFAULT_COLOR_TABLE
int Rast3d_write_colors(const char *name, const char *mapset, struct Colors *colors)
Writes the colors for map name in mapset into a color file.
int Rast3d_read_colors(const char *name, const char *mapset, struct Colors *colors)
Reads color file for map name in mapset into the Colors structure.
int Rast3d_remove_color(const char *name)
Removes the primary and/or secondary color file.
#define RASTER3D_COLOR_ELEMENT
#define RASTER3D_DIRECTORY
struct _Color_Info_ fixed
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)