GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
color_rule.c File Reference

GIS Library - Color rules. More...

#include <grass/gis.h>
Include dependency graph for color_rule.c:

Go to the source code of this file.

Macros

#define LIMIT(x)   if (x < 0) x = 0; else if (x > 255) x = 255;
 

Functions

int G_add_d_raster_color_rule (const DCELL *val1, int r1, int g1, int b1, const DCELL *val2, int r2, int g2, int b2, struct Colors *colors)
 Adds the floating-point rule (DCELL version) More...
 
int G_add_f_raster_color_rule (const FCELL *cat1, int r1, int g1, int b1, const FCELL *cat2, int r2, int g2, int b2, struct Colors *colors)
 Adds the floating-point rule (FCELL version) More...
 
int G_add_c_raster_color_rule (const CELL *cat1, int r1, int g1, int b1, const CELL *cat2, int r2, int g2, int b2, struct Colors *colors)
 Adds the floating-point rule (CCELL version) More...
 
int G_add_raster_color_rule (const void *val1, int r1, int g1, int b1, const void *val2, int r2, int g2, int b2, struct Colors *colors, RASTER_MAP_TYPE data_type)
 Adds the floating-point rule. More...
 
int G_add_color_rule (CELL cat1, int r1, int g1, int b1, CELL cat2, int r2, int g2, int b2, struct Colors *colors)
 Set colors rules. More...
 
int G_add_modular_d_raster_color_rule (const DCELL *val1, int r1, int g1, int b1, const DCELL *val2, int r2, int g2, int b2, struct Colors *colors)
 Add modular color rule (DCELL version) More...
 
int G_add_modular_f_raster_color_rule (const FCELL *val1, int r1, int g1, int b1, const FCELL *val2, int r2, int g2, int b2, struct Colors *colors)
 Add modular color rule (FCELL version) More...
 
int G_add_modular_c_raster_color_rule (const CELL *val1, int r1, int g1, int b1, const CELL *val2, int r2, int g2, int b2, struct Colors *colors)
 Add modular color rule (CCELL version) More...
 
int G_add_modular_raster_color_rule (const void *val1, int r1, int g1, int b1, const void *val2, int r2, int g2, int b2, struct Colors *colors, RASTER_MAP_TYPE data_type)
 Add modular color rule. More...
 
int G_add_modular_color_rule (CELL cat1, int r1, int g1, int b1, CELL cat2, int r2, int g2, int b2, struct Colors *colors)
 Add modular color rule. More...
 

Detailed Description

GIS Library - Color rules.

(C) 2001-2008 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
GRASS GIS Development Team
Date
1999-2008

Definition in file color_rule.c.

Macro Definition Documentation

#define LIMIT (   x)    if (x < 0) x = 0; else if (x > 255) x = 255;

Definition at line 19 of file color_rule.c.

Function Documentation

int G_add_c_raster_color_rule ( const CELL *  cat1,
int  r1,
int  g1,
int  b1,
const CELL *  cat2,
int  r2,
int  g2,
int  b2,
struct Colors *  colors 
)

Adds the floating-point rule (CCELL version)

See G_add_raster_color_rule() for details.

Parameters
v1cell value
r1,g1,b1color value
v2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure
Returns
1

Definition at line 89 of file color_rule.c.

int G_add_color_rule ( CELL  cat1,
int  r1,
int  g1,
int  b1,
CELL  cat2,
int  r2,
int  g2,
int  b2,
struct Colors *  colors 
)

Set colors rules.

This is the heart and soul of the new color logic. It adds a color rule to the colors structure. The colors defined by the red, green, and blue values r1,g1,b1 and r2,g2,b2 are assigned to cat1 and cat2 respectively. Colors for data values between cat1 and cat2 are not stored in the structure but are interpolated when queried by G_lookup_colors andG_get_color. The color components r1,g1,b1 and r2,g2,b2 must be in the range 0 – 255. For example, to create a linear grey scale for the range 200 – 1000:

struct Colors colr;
G_init_colors (&colr);
G_add_color_rule ((CELL)200, 0,0,0, (CELL)1000, 255,255,255);

The programmer is encouraged to review Raster_Color_Table_Format how this routine fits into the 5.x raster color logic. Note. The colors structure must have been initialized by G_init_colors. See Predefined_Color_Tables for routines to build some predefined color tables.

Parameters
cat1cell value
r1,g1,b1color value
cat2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure
Returns
1

Definition at line 165 of file color_rule.c.

Referenced by G_histogram_eq_colors(), G_make_histogram_eq_colors(), G_make_histogram_log_colors(), G_set_color(), IL_output_2d(), and IL_resample_output_2d().

int G_add_d_raster_color_rule ( const DCELL *  val1,
int  r1,
int  g1,
int  b1,
const DCELL *  val2,
int  r2,
int  g2,
int  b2,
struct Colors *  colors 
)

Adds the floating-point rule (DCELL version)

See G_add_raster_color_rule() for details.

Parameters
v1cell value
r1,g1,b1color value
v2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure
Returns
1

Definition at line 41 of file color_rule.c.

Referenced by G_abs_log_colors(), G_histogram_eq_colors_fp(), G_log_colors(), G_read_color_rules(), G_set_d_color(), and IL_resample_output_2d().

int G_add_f_raster_color_rule ( const FCELL *  cat1,
int  r1,
int  g1,
int  b1,
const FCELL *  cat2,
int  r2,
int  g2,
int  b2,
struct Colors *  colors 
)

Adds the floating-point rule (FCELL version)

See G_add_raster_color_rule() for details.

Parameters
v1cell value
r1,g1,b1color value
v2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure
Returns
1

Definition at line 65 of file color_rule.c.

Referenced by IL_output_2d(), and IL_resample_output_2d().

int G_add_modular_c_raster_color_rule ( const CELL *  val1,
int  r1,
int  g1,
int  b1,
const CELL *  val2,
int  r2,
int  g2,
int  b2,
struct Colors *  colors 
)

Add modular color rule (CCELL version)

Parameters
val1cell value
r1,g1,b1color value
val2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure
Returns
-1 on failure
1 on success

Definition at line 249 of file color_rule.c.

References G_add_modular_color_rule().

int G_add_modular_color_rule ( CELL  cat1,
int  r1,
int  g1,
int  b1,
CELL  cat2,
int  r2,
int  g2,
int  b2,
struct Colors *  colors 
)

Add modular color rule.

This function seems to be same as G_add_modular_raster_color_rule(). Can be removed?

Parameters
val1cell value
r1,g1,b1color value
val2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure
data_typeraster data type
Returns
-1 on failure
1 on success

Definition at line 310 of file color_rule.c.

References max, and min.

Referenced by G_add_modular_c_raster_color_rule(), and G_make_random_colors().

int G_add_modular_d_raster_color_rule ( const DCELL *  val1,
int  r1,
int  g1,
int  b1,
const DCELL *  val2,
int  r2,
int  g2,
int  b2,
struct Colors *  colors 
)

Add modular color rule (DCELL version)

Parameters
val1cell value
r1,g1,b1color value
val2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure
Returns
-1 on failure
1 on success

Definition at line 187 of file color_rule.c.

References max, and min.

Referenced by IL_resample_output_2d().

int G_add_modular_f_raster_color_rule ( const FCELL *  val1,
int  r1,
int  g1,
int  b1,
const FCELL *  val2,
int  r2,
int  g2,
int  b2,
struct Colors *  colors 
)

Add modular color rule (FCELL version)

Parameters
val1cell value
r1,g1,b1color value
val2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure
Returns
-1 on failure
1 on success

Definition at line 218 of file color_rule.c.

References max, and min.

int G_add_modular_raster_color_rule ( const void *  val1,
int  r1,
int  g1,
int  b1,
const void *  val2,
int  r2,
int  g2,
int  b2,
struct Colors *  colors,
RASTER_MAP_TYPE  data_type 
)

Add modular color rule.

Question: shouldn't this function call G_add_modular_<data_type>_raster_color_rule() instead???

Parameters
val1cell value
r1,g1,b1color value
val2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure
data_typeraster data type
Returns
-1 on failure
1 on success

Definition at line 274 of file color_rule.c.

References max, and min.

int G_add_raster_color_rule ( const void *  val1,
int  r1,
int  g1,
int  b1,
const void *  val2,
int  r2,
int  g2,
int  b2,
struct Colors *  colors,
RASTER_MAP_TYPE  data_type 
)

Adds the floating-point rule.

Adds the floating-point rule that the range [v1,v2] gets a linear ramp of colors from [r1,g1,b1] to [r2,g2,b2]. If either v1 or v2 is the NULL-value, this call is converted into G_set_null_value_color (r1, g1, b1, colors)

Parameters
v1cell value
r1,g1,b1color value
v2cell value
r2,g2,b2color value
[in,out]colorspointer to color table structure
data_typeraster data type (CELL, FCELL, DCELL)
Returns
1

Definition at line 122 of file color_rule.c.