14 static int read_colors(
const char *,
const char *,
struct Colors *);
15 static int read_new_colors(FILE *,
struct Colors *);
16 static int read_old_colors(FILE *,
struct Colors *);
55 switch (read_colors(name, mapset, colors)) {
72 G_warning(
"color support for [%s] in mapset [%s] %s", name, mapset, err);
76 static int read_colors(
const char *
name,
const char *mapset,
91 if (fgets(buf,
sizeof buf, fd) ==
NULL) {
99 stat = read_new_colors(fd, colors);
103 stat = read_old_colors(fd, colors);
122 static int read_new_colors(FILE * fd,
struct Colors *colors)
129 char word1[256], word2[256];
135 if (fgets(buf,
sizeof buf, fd) ==
NULL)
139 if (sscanf(buf + 1,
"%lf %lf", &val1, &val2) == 2)
143 while (fgets(buf,
sizeof buf, fd)) {
144 null = undef = fp_rule = 0;
146 n = sscanf(buf,
"%s %s", word1, word2);
150 if (sscanf(word1,
"shift:%lf", &shift) == 1
151 || (strcmp(word1,
"shift:") == 0 &&
152 sscanf(word2,
"%lf", &shift) == 1)) {
156 if (strcmp(word1,
"invert") == 0) {
160 if (strcmp(word1,
"%%") == 0) {
165 switch (sscanf(word1,
"nv:%d:%d:%d", &r1, &g1, &b1)) {
175 switch (sscanf(word1,
"*:%d:%d:%d", &r1, &g1, &b1)) {
185 switch (sscanf(word1,
"%ld:%d:%d:%d", &cat1, &r1, &g1, &b1)) {
192 if (sscanf(word1,
"%lf:%d:%d:%d", &val1, &r1, &g1, &b1) == 4)
194 else if (sscanf(word1,
"%lf:%d", &val1, &r1) == 2) {
202 switch (sscanf(word2,
"%ld:%d:%d:%d", &cat2, &r2, &g2, &b2)) {
213 if (sscanf(word2,
"%lf:%d:%d:%d", &val2, &r2, &g2, &b2) == 4) {
218 else if (sscanf(word2,
"%lf:%d", &val2, &r2) == 2) {
245 b1, (
DCELL *) & val2, r2,
249 (
CELL *) &cat2, r2, g2, b2, colors);
254 (
DCELL *) & val2, r2, g2, b2,
258 (
CELL *) &cat2, r2, g2, b2, colors);
267 static int read_old_colors(FILE * fd,
struct Colors *colors)
272 float red_f, grn_f, blu_f;
282 if (fgets(buf,
sizeof buf, fd) ==
NULL)
288 if (sscanf(buf + 1,
"%ld", &min) != 1)
300 while (fgets(buf,
sizeof buf, fd)) {
302 if (sscanf(buf,
"%f %f %f", &red_f, &grn_f, &blu_f) != 3)
310 switch (sscanf(buf,
"%d %d %d", &red, &grn, &blu)) {
332 colors->
cmax = n - 1;
353 if (strcmp(mapset,
G_mapset()) != 0) {
354 G_warning(
_(
"mapset <%s> is not the current mapset"), mapset);
void Rast__write_colors(FILE *, struct Colors *)
Write map layer color table.
struct _Color_Info_ fixed
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)
#define Rast_is_d_null_value(dcellVal)
void Rast_invert_colors(struct Colors *)
void Rast_shift_d_colors(DCELL, struct Colors *)
void G_strip(char *)
Removes all leading and trailing white space from string.
void Rast_set_d_color_range(DCELL, DCELL, struct Colors *)
Set color range (DCELL version)
int G_remove_misc(const char *, const char *, const char *)
Remove a database misc file.
int Rast3d_read_range(const char *, const char *, struct FPRange *)
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
void Rast_get_fp_range_min_max(const struct FPRange *, DCELL *, DCELL *)
Get minimum and maximum value from fp range.
int Rast__insert_color_into_lookup(CELL, int, int, int, struct _Color_Info_ *)
void Rast_mark_colors_as_fp(struct Colors *)
Mark colors as floating-point.
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)
FILE * G_fopen_old_misc(const char *, const char *, const char *, const char *)
open a database misc file for reading
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.
void G_fseek(FILE *, off_t, int)
Change the file position of the stream.
void Rast_set_default_color(int, int, int, struct Colors *)
Set default color value.
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.
void Rast_set_null_value_color(int, int, int, struct Colors *)
Set color for NULL-value.
int Rast3d_remove_color(const char *name)
Removes the primary and/or secondary color file.
#define RASTER3D_DIRECTORY
FILE * G_fopen_new_misc(const char *, const char *, const char *)
open a new database misc file
#define DEFAULT_COLOR_TABLE
const char * G_mapset(void)
Get current mapset name.
void G_warning(const char *,...) __attribute__((format(printf
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_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_make_fp_colors(struct Colors *, const char *, DCELL, DCELL)
Load color rules from predefined floating-point color table.
void Rast_init_colors(struct Colors *)
Initialize color structure.
#define RASTER3D_COLOR_ELEMENT