[GRASS-SVN] r47042 - grass/trunk/lib/pngdriver
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jul 7 05:06:12 EDT 2011
Author: martinl
Date: 2011-07-07 02:06:11 -0700 (Thu, 07 Jul 2011)
New Revision: 47042
Modified:
grass/trunk/lib/pngdriver/Graph_set.c
Log:
pngdriver: support also named and RGB colors for GRASS_BACKGROUNDCOLOR
Modified: grass/trunk/lib/pngdriver/Graph_set.c
===================================================================
--- grass/trunk/lib/pngdriver/Graph_set.c 2011-07-07 09:04:54 UTC (rev 47041)
+++ grass/trunk/lib/pngdriver/Graph_set.c 2011-07-07 09:06:11 UTC (rev 47042)
@@ -23,6 +23,7 @@
#endif
#include <grass/gis.h>
+#include <grass/colors.h>
#include <grass/glocale.h>
#include "pngdriver.h"
@@ -55,7 +56,7 @@
if (png.grid)
G_free(png.grid);
- png.grid = (int *)((char *)ptr + HEADER_SIZE);
+ png.grid = (unsigned int *)((char *) ptr + HEADER_SIZE);
close(fd);
@@ -113,8 +114,11 @@
png_init_color_table();
p = getenv("GRASS_BACKGROUNDCOLOR");
- if (p && *p && sscanf(p, "%02x%02x%02x", &red, &grn, &blu) == 3)
+ if (p && *p &&
+ (sscanf(p, "%02x%02x%02x", &red, &grn, &blu) == 3 ||
+ G_str_to_color(p, (int *)&red, (int *)&grn, (int *)&blu) == 1)) {
png.background = png_get_color(red, grn, blu, png.has_alpha ? 255 : 0);
+ }
else {
/* 0xffffff = white, 0x000000 = black */
if (strcmp(DEFAULT_FG_COLOR, "white") == 0)
@@ -124,7 +128,7 @@
/* foreground: black, background: white */
png.background = png_get_color(255, 255, 255, png.has_alpha ? 255 : 0);
}
-
+
G_verbose_message(_("png: collecting to file '%s'"), png.file_name);
G_verbose_message(_("png: image size %dx%d"),
png.width, png.height);
More information about the grass-commit
mailing list