|
GRASS 8 Programmer's Manual 8.6.0dev(2026)-8843f13794
|
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. | |
| const char * | Rast_parse_color_rule_error (int code) |
| Parse color rule. | |
| 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. | |
| int | Rast_read_color_rules (struct Colors *colors, DCELL min, DCELL max, read_rule_fn *read_rule, void *closure) |
| Read color rules from file. | |
| int | Rast_load_colors (struct Colors *colors, const char *path, CELL min, CELL max) |
| Load color rules from file. | |
| int | Rast_load_fp_colors (struct Colors *colors, const char *path, DCELL min, DCELL max) |
| Load color floating-point rules from file. | |
| void | Rast_make_colors (struct Colors *colors, const char *name, CELL min, CELL max) |
| Load color rules from predefined color table. | |
| void | Rast_make_fp_colors (struct Colors *colors, const char *name, DCELL min, DCELL max) |
| Load color rules from predefined floating-point color table. | |
Raster Library - Read and parse color rules file.
SPDX-FileCopyrightText: 2007-2016 GRASS Development Team SPDX-License-Identifier: GPL-2.0-or-later
Definition in file raster/color_rules.c.
| Enumerator | |
|---|---|
| CR_OK | |
| CR_ERROR_RULE_SYNTAX | |
| CR_ERROR_COLOR_SYNTAX | |
| CR_ERROR_PERCENT | |
| CR_ERROR_VALUE | |
Definition at line 25 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 290 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 307 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 332 of file raster/color_rules.c.
References max, min, and name.
Referenced by Rast_make_aspect_colors(), Rast_make_bgyr_colors(), Rast_make_byg_colors(), Rast_make_byr_colors(), Rast_make_grey_scale_colors(), Rast_make_gyr_colors(), Rast_make_rainbow_colors(), Rast_make_ramp_colors(), Rast_make_ryg_colors(), Rast_make_wave_colors(), and Rast_read_colors().
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 346 of file raster/color_rules.c.
References max, min, and name.
Referenced by Rast3d_read_colors(), Rast_make_aspect_fp_colors(), Rast_make_bgyr_fp_colors(), Rast_make_byg_fp_colors(), Rast_make_byr_fp_colors(), Rast_make_grey_scale_fp_colors(), Rast_make_gyr_fp_colors(), Rast_make_rainbow_fp_colors(), Rast_make_ramp_fp_colors(), Rast_make_ryg_fp_colors(), Rast_make_wave_fp_colors(), and Rast_read_colors().
| 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 54 of file raster/color_rules.c.
References b, CR_ERROR_COLOR_SYNTAX, CR_ERROR_PERCENT, CR_ERROR_RULE_SYNTAX, CR_ERROR_VALUE, CR_OK, g, G_chop(), G_str_to_color(), G_strcasecmp(), max, min, r, and x.
Referenced by Rast_read_color_rule().
Parse color rule.
| code |
Definition at line 108 of file raster/color_rules.c.
References _, CR_ERROR_COLOR_SYNTAX, CR_ERROR_PERCENT, CR_ERROR_RULE_SYNTAX, CR_ERROR_VALUE, and CR_OK.
Referenced by Rast_read_color_rule().
| 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 144 of file raster/color_rules.c.
References _, b, g, G_debug(), G_fatal_error(), G_getl2(), G_strip(), max, min, r, Rast_parse_color_rule(), and Rast_parse_color_rule_error().
Referenced by Rast_read_color_rules().
| 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 188 of file raster/color_rules.c.
References _, b, g, G_fatal_error(), G_free(), G_realloc, max, min, NULL, r, Rast_add_d_color_rule(), Rast_init_colors(), Rast_read_color_rule(), Rast_set_d_color(), Rast_set_default_color(), and Rast_set_null_value_color().