GRASS GIS 8 Programmer's Manual
8.2.2dev(2023)-3d2c704037
|
Raster Library - Read and parse color rules file. More...
#include <stdio.h>
#include <grass/gis.h>
#include <grass/colors.h>
#include <grass/raster.h>
#include <grass/glocale.h>
Go to the source code of this file.
Enumerations | |
enum | rule_error { CR_OK = 0, CR_ERROR_RULE_SYNTAX, CR_ERROR_COLOR_SYNTAX, CR_ERROR_PERCENT, CR_ERROR_VALUE } |
Functions | |
int | Rast_parse_color_rule (DCELL min, DCELL max, const char *buf, DCELL *val, int *r, int *g, int *b, int *norm, int *nval, int *dflt) |
Read color rule. More... | |
const char * | Rast_parse_color_rule_error (int code) |
Parse color rule. More... | |
int | Rast_read_color_rule (void *closure, DCELL min, DCELL max, DCELL *val, int *r, int *g, int *b, int *norm, int *nval, int *dflt) |
Read color rule. More... | |
int | Rast_read_color_rules (struct Colors *colors, DCELL min, DCELL max, read_rule_fn *read_rule, void *closure) |
Read color rules from file. More... | |
int | Rast_load_colors (struct Colors *colors, const char *path, CELL min, CELL max) |
Load color rules from file. More... | |
int | Rast_load_fp_colors (struct Colors *colors, const char *path, DCELL min, DCELL max) |
Load color floating-point rules from file. More... | |
void | Rast_make_colors (struct Colors *colors, const char *name, CELL min, CELL max) |
Load color rules from predefined color table. More... | |
void | Rast_make_fp_colors (struct Colors *colors, const char *name, DCELL min, DCELL max) |
Load color rules from predefined floating-point color table. More... | |
Raster Library - Read and parse color rules file.
(C) 2007-2016 by the GRASS Development Team
This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.
Definition in file raster/color_rules.c.
enum rule_error |
Enumerator | |
---|---|
CR_OK | |
CR_ERROR_RULE_SYNTAX | |
CR_ERROR_COLOR_SYNTAX | |
CR_ERROR_PERCENT | |
CR_ERROR_VALUE |
Definition at line 29 of file raster/color_rules.c.
Load color rules from file.
[out] | colors | pointer to Colors structure |
path | path to the color rules file | |
min,max | min & max values (used only when color rules are in percentage) |
Definition at line 300 of file raster/color_rules.c.
Load color floating-point rules from file.
[out] | colors | pointer to Colors structure |
path | path to the color rules file | |
min,max | min & max values (used only when color rules are in percentage) |
Definition at line 316 of file raster/color_rules.c.
Load color rules from predefined color table.
[out] | colors | pointer to Colors structure |
name | name of color table to load | |
min,max | min & max values (used only when color rules are in percentage) |
Definition at line 340 of file raster/color_rules.c.
Load color rules from predefined floating-point color table.
[out] | colors | pointer to Colors structure |
name | name of color table to load | |
min,max | min & max values (used only when color rules are in percentage) |
Definition at line 353 of file raster/color_rules.c.
int Rast_parse_color_rule | ( | DCELL | min, |
DCELL | max, | ||
const char * | buf, | ||
DCELL * | val, | ||
int * | r, | ||
int * | g, | ||
int * | b, | ||
int * | norm, | ||
int * | nval, | ||
int * | dflt | ||
) |
Read color rule.
The val output parameter is always an absolute value and is derived from the rule and the min and max values in case the rule is in percents.
Always only one of the norm, nval, and dflt output parameters is set to non-zero value, the others are set to zero.
The return code can be translated to an error message using the Rast_parse_color_rule_error() function.
min,max | min & max values (used only when color rules are in percentage) | |
buf | string with the color rule | |
[out] | val | value which the color is assigned to |
[out] | r,g,b | color values |
[out] | norm | set to non-zero value if the value and color are set |
[out] | nval | set to non-zero value if rule is for null value |
[out] | dflt | set to non-zero value if rule specifies the default color |
Definition at line 60 of file raster/color_rules.c.
const char* Rast_parse_color_rule_error | ( | int | code | ) |
Parse color rule.
code |
Definition at line 114 of file raster/color_rules.c.
References _, CR_ERROR_COLOR_SYNTAX, CR_ERROR_PERCENT, CR_ERROR_RULE_SYNTAX, CR_ERROR_VALUE, and CR_OK.
int Rast_read_color_rule | ( | void * | closure, |
DCELL | min, | ||
DCELL | max, | ||
DCELL * | val, | ||
int * | r, | ||
int * | g, | ||
int * | b, | ||
int * | norm, | ||
int * | nval, | ||
int * | dflt | ||
) |
Read color rule.
closure | ||
min,max | min & max values (used only when color rules are in percentage) | |
val | value | |
[out] | r,g,b | color values |
norm | ||
nval | ||
dflt |
Definition at line 152 of file raster/color_rules.c.
int Rast_read_color_rules | ( | struct Colors * | colors, |
DCELL | min, | ||
DCELL | max, | ||
read_rule_fn * | read_rule, | ||
void * | closure | ||
) |
Read color rules from file.
[out] | colors | pointer to Colors structure |
min,max | min & max values (used only when color rules are in percentage) | |
read_rule | pointer to read_rule_fn structure | |
closure |
Definition at line 198 of file raster/color_rules.c.