39 unsigned char *red,
unsigned char *grn,
40 unsigned char *blu,
unsigned char *
set,
int n,
41 struct Colors *colors)
77 unsigned char *red,
unsigned char *grn,
78 unsigned char *blu,
unsigned char *
set,
int n,
79 struct Colors *colors)
83 G_zero((
char *)set, n *
sizeof(
unsigned char));
119 unsigned char *red,
unsigned char *grn,
120 unsigned char *blu,
unsigned char *
set,
int n,
121 struct Colors *colors, RASTER_MAP_TYPE map_type)
126 G_zero((
char *)set, n *
sizeof(
unsigned char));
156 unsigned char *grn,
unsigned char *blu,
157 unsigned char *
set,
int n,
struct Colors *colors)
162 G_zero((
char *)set, n *
sizeof(
unsigned char));
194 unsigned char *grn,
unsigned char *blu,
195 unsigned char *
set,
int n,
struct Colors *colors)
200 G_zero((
char *)set, n *
sizeof(
unsigned char));
214 static int less_or_equal(
double x,
double y)
222 static int less(
double x,
double y)
232 unsigned char *grn,
unsigned char *blu,
233 unsigned char *
set,
int n,
struct Colors *colors,
234 int mod,
int rules_only, RASTER_MAP_TYPE data_type)
236 struct _Color_Info_ *cp;
237 struct _Color_Rule_ *
rule;
238 DCELL
dmin,
dmax, val, dmod = 0L, shift;
240 register const void *ptr, *last_ptr =
NULL;
244 int lookup, max_ind, min_ind,
try;
248 cp = &colors->modular;
261 max = (CELL) dmax + 1;
263 cell_type = (data_type == CELL_TYPE);
266 shift = invert = lookup = mod = 0;
277 shift = colors->shift;
278 invert = colors->invert;
279 lookup = cp->lookup.active;
289 if (ptr != raster &&
G_raster_cmp(ptr, last_ptr, data_type) == 0) {
316 if (shift && val >= dmin && val <= dmax) {
319 val += dmax - dmin + 1;
321 val -= dmax - dmin + 1;
326 val = dmin + dmax - val;
333 val = val - dmod * floor(val / dmod);
348 if (lookup && ((
double)cat - val == 0.)) {
349 if (cat >= min && cat <= max) {
351 if (cp->lookup.set[cat]) {
352 *red = cp->lookup.red[
cat];
353 *grn = cp->lookup.grn[
cat];
354 *blu = cp->lookup.blu[
cat];
367 if (cp->fp_lookup.active) {
368 try = (cp->fp_lookup.nalloc - 1) / 2;
370 max_ind = cp->fp_lookup.nalloc - 2;
374 if (cp->fp_lookup.rules[
try])
377 lower = less_or_equal;
385 if (lower(cp->fp_lookup.vals[
try + 1], val)) {
388 try = (max_ind + min_ind) / 2;
389 if (min_ind > max_ind) {
395 if (lower(val, cp->fp_lookup.vals[
try])) {
398 try = (max_ind + min_ind) / 2;
399 if (max_ind < min_ind) {
405 rule = cp->fp_lookup.rules[
try];
411 for (rule = cp->rules; rule; rule = rule->next) {
416 if (rule->low.value <= val && val <= rule->high.value)
447 unsigned char *grn,
unsigned char *blu,
448 const struct _Color_Rule_ *
rule)
452 if ((delta = rule->high.value - rule->low.value)) {
453 val -= rule->low.value;
456 (
int)(val * (
double)((
int)rule->high.red - (
int)rule->low.red) /
458 + (
int)rule->low.red;
460 (
int)(val * (double)((
int)rule->high.grn - (
int)rule->low.grn) /
462 + (
int)rule->low.grn;
464 (
int)(val * (
double)((
int)rule->high.blu - (
int)rule->low.blu) /
466 + (
int)rule->low.blu;
469 *red = rule->low.red;
470 *grn = rule->low.grn;
471 *blu = rule->low.blu;
int G_lookup_raster_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)
If the cell_type is CELL_TYPE, calls G_lookup_colors((CELL *)cell, r, g, b, set, n, colors); If the cell_type is FCELL_TYPE, calls G_lookup_f_raster_colors(FCELL *)cell, r, g, b, set, n, colors); If the cell_type is DCELL_TYPE, calls G_lookup_d_raster_colors(DCELL *)cell, r, g, b, set, n, colors);.
int G_get_null_value_color(int *red, int *grn, int *blu, const struct Colors *colors)
Gets color for null value.
int G_lookup_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
int G_lookup_f_raster_colors(const FCELL *fcell, unsigned char *red, unsigned char *grn, unsigned char *blu, unsigned char *set, int n, struct Colors *colors)
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.
void * G_incr_void_ptr(const void *ptr, const size_t size)
Advance void pointer.
int G_zero(void *buf, int i)
Zero out a buffer, buf, of length i.
int G_get_default_color(int *red, int *grn, int *blu, const struct Colors *colors)
Gets default color.
size_t G_raster_size(RASTER_MAP_TYPE data_type)
Returns size of a raster CELL in bytes.
int G__organize_colors(struct Colors *colors)
int G__interpolate_color_rule(DCELL val, unsigned char *red, unsigned char *grn, unsigned char *blu, const struct _Color_Rule_ *rule)
int G_raster_cmp(const void *v1, const void *v2, RASTER_MAP_TYPE data_type)
Compares raster values p and q.
int G_lookup_d_raster_colors(const DCELL *dcell, unsigned char *red, unsigned char *grn, unsigned char *blu, unsigned char *set, int n, struct Colors *colors)
Converts the n floating-point values in the dcell array to their r,g,b color components. Embedded NULL-values are handled properly as well.
int G__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)
DCELL G_get_raster_value_d(const void *rast, RASTER_MAP_TYPE data_type)
Retrieves the value of type data_type from pointer p,.
int G_is_null_value(const void *rast, RASTER_MAP_TYPE data_type)
If the data_type is CELL_TYPE, calls G_is_c_null_value ((CELL *) rast); If the data_type is FCELL_TYP...
int G_lookup_c_raster_colors(const CELL *cell, unsigned char *red, unsigned char *grn, unsigned char *blu, unsigned char *set, int n, struct Colors *colors)
The same as G_lookup_colors(cell, r, g, b, set, n, colors).