[GRASS-SVN] r33600 - grass/trunk/raster/r.colors.out

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Sep 29 15:41:13 EDT 2008


Author: glynn
Date: 2008-09-29 15:41:13 -0400 (Mon, 29 Sep 2008)
New Revision: 33600

Modified:
   grass/trunk/raster/r.colors.out/main.c
Log:
Handle 3.0 colour tables


Modified: grass/trunk/raster/r.colors.out/main.c
===================================================================
--- grass/trunk/raster/r.colors.out/main.c	2008-09-29 19:39:29 UTC (rev 33599)
+++ grass/trunk/raster/r.colors.out/main.c	2008-09-29 19:41:13 UTC (rev 33600)
@@ -97,19 +97,34 @@
 	    G_fatal_error(_("Unable to open output file <%s>"), file);
     }
 
-    count = G_colors_count(&colors);
+    if (colors.version < 0) {
+	/* 3.0 format */
+	CELL lo, hi;
 
-    for (i = 0; i < count; i++) {
-	DCELL val1, val2;
-	unsigned char r1, g1, b1, r2, g2, b2;
+	G_get_color_range(&lo, &hi, &colors);
 
-	G_get_f_color_rule(
-	    &val1, &r1, &g1, &b1,
-	    &val2, &r2, &g2, &b2,
-	    &colors, count - 1 - i);
+	for (i = lo; i <= hi; i++) {
+	    unsigned char r, g, b, set;
+	    DCELL val = (DCELL) i;
+	    G_lookup_colors(&i, &r, &g, &b, &set, 1, &colors);
+	    write_rule(&val, r, g, b);
+	}
+    }
+    else {
+	count = G_colors_count(&colors);
 
-	write_rule(&val1, r1, g1, b1);
-	write_rule(&val2, r2, g2, b2);
+	for (i = 0; i < count; i++) {
+	    DCELL val1, val2;
+	    unsigned char r1, g1, b1, r2, g2, b2;
+
+	    G_get_f_color_rule(
+		&val1, &r1, &g1, &b1,
+		&val2, &r2, &g2, &b2,
+		&colors, count - 1 - i);
+
+	    write_rule(&val1, r1, g1, b1);
+	    write_rule(&val2, r2, g2, b2);
+	}
     }
 
     {



More information about the grass-commit mailing list