18 #include <sys/types.h>
23 #include <grass/gis.h>
41 static void map_file(
void)
52 ptr = mmap(
NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t) 0);
53 if (ptr == MAP_FAILED)
68 unsigned int red, grn, blu;
73 G_gisinit(
"PNG driver");
75 p =
getenv(
"GRASS_PNGFILE");
76 if (!p || strlen(p) == 0)
81 p =
getenv(
"GRASS_TRUECOLOR");
84 G_message(
"PNG: GRASS_TRUECOLOR status: %s",
87 p =
getenv(
"GRASS_PNG_AUTO_WRITE");
90 p =
getenv(
"GRASS_PNG_MAPPED");
91 do_map = p && strcmp(p,
"TRUE") == 0;
100 p =
getenv(
"GRASS_PNG_READ");
101 do_read = p && strcmp(p,
"TRUE") == 0;
103 if (do_read && access(
file_name, 0) != 0)
114 p =
getenv(
"GRASS_TRANSPARENT");
119 p =
getenv(
"GRASS_BACKGROUNDCOLOR");
120 if (p && *p && sscanf(p,
"%02x%02x%02x", &red, &grn, &blu) == 3)
124 if (strcmp(DEFAULT_FG_COLOR,
"white") == 0)
133 (
"PNG: collecting to file: %s,\n GRASS_WIDTH=%d, GRASS_HEIGHT=%d",
136 if (do_read && do_map)
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
void G_free(void *buf)
Free allocated memory.
int PNG_Graph_set(int argc, char **argv)
void init_color_table(void)
void G_message(const char *msg,...)
Print a message to stderr.
unsigned char png_palette[256][4]
unsigned int get_color(int r, int g, int b, int a)