21 static int read_new_colors(FILE *,
struct Colors *);
22 static int read_old_colors(FILE *,
struct Colors *);
77 sprintf(buf,
"colr2/%s", mapset);
129 if (fgets(buf,
sizeof buf, fd) ==
NULL) {
140 stat = read_new_colors(fd, colors);
144 stat = read_old_colors(fd, colors);
168 static int read_new_colors(FILE *fd,
struct Colors *colors)
175 char word1[256], word2[256];
181 if (fgets(buf,
sizeof buf, fd) ==
NULL)
185 if (sscanf(buf + 1,
"%lf %lf", &val1, &val2) == 2)
189 while (fgets(buf,
sizeof buf, fd)) {
190 null = undef = fp_rule = 0;
192 n = sscanf(buf,
"%s %s", word1, word2);
196 if (sscanf(word1,
"shift:%lf", &shift) == 1 ||
197 (strcmp(word1,
"shift:") == 0 &&
198 sscanf(word2,
"%lf", &shift) == 1)) {
202 if (strcmp(word1,
"invert") == 0) {
206 if (strcmp(word1,
"%%") == 0) {
211 switch (sscanf(word1,
"nv:%d:%d:%d", &r1, &g1, &b1)) {
221 switch (sscanf(word1,
"*:%d:%d:%d", &r1, &g1, &b1)) {
231 switch (sscanf(word1,
"%ld:%d:%d:%d", &cat1, &r1, &g1, &b1)) {
238 if (sscanf(word1,
"%lf:%d:%d:%d", &val1, &r1, &g1, &b1) == 4)
240 else if (sscanf(word1,
"%lf:%d", &val1, &r1) == 2) {
248 switch (sscanf(word2,
"%ld:%d:%d:%d", &cat2, &r2, &g2, &b2)) {
259 if (sscanf(word2,
"%lf:%d:%d:%d", &val2, &r2, &g2, &b2) == 4) {
264 else if (sscanf(word2,
"%lf:%d", &val2, &r2) == 2) {
291 (
DCELL *)&val2, r2, g2, b2,
295 (
CELL *)&cat2, r2, g2, b2,
301 (
DCELL *)&val2, r2, g2, b2, colors);
306 G_debug(3,
"adding rule %ld=%.2lf %d %d %d %ld=%.2lf %d %d %d", cat1,
307 val1, r1, g1, b1, cat2, val2, r2, g2, b2);
312 static int read_old_colors(FILE *fd,
struct Colors *colors)
317 float red_f, grn_f, blu_f;
327 if (fgets(buf,
sizeof buf, fd) ==
NULL)
333 if (sscanf(buf + 1,
"%ld", &
min) != 1)
345 while (fgets(buf,
sizeof buf, fd)) {
347 if (sscanf(buf,
"%f %f %f", &red_f, &grn_f, &blu_f) != 3)
355 switch (sscanf(buf,
"%d %d %d", &red, &grn, &blu)) {
377 colors->
cmax = n - 1;
FILE * G_fopen_old(const char *, const char *, const char *)
Open a database 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.
const char * G_mapset(void)
Get current mapset name.
const char * G_find_raster(char *, const char *)
Find a raster map.
void G_strip(char *)
Removes all leading and trailing white space from string.
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)
int Rast__insert_color_into_lookup(CELL, int, int, int, struct _Color_Info_ *)
int Rast_read_fp_range(const char *, const char *, struct FPRange *)
Read floating-point range.
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_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_get_range_min_max(const struct Range *, CELL *, CELL *)
Get range min and max.
void Rast_init_colors(struct Colors *)
Initialize color structure.
int Rast_read_range(const char *, const char *, struct Range *)
Read raster range (CELL)
void Rast_set_d_color_range(DCELL, DCELL, struct Colors *)
Set color range (DCELL version)
int Rast_map_is_fp(const char *, const char *)
Check if raster map is floating-point.
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)
#define Rast_is_c_null_value(cellVal)
void Rast_invert_colors(struct Colors *)
void Rast_make_colors(struct Colors *, const char *, CELL, CELL)
Load color rules from predefined color table.
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 Rast__read_colors(const char *element, const char *name, const char *mapset, struct Colors *colors)
int Rast_read_colors(const char *name, const char *mapset, struct Colors *colors)
Read color table of raster map.
void Rast_mark_colors_as_fp(struct Colors *colors)
Mark colors as floating-point.
struct _Color_Info_ fixed
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)