[GRASS-SVN] r49346 - grass/branches/develbranch_6/raster/r.out.png

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 24 04:13:38 EST 2011


Author: neteler
Date: 2011-11-24 01:13:37 -0800 (Thu, 24 Nov 2011)
New Revision: 49346

Modified:
   grass/branches/develbranch_6/raster/r.out.png/r.out.png.c
Log:
glynn: Use functions rather than direct acess to the info struct (backport from trunk, r43927)

Modified: grass/branches/develbranch_6/raster/r.out.png/r.out.png.c
===================================================================
--- grass/branches/develbranch_6/raster/r.out.png/r.out.png.c	2011-11-24 09:13:28 UTC (rev 49345)
+++ grass/branches/develbranch_6/raster/r.out.png/r.out.png.c	2011-11-24 09:13:37 UTC (rev 49346)
@@ -145,7 +145,7 @@
 
     /* see what can be done to convert'em -A.Sh.
      * gscale = G_define_flag ();
-     * gscale->key = 'G';
+     * gscale->key = 'g';
      * gscale->description = "Output greyscale instead of color";
      */
 
@@ -193,9 +193,9 @@
     /* ... if at all */
     ret = G_str_to_color(bgcolor->answer, &def_red, &def_grn, &def_blu);
     if (ret == 0)
-    	G_fatal_error(_("[%s]: No such color"), bgcolor->answer);
+	G_fatal_error(_("[%s]: No such color"), bgcolor->answer);
     else if (ret == 2) {  /* (ret==2) is "none" */
-    	if(!do_alpha)
+	if(!do_alpha)
 	    do_alpha = TRUE;
     }
 #else
@@ -228,9 +228,9 @@
 
     /* open png file for writing */
     if (do_stdout)
-    	fp = stdout;
+	fp = stdout;
     else if (NULL == (fp = fopen(outfile, "w")))
-    	G_fatal_error(_("Unable to open output file <%s>"), outfile);
+	G_fatal_error(_("Unable to open output file <%s>"), outfile);
 
 
     png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
@@ -261,10 +261,12 @@
     png_info_init(info_ptr);
 #endif
     png_init_io(png_ptr, fp);
-    info_ptr->width = win.cols;
-    info_ptr->height = win.rows;
-    info_ptr->bit_depth = depth;
 
+    png_set_IHDR(png_ptr, info_ptr, win.cols, win.rows, depth,
+		 do_alpha ? PNG_COLOR_TYPE_RGB_ALPHA : PNG_COLOR_TYPE_RGB,
+		 PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
+		 PNG_FILTER_TYPE_DEFAULT);
+
     /* explicit filter-type (or none) required */
     if ((filter >= 0) && (filter <= 4)) {
 	png_set_filter(png_ptr, 0, filter);
@@ -272,7 +274,7 @@
 
     png_set_compression_level(png_ptr, png_compr);
 
-    if(do_alpha) {
+    if (do_alpha) {
 	png_color_16 background_color;
 	background_color.red = (png_uint_16)def_red;
 	background_color.green = (png_uint_16)def_grn;
@@ -302,11 +304,6 @@
 	/*if(!gscale->answer){ *//* 24BIT COLOR IMAGE */
 
 	if (TRUE) {
-	    if (do_alpha)
-		info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
-	    else
-		info_ptr->color_type = PNG_COLOR_TYPE_RGB;
-
 	    /* write the png-info struct */
 	    png_write_info(png_ptr, info_ptr);
 



More information about the grass-commit mailing list