ソースを参照

metadata and cleanup (merge from devbr6)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@39402 15284696-431f-4ddb-bdfa-cd5b030d7da7
Hamish Bowman 15 年 前
コミット
8baf4acb97
2 ファイル変更26 行追加7 行削除
  1. 19 0
      imagery/i.his.rgb/closefiles.c
  2. 7 7
      imagery/i.his.rgb/his2rgb.c

+ 19 - 0
imagery/i.his.rgb/closefiles.c

@@ -13,6 +13,7 @@ int closefiles(char *r_name, char *g_name, char *b_name,
     int i;
     struct Colors colors;
     struct Range range;
+    struct History history;
     CELL min, max;
     const char *mapset;
 
@@ -23,6 +24,8 @@ int closefiles(char *r_name, char *g_name, char *b_name,
 
     mapset = G_mapset();
 
+    /* write colors */
+    /*   set to 0,max_level instead of min,max ?? */
     Rast_read_range(r_name, mapset, &range);
     Rast_get_range_min_max(&range, &min, &max);
     Rast_make_grey_scale_colors(&colors, min, max);
@@ -38,5 +41,21 @@ int closefiles(char *r_name, char *g_name, char *b_name,
     Rast_make_grey_scale_colors(&colors, min, max);
     Rast_write_colors(b_name, mapset, &colors);
 
+    /* write metadata */
+    Rast_short_history(r_name, "raster", &history);
+    Rast_command_history(&history);
+    Rast_write_history(r_name, &history);
+    Rast_put_cell_title(r_name, "Image red");
+
+    Rast_short_history(g_name, "raster", &history);
+    Rast_command_history(&history);
+    Rast_write_history(g_name, &history);
+    Rast_put_cell_title(g_name, "Image green");
+
+    Rast_short_history(b_name, "raster", &history);
+    Rast_command_history(&history);
+    Rast_write_history(b_name, &history);
+    Rast_put_cell_title(b_name, "Image blue");
+
     return 0;
 }

+ 7 - 7
imagery/i.his.rgb/his2rgb.c

@@ -19,7 +19,7 @@ ASSUMPTION:
 #include <grass/gis.h>
 #include "globals.h"
 
-void his2rgb(CELL * rowbuffer[3], int columns)
+void his2rgb(CELL *rowbuffer[3], int columns)
 {
     long sample;		/* sample indicator                          */
     double red;			/* the red band output                       */
@@ -121,16 +121,16 @@ void his2rgb(CELL * rowbuffer[3], int columns)
 	else
 	    blue = blue255;
 
-	if (red > 254.5)
-	    red = 254.5;
+	if (red > 255. - 0.5)
+	    red = 255. - 0.5;
 	if (red < 0.0)
 	    red = 0.0;
-	if (green > 254.5)
-	    green = 254.5;
+	if (green > 255. - 0.5)
+	    green = 255. - 0.5;
 	if (green < 0.0)
 	    green = 0.0;
-	if (blue > 254.5)
-	    blue = 254.5;
+	if (blue > 255. - 0.5)
+	    blue = 255. - 0.5;
 	if (blue < 0.0)
 	    blue = 0.0;