21 static int read_new_colors(FILE *,
struct Colors *);
22 static int read_old_colors(FILE *,
struct Colors *);
78 sprintf(buf,
"colr2/%s", mapset);
112 G_warning(
_(
"Color support for <%s@%s> %s"), name, mapset, err);
117 const char *mapset,
struct Colors *colors)
130 if (fgets(buf,
sizeof buf, fd) ==
NULL) {
141 stat = read_new_colors(fd, colors);
145 stat = read_old_colors(fd, colors);
169 static int read_new_colors(FILE * fd,
struct Colors *colors)
176 char word1[256], word2[256];
182 if (fgets(buf,
sizeof buf, fd) ==
NULL)
186 if (sscanf(buf + 1,
"%lf %lf", &val1, &val2) == 2)
190 while (fgets(buf,
sizeof buf, fd)) {
191 null = undef = fp_rule = 0;
193 n = sscanf(buf,
"%s %s", word1, word2);
197 if (sscanf(word1,
"shift:%lf", &shift) == 1
198 || (strcmp(word1,
"shift:") == 0 &&
199 sscanf(word2,
"%lf", &shift) == 1)) {
203 if (strcmp(word1,
"invert") == 0) {
207 if (strcmp(word1,
"%%") == 0) {
212 switch (sscanf(word1,
"nv:%d:%d:%d", &r1, &g1, &b1)) {
222 switch (sscanf(word1,
"*:%d:%d:%d", &r1, &g1, &b1)) {
232 switch (sscanf(word1,
"%ld:%d:%d:%d", &cat1, &r1, &g1, &b1)) {
239 if (sscanf(word1,
"%lf:%d:%d:%d", &val1, &r1, &g1, &b1) == 4)
241 else if (sscanf(word1,
"%lf:%d", &val1, &r1) == 2) {
249 switch (sscanf(word2,
"%ld:%d:%d:%d", &cat2, &r2, &g2, &b2)) {
260 if (sscanf(word2,
"%lf:%d:%d:%d", &val2, &r2, &g2, &b2) == 4) {
265 else if (sscanf(word2,
"%lf:%d", &val2, &r2) == 2) {
292 b1, (
DCELL *) & val2, r2,
296 (
CELL *) & cat2, r2, g2, b2,
302 (
DCELL *) & val2, r2, g2, b2, colors);
305 (
CELL *) & cat2, r2, g2, b2, colors);
307 G_debug(3,
"adding rule %ld=%.2lf %d %d %d %ld=%.2lf %d %d %d",
308 cat1, val1, r1, g1, b1, cat2, val2, r2, g2, b2);
313 static int read_old_colors(FILE * fd,
struct Colors *colors)
318 float red_f, grn_f, blu_f;
328 if (fgets(buf,
sizeof buf, fd) ==
NULL)
334 if (sscanf(buf + 1,
"%ld", &min) != 1)
346 while (fgets(buf,
sizeof buf, fd)) {
348 if (sscanf(buf,
"%f %f %f", &red_f, &grn_f, &blu_f) != 3)
356 switch (sscanf(buf,
"%d %d %d", &red, &grn, &blu)) {
378 colors->
cmax = n - 1;
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_mark_colors_as_fp(struct Colors *colors)
Mark colors as floating-point.
int Rast_read_colors(const char *name, const char *mapset, struct Colors *colors)
Read color table of raster map.
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 Rast_read_range(const char *, const char *, struct Range *)
Read raster range (CELL)
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_ *)
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 G_fseek(FILE *, off_t, int)
Change the file position of the stream.
FILE * G_fopen_old(const char *, const char *, const char *)
Open a database file for reading.
void Rast_set_default_color(int, int, int, struct Colors *)
Set default color value.
int Rast__read_colors(const char *element, const char *name, const char *mapset, struct Colors *colors)
void Rast_set_null_value_color(int, int, int, struct Colors *)
Set color for NULL-value.
const char * G_find_raster(char *, const char *)
Find a raster map.
int Rast_read_fp_range(const char *, const char *, struct FPRange *)
Read floating-point range.
#define DEFAULT_COLOR_TABLE
const char * G_mapset(void)
Get current mapset name.
void G_warning(const char *,...) __attribute__((format(printf
void Rast_make_colors(struct Colors *, const char *, CELL, CELL)
Load color rules from predefined 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_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 Rast_is_c_null_value(cellVal)
int G_debug(int, const char *,...) __attribute__((format(printf
int Rast_map_is_fp(const char *, const char *)
Check if raster map is floating-point.
void Rast_get_range_min_max(const struct Range *, CELL *, CELL *)
Get range min and max.