GRASS GIS 7 Programmer's Manual  7.5.svn(2018)-r72721
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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. More...
 
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. More...
 
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) More...
 
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) More...
 
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. More...
 
void Rast__interpolate_color_rule (DCELL val, unsigned char *red, unsigned char *grn, unsigned char *blu, const struct _Color_Rule_ *rule)
 Interpolate color rules. More...
 

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

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 417 of file color_look.c.

References _Color_Value_::blu, _Color_Value_::grn, _Color_Rule_::high, int, _Color_Value_::red, and _Color_Value_::value.

Referenced by 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 _Color_Info_::active, b, _Color_Info_::blu, cat, CELL_TYPE, Colors::fixed, _Color_Info_::fp_lookup, g, G_incr_void_ptr(), _Color_Info_::grn, _Color_Rule_::high, int, Colors::invert, _Color_Info_::lookup, max, _Color_Info_::max, min, _Color_Info_::min, Colors::modular, _Color_Info_::nalloc, _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(), _Color_Info_::red, _Color_Info_::rules, _Color_Info_::set, Colors::shift, _Color_Info_::vals, and _Color_Value_::value.

Referenced by Rast_lookup_c_colors(), Rast_lookup_colors(), Rast_lookup_d_colors(), and Rast_lookup_f_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(), and Rast_print_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().

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().

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 113 of file color_look.c.

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

Referenced by Gs_pack_colors_float().