Browse Source

rasterlib: fns from color_look.c renamed, see
http://trac.osgeo.org/grass/wiki/Grass7/RasterLib


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@38110 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 16 years ago
parent
commit
325604d01d

+ 15 - 17
include/raster.h

@@ -136,25 +136,23 @@ int Rast__insert_color_into_lookup(CELL, int, int, int, struct _Color_Info_ *);
 int Rast_invert_colors(struct Colors *);
 int Rast_invert_colors(struct Colors *);
 
 
 /* color_look.c */
 /* color_look.c */
-void Rast_lookup_colors(const CELL *, unsigned char *, unsigned char *,
-		     unsigned char *, unsigned char *, int, struct Colors *);
-void Rast_lookup_c_raster_colors(const CELL *, unsigned char *, unsigned char *,
-			      unsigned char *, unsigned char *, int,
-			      struct Colors *);
-void Rast_lookup_raster_colors(const void *, unsigned char *, unsigned char *,
-			    unsigned char *, unsigned char *, int,
-			    struct Colors *, RASTER_MAP_TYPE);
-void Rast_lookup_f_raster_colors(const FCELL *, unsigned char *, unsigned char *,
-			     unsigned char *, unsigned char *, int,
-			     struct Colors *);
-void Rast_lookup_d_raster_colors(const DCELL *, unsigned char *, unsigned char *,
-			     unsigned char *, unsigned char *, int,
-			     struct Colors *);
+void Rast_lookup_c_colors(const CELL *, unsigned char *, unsigned char *,
+			  unsigned char *, unsigned char *, int,
+			  struct Colors *);
+void Rast_lookup_colors(const void *, unsigned char *, unsigned char *,
+			unsigned char *, unsigned char *, int,
+			struct Colors *, RASTER_MAP_TYPE);
+void Rast_lookup_f_colors(const FCELL *, unsigned char *, unsigned char *,
+			  unsigned char *, unsigned char *, int,
+			  struct Colors *);
+void Rast_lookup_d_colors(const DCELL *, unsigned char *, unsigned char *,
+			  unsigned char *, unsigned char *, int,
+			  struct Colors *);
 void Rast__lookup_colors(const void *, unsigned char *, unsigned char *,
 void Rast__lookup_colors(const void *, unsigned char *, unsigned char *,
-		      unsigned char *, unsigned char *, int, struct Colors *,
-		      int, int, RASTER_MAP_TYPE);
+			 unsigned char *, unsigned char *, int, struct Colors *,
+			 int, int, RASTER_MAP_TYPE);
 void Rast__interpolate_color_rule(DCELL, unsigned char *, unsigned char *,
 void Rast__interpolate_color_rule(DCELL, unsigned char *, unsigned char *,
-			       unsigned char *, const struct _Color_Rule_ *);
+				  unsigned char *, const struct _Color_Rule_ *);
 
 
 /* color_org.c */
 /* color_org.c */
 void Rast__organize_colors(struct Colors *);
 void Rast__organize_colors(struct Colors *);

+ 4 - 4
lib/display/raster.c

@@ -100,7 +100,7 @@ static int draw_cell(int A_row,
 	set = G_realloc(set, nalloc);
 	set = G_realloc(set, nalloc);
     }
     }
 
 
-    Rast_lookup_raster_colors(array, red, grn, blu, set, ncols, colors,
+    Rast_lookup_colors(array, red, grn, blu, set, ncols, colors,
 			   data_type);
 			   data_type);
 
 
     if (D__overlay_mode)
     if (D__overlay_mode)
@@ -165,11 +165,11 @@ int D_draw_raster_RGB(int A_row,
     }
     }
 
 
     /* convert cell values to bytes */
     /* convert cell values to bytes */
-    Rast_lookup_raster_colors(r_raster, r_buf, n_buf, n_buf, n_buf, ncols,
+    Rast_lookup_colors(r_raster, r_buf, n_buf, n_buf, n_buf, ncols,
 			   r_colors, r_type);
 			   r_colors, r_type);
-    Rast_lookup_raster_colors(g_raster, n_buf, g_buf, n_buf, n_buf, ncols,
+    Rast_lookup_colors(g_raster, n_buf, g_buf, n_buf, n_buf, ncols,
 			   g_colors, g_type);
 			   g_colors, g_type);
