GRASS 8 Programmer's Manual 8.6.0dev(2026)-f6f2c534ea
Loading...
Searching...
No Matches
color_look.c File Reference

Raster Library - Lookup array of colors. More...

#include <math.h>
#include <grass/gis.h>
#include <grass/raster.h>
Include dependency graph for color_look.c:

Go to the source code of this file.

Functions

void Rast_lookup_c_colors (const CELL *cell, unsigned char *red, unsigned char *grn, unsigned char *blu, unsigned char *set, int n, struct Colors *colors)
 Lookup an array of colors.
 
void Rast_lookup_colors (const void *raster, unsigned char *red, unsigned char *grn, unsigned char *blu, unsigned char *set, int n, struct Colors *colors, RASTER_MAP_TYPE map_type)
 Lookup an array of colors.
 
void Rast_lookup_f_colors (const FCELL *fcell, unsigned char *red, unsigned char *grn, unsigned char *blu, unsigned char *set, int n, struct Colors *colors)
 Lookup an array of colors (FCELL)
 
void Rast_lookup_d_colors (const DCELL *dcell, unsigned char *red, unsigned char *grn, unsigned char *blu, unsigned char *set, int n, struct Colors *colors)
 Lookup an array of colors (DCELL)
 
void Rast__lookup_colors (const void *raster, unsigned char *red, unsigned char *grn, unsigned char *blu, unsigned char *set, int n, struct Colors *colors, int mod, int rules_only, RASTER_MAP_TYPE data_type)
 Lookup an array of colors.
 
void Rast__interpolate_color_rule (DCELL val, unsigned char *red, unsigned char *grn, unsigned char *blu, const struct _Color_Rule_ *rule)
 Interpolate color rules.
 

Detailed Description

Raster Library - Lookup array of colors.

(C) 1999-2009 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.

Author
USACERL and many others

Definition in file color_look.c.

Function Documentation

◆ Rast__interpolate_color_rule()

void Rast__interpolate_color_rule ( DCELL  val,
unsigned char red,
unsigned char grn,
unsigned char blu,
const struct _Color_Rule_ rule 
)

Interpolate color rules.

Parameters
valraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
rulepointer to _Color_Rule which holds color rules info

Definition at line 422 of file color_look.c.

References _Color_Rule_::high.

Referenced by Rast__lookup_colors().

◆ Rast__lookup_colors()

void Rast__lookup_colors ( const void raster,
unsigned char red,
unsigned char grn,
unsigned char blu,
unsigned char set,
int  n,
struct Colors colors,
int  mod,
int  rules_only,
RASTER_MAP_TYPE  data_type 
)

Lookup an array of colors.

Parameters
rasterraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
setarray which indicates if color is set or not
nnumber of values
colorspointer to Colors structure which holds color info
mod
rules_only
data_typeraster type (CELL, FCELL, DCELL)

Definition at line 195 of file color_look.c.

References b, CELL_TYPE, Colors::fixed, g, G_incr_void_ptr, _Color_Rule_::high, Colors::invert, max, min, Colors::modular, _Color_Rule_::next, NULL, r, Rast__interpolate_color_rule(), Rast_cell_size(), Rast_get_d_value(), Rast_get_default_color(), Rast_get_null_value_color(), Rast_is_null_value(), Rast_raster_cmp(), and Colors::shift.

Referenced by Rast_lookup_c_colors(), Rast_lookup_colors(), Rast_lookup_d_colors(), and Rast_lookup_f_colors().

◆ Rast_lookup_c_colors()

void Rast_lookup_c_colors ( const CELL cell,
unsigned char red,
unsigned char grn,
unsigned char blu,
unsigned char set,
int  n,
struct Colors colors 
)

Lookup an array of colors.

Extracts colors for an array of cell values. The colors for the n values in the cell array are stored in the red, green, and blue arrays. The values in the set array will indicate if the corresponding cell value has a color or not (1 means it does, 0 means it does not).

The programmer must allocate the red, green, blue, and set arrays to be at least dimension n.

Note: The red, green, and blue intensities will be in the range 0 - 255.

Modified to return a color for NULL-values.

Parameters
cellraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
setarray which indicates if color is set or not
nnumber of values
colorspointer to Colors structure which holds color info

Definition at line 45 of file color_look.c.

References CELL_TYPE, G_zero(), Rast__lookup_colors(), and Rast__organize_colors().

Referenced by Gs_build_256lookup(), Gs_pack_colors(), Rast_print_colors(), and Rast_print_json_colors().

◆ Rast_lookup_colors()

void Rast_lookup_colors ( const void raster,
unsigned char red,
unsigned char grn,
unsigned char blu,
unsigned char set,
int  n,
struct Colors colors,
RASTER_MAP_TYPE  map_type 
)

Lookup an array of colors.

Parameters
rasterraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
setarray which indicates if color is set or not
nnumber of values
colorspointer to Colors structure which holds color info
map_typeraster type (CELL, FCELL, DCELL)

Definition at line 79 of file color_look.c.

References G_zero(), Rast__lookup_colors(), and Rast__organize_colors().

Referenced by D_draw_raster_RGB(), Rast_get_color(), Rast_get_row_colors(), and Rast_map_to_img_str().

◆ Rast_lookup_d_colors()

void Rast_lookup_d_colors ( const DCELL dcell,
unsigned char red,
unsigned char grn,
unsigned char blu,
unsigned char set,
int  n,
struct Colors colors 
)

Lookup an array of colors (DCELL)

Converts the n double-precision values in the dcell array to their r,g,b color components. Embedded NULL-values are handled properly as well.

Parameters
dcellraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
setarray which indicates if color is set or not
nnumber of values
colorspointer to Colors structure which holds color info

Definition at line 146 of file color_look.c.

References DCELL_TYPE, G_zero(), Rast__lookup_colors(), and Rast__organize_colors().

◆ Rast_lookup_f_colors()

void Rast_lookup_f_colors ( const FCELL fcell,
unsigned char red,
unsigned char grn,
unsigned char blu,
unsigned char set,
int  n,
struct Colors colors 
)

Lookup an array of colors (FCELL)

Converts the n floating-point values in the fcell array to their r,g,b color components. Embedded NULL-values are handled properly as well.

Parameters
fcellraster cell value
[out]redred value
[out]grngreen value
[out]blublue value
setarray which indicates if color is set or not
nnumber of values
colorspointer to Colors structure which holds color info

Definition at line 112 of file color_look.c.

References FCELL_TYPE, G_zero(), Rast__lookup_colors(), and Rast__organize_colors().

Referenced by Gs_pack_colors_float().