-    Rast_lookup_raster_colors(b_raster, n_buf, n_buf, b_buf, n_buf, ncols,
+    Rast_lookup_colors(b_raster, n_buf, n_buf, b_buf, n_buf, ncols,
 			   b_colors, b_type);
 			   b_colors, b_type);
 
 
     if (D__overlay_mode)
     if (D__overlay_mode)

+ 1 - 1
lib/ogsf/Gs3.c

@@ -781,7 +781,7 @@ void Gs_pack_colors_float(const char *filename, float *fbuf, int *ibuf,
     G_message(_("Translating colors from raster map <%s>..."), filename);
     G_message(_("Translating colors from raster map <%s>..."), filename);
 
 
     for (i = 0; i < rows; i++) {
     for (i = 0; i < rows; i++) {
-	Rast_lookup_f_raster_colors(fcur, r, g, b, set, cols, &colrules);
+	Rast_lookup_f_colors(fcur, r, g, b, set, cols, &colrules);
 	G_percent(i, rows, 2);
 	G_percent(i, rows, 2);
 
 
 	for (j = 0; j < cols; j++) {
 	for (j = 0; j < cols; j++) {

+ 1 - 1
lib/raster/color_get.c

@@ -41,7 +41,7 @@ int Rast_get_color(const void *rast,
 {
 {
     unsigned char r, g, b, set;
     unsigned char r, g, b, set;
 
 
-    Rast_lookup_raster_colors(rast, &r, &g, &b, &set, 1, colors, map_type);
+    Rast_lookup_colors(rast, &r, &g, &b, &set, 1, colors, map_type);
 
 
     *red = (int)r;
     *red = (int)r;
     *grn = (int)g;
     *grn = (int)g;

+ 21 - 56
lib/raster/color_look.c

@@ -20,41 +20,6 @@
 /*!
 /*!
  * \brief Lookup an array of colors
  * \brief Lookup an array of colors
  *
  *
- * \todo To be removed, replaced by Rast_lookup_c_raster_colors().
- *
- * Extracts colors for an array of <i>cell</i> values. The colors
- * for the <i>n</i> values in the <i>cell</i> array are stored in
- * the <i>red, green</i>, and <i>blue</i> arrays. The values in the
- * <i>set</i> array will indicate if the corresponding <i>cell</i>
- * value has a color or not (1 means it does, 0 means it does not).
- *
- * The programmer must allocate the <i>red, green, blue</i>, and
- * <b>set</b> arrays to be at least dimension <i>n</i>.
- *
- * <b>Note:</b> The <i>red, green</i>, and <i>blue</i> intensities
- * will be in the range 0 -­ 255.
- *
- * Modified to return a color for NULL-values.
- *
- * \param cell raster cell value
- * \param[out] red red value
- * \param[out] grn green value
- * \param[out] blu blue value
- * \param set array which indicates if color is set or not
- * \param n number of values
- * \param colors pointer to Colors structure which holds color info
- */
-void Rast_lookup_colors(const CELL * cell,
-		     unsigned char *red, unsigned char *grn,
-		     unsigned char *blu, unsigned char *set, int n,
-		     struct Colors *colors)
-{
-    Rast_lookup_c_raster_colors(cell, red, grn, blu, set, n, colors);
-}
-
-/*!
- * \brief Lookup an array of colors
- *
  * Extracts colors for an array of <i>cell</i> values. The colors
  * Extracts colors for an array of <i>cell</i> values. The colors
  * for the <i>n</i> values in the <i>cell</i> array are stored in
  * for the <i>n</i> values in the <i>cell</i> array are stored in
  * the <i>red, green</i>, and <i>blue</i> arrays. The values in the
  * the <i>red, green</i>, and <i>blue</i> arrays. The values in the
@@ -77,10 +42,10 @@ void Rast_lookup_colors(const CELL * cell,
  * \param n number of values
  * \param n number of values
  * \param colors pointer to Colors structure which holds color info
  * \param colors pointer to Colors structure which holds color info
  */
  */
-void Rast_lookup_c_raster_colors(const CELL * cell,
-			      unsigned char *red, unsigned char *grn,
-			      unsigned char *blu, unsigned char *set, int n,
-			      struct Colors *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)
 {
 {
     Rast__organize_colors(colors);	/* make sure the lookup tables are in place */
     Rast__organize_colors(colors);	/* make sure the lookup tables are in place */
 
 
@@ -99,8 +64,8 @@ void Rast_lookup_c_raster_colors(const CELL * cell,
  * \brief Lookup an array of colors
  * \brief Lookup an array of colors
  *
  *
  * - If the <em>map_type</em> is CELL_TYPE, calls Rast_lookup_colors()
  * - If the <em>map_type</em> is CELL_TYPE, calls Rast_lookup_colors()
- * - If the <em>map_type</em> is FCELL_TYPE, calls Rast_lookup_f_raster_colors()
- * - If the <em>map_type</em> is DCELL_TYPE, calls Rast_lookup_d_raster_colors()
+ * - If the <em>map_type</em> is FCELL_TYPE, calls Rast_lookup_f_colors()
+ * - If the <em>map_type</em> is DCELL_TYPE, calls Rast_lookup_d_colors()
  *
  *
  * \param raster raster cell value
  * \param raster raster cell value
  * \param[out] red red value
  * \param[out] red red value
@@ -111,10 +76,10 @@ void Rast_lookup_c_raster_colors(const CELL * cell,
  * \param colors pointer to Colors structure which holds color info
  * \param colors pointer to Colors structure which holds color info
  * \param map_type raster type (CELL, FCELL, DCELL)
  * \param map_type raster type (CELL, FCELL, DCELL)
  */
  */
-void Rast_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)
+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)
 {
 {
     Rast__organize_colors(colors);	/* make sure the lookup tables are in place */
     Rast__organize_colors(colors);	/* make sure the lookup tables are in place */
     /* in case of float color rules, fp_lookup table is created */
     /* in case of float color rules, fp_lookup table is created */
@@ -143,9 +108,9 @@ void Rast_lookup_raster_colors(const void *raster,
  * \param n number of values
  * \param n number of values
  * \param colors pointer to Colors structure which holds color info
  * \param colors pointer to Colors structure which holds color info
  */
  */
-void Rast_lookup_f_raster_colors(const FCELL * fcell, unsigned char *red,
-			      unsigned char *grn, unsigned char *blu,
-			      unsigned char *set, int n, struct Colors *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)
 {
 {
     Rast__organize_colors(colors);	/* make sure the lookup tables are in place */
     Rast__organize_colors(colors);	/* make sure the lookup tables are in place */
     /* in case of float color rules, fp_lookup table is created */
     /* in case of float color rules, fp_lookup table is created */
@@ -176,9 +141,9 @@ void Rast_lookup_f_raster_colors(const FCELL * fcell, unsigned char *red,
  * \param n number of values
  * \param n number of values
  * \param colors pointer to Colors structure which holds color info
  * \param colors pointer to Colors structure which holds color info
  */
  */
-void Rast_lookup_d_raster_colors(const DCELL * dcell, unsigned char *red,
-			      unsigned char *grn, unsigned char *blu,
-			      unsigned char *set, int n, struct Colors *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)
 {
 {
     Rast__organize_colors(colors);	/* make sure the lookup tables are in place */
     Rast__organize_colors(colors);	/* make sure the lookup tables are in place */
     /* in case of float color rules, fp_lookup table is created */
     /* in case of float color rules, fp_lookup table is created */
@@ -226,9 +191,9 @@ static int less(double x, double y)
  * \param data_type raster type (CELL, FCELL, DCELL)
  * \param data_type raster type (CELL, FCELL, DCELL)
  */
  */
 void Rast__lookup_colors(const void *raster, unsigned char *red,
 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)
+			 unsigned char *grn, unsigned char *blu,
+			 unsigned char *set, int n, struct Colors *colors,
+			 int mod, int rules_only, RASTER_MAP_TYPE data_type)
 {
 {
     struct _Color_Info_ *cp;
     struct _Color_Info_ *cp;
     struct _Color_Rule_ *rule;
     struct _Color_Rule_ *rule;
@@ -448,8 +413,8 @@ void Rast__lookup_colors(const void *raster, unsigned char *red,
   \param rule pointer to _Color_Rule which holds color rules info
   \param rule pointer to _Color_Rule which holds color rules info
 */
 */
 void Rast__interpolate_color_rule(DCELL val, unsigned char *red,
 void Rast__interpolate_color_rule(DCELL val, unsigned char *red,
-			       unsigned char *grn, unsigned char *blu,
-			       const struct _Color_Rule_ *rule)
+				  unsigned char *grn, unsigned char *blu,
+				  const struct _Color_Rule_ *rule)
 {
 {
     DCELL delta;
     DCELL delta;
 
 

+ 1 - 1
lib/raster/get_row_colr.c

@@ -62,7 +62,7 @@ int Rast_get_raster_row_colors(int fd, int row, struct Colors *colors,
 
 
     set = G__alloca(cols);
     set = G__alloca(cols);
 
 
-    Rast_lookup_raster_colors(array, red, grn, blu, set, cols, colors, type);
+    Rast_lookup_colors(array, red, grn, blu, set, cols, colors, type);
 
 
     G__freea(array);
     G__freea(array);
     G__freea(set);
     G__freea(set);

+ 1 - 1
raster/r.mapcalc/map.c

@@ -232,7 +232,7 @@ static void translate_from_colors(struct map *m, DCELL *rast, CELL *cell,
     unsigned char *set = G__alloca(columns);
     unsigned char *set = G__alloca(columns);
     int i;
     int i;
 
 
-    Rast_lookup_d_raster_colors(rast, red, grn, blu, set, ncols, &m->colors);
+    Rast_lookup_d_colors(rast, red, grn, blu, set, ncols, &m->colors);
 
 
     switch (mod) {
     switch (mod) {
     case 'r':
     case 'r':

+ 1 - 1
raster/r.mapcalc/map3.c

@@ -200,7 +200,7 @@ static void translate_from_colors(map * m, DCELL * rast, CELL * cell,
 {
 {
     int i;
     int i;
 
 
-    Rast_lookup_d_raster_colors(rast, red, grn, blu, set, ncols, &m->colors);
+    Rast_lookup_d_colors(rast, red, grn, blu, set, ncols, &m->colors);
 
 
     switch (mod) {
     switch (mod) {
     case 'r':
     case 'r':

+ 1 - 1
raster/r.out.mpeg/main.c

@@ -298,7 +298,7 @@ static int load_files(void)
 		    G_fatal_error(_("Error reading row <%d>"), row);
 		    G_fatal_error(_("Error reading row <%d>"), row);
 
 
 		rowoff = (vyoff + row) * ncols;
 		rowoff = (vyoff + row) * ncols;
-		Rast_lookup_raster_colors(voidc, tr, tg, tb,
+		Rast_lookup_colors(voidc, tr, tg, tb,
 				       tset, tsiz, &colors, rtype);
 				       tset, tsiz, &colors, rtype);
 
 
 		for (col = 0; col < vcols; col++) {
 		for (col = 0; col < vcols; col++) {

+ 2 - 2
raster/r.out.png/main.c

@@ -254,8 +254,8 @@ int main(int argc, char *argv[])
 		G_percent(row, w.rows, 5);
 		G_percent(row, w.rows, 5);
 		if (Rast_get_raster_row(cellfile, (void *)voidc, row, rtype) < 0)
 		if (Rast_get_raster_row(cellfile, (void *)voidc, row, rtype) < 0)
 		    exit(EXIT_FAILURE);
 		    exit(EXIT_FAILURE);
-		Rast_lookup_raster_colors((void *)voidc, ored, ogrn, oblu, set,
-				       w.cols, &colors, rtype);
+		Rast_lookup_colors((void *)voidc, ored, ogrn, oblu, set,
+				   w.cols, &colors, rtype);
 
 
 		pp = line;
 		pp = line;
 
 

+ 4 - 4
raster/r.out.ppm/main.c

@@ -166,8 +166,8 @@ int main(int argc, char *argv[])
 		if (Rast_get_raster_row(cellfile, (void *)voidc, row, rtype) < 0)
 		if (Rast_get_raster_row(cellfile, (void *)voidc, row, rtype) < 0)
 		    G_fatal_error(_("Unable to read raster map <%s> row %d"),
 		    G_fatal_error(_("Unable to read raster map <%s> row %d"),
 				  rast->answer, row);
 				  rast->answer, row);
-		Rast_lookup_raster_colors((void *)voidc, ored, ogrn, oblu, set,
-				       w.cols, &colors, rtype);
+		Rast_lookup_colors((void *)voidc, ored, ogrn, oblu, set,
+				   w.cols, &colors, rtype);
 
 
 		for (col = 0; col < w.cols; col++) {
 		for (col = 0; col < w.cols; col++) {
 		    if (set[col]) {
 		    if (set[col]) {
@@ -189,8 +189,8 @@ int main(int argc, char *argv[])
 		G_percent(row, w.rows, 5);
 		G_percent(row, w.rows, 5);
 		if (Rast_get_raster_row(cellfile, (void *)voidc, row, rtype) < 0)
 		if (Rast_get_raster_row(cellfile, (void *)voidc, row, rtype) < 0)
 		    exit(1);
 		    exit(1);
-		Rast_lookup_raster_colors((void *)voidc, ored, ogrn, oblu, set,
-				       w.cols, &colors, rtype);
+		Rast_lookup_colors((void *)voidc, ored, ogrn, oblu, set,
+				   w.cols, &colors, rtype);
 
 
 		for (col = 0; col < w.cols; col++) {
 		for (col = 0; col < w.cols; col++) {
 
 

+ 1 - 1
raster/r.out.ppm3/main.c

@@ -162,7 +162,7 @@ int main(int argc, char **argv)
 	    if (Rast_get_raster_row(B[i].file, B[i].array, row, B[i].type) < 0)
 	    if (Rast_get_raster_row(B[i].file, B[i].array, row, B[i].type) < 0)
 		G_fatal_error("Rast_get_raster_row failed");
 		G_fatal_error("Rast_get_raster_row failed");
 
 
-	    Rast_lookup_raster_colors(B[i].array,
+	    Rast_lookup_colors(B[i].array,
 				   (i == 0) ? B[i].buf : dummy,
 				   (i == 0) ? B[i].buf : dummy,
 				   (i == 1) ? B[i].buf : dummy,
 				   (i == 1) ? B[i].buf : dummy,
 				   (i == 2) ? B[i].buf : dummy,
 				   (i == 2) ? B[i].buf : dummy,

+ 1 - 1
raster/r.out.vrml/put_grid.c

@@ -100,7 +100,7 @@ void vrml_put_grid(FILE * vout,
 		G_percent(row, rows - 1, 5);
 		G_percent(row, rows - 1, 5);
 
 
 	    Rast_get_f_raster_row(colorfd, tf, row);
 	    Rast_get_f_raster_row(colorfd, tf, row);
-	    Rast_lookup_f_raster_colors(tf, red, green, blue, set, cols, colr);
+	    Rast_lookup_f_colors(tf, red, green, blue, set, cols, colr);
 
 
 	    for (col = 0; col < cols; col++) {
 	    for (col = 0; col < cols; col++) {
 		sprintf(str, "%.3f %.3f %.3f,",
 		sprintf(str, "%.3f %.3f %.3f,",

+ 1 - 1
visualization/xganim/main.cc

@@ -248,7 +248,7 @@ int MyApp::load_files(void)
 		    G_fatal_error(_("Unable to read raster row"));
 		    G_fatal_error(_("Unable to read raster row"));
 
 
 		rowoff = (vyoff + row) * ncols;
 		rowoff = (vyoff + row) * ncols;
-		Rast_lookup_d_raster_colors(dcell, tr, tg, tb, tset, tsiz, &colors);
+		Rast_lookup_d_colors(dcell, tr, tg, tb, tset, tsiz, &colors);
 
 
 		for (col = 0; col < vcols; col++) {
 		for (col = 0; col < vcols; col++) {
 		    coff = (int)(col / vscale);
 		    coff = (int)(col / vscale);