19#include <grass/glocale.h>
26 int i_width, i_height, maxval;
33 input = fopen(
png.file_name,
"rb");
37 if (fscanf(input,
"P6 %d %d %d", &i_width, &i_height, &maxval) != 3)
40 if (fgetc(input) == EOF)
43 if (i_width !=
png.width || i_height !=
png.height)
44 G_fatal_error(
"PNG: input file has incorrect dimensions: expected: "
46 png.width,
png.height, i_width, i_height);
48 for (y = 0, p =
png.grid; y <
png.height; y++) {
49 for (
x = 0;
x <
png.width;
x++, p++) {
75 int i_width, i_height, maxval;
82 mask_name[strlen(mask_name) - 2] =
'g';
84 input = fopen(mask_name,
"rb");
86 G_fatal_error(
"PNG: couldn't open input mask file %s", mask_name);
88 if (fscanf(input,
"P5 %d %d %d", &i_width, &i_height, &maxval) != 3)
91 if (fgetc(input) == EOF)
92 G_fatal_error(_(
"PNG: invalid input mask file %s"), mask_name);
94 if (i_width !=
png.width || i_height !=
png.height)
95 G_fatal_error(
"PNG: input mask file has incorrect dimensions: "
96 "expected: %dx%d got: %dx%d",
97 png.width,
png.height, i_width, i_height);
101 for (y = 0, p =
png.grid; y <
png.height; y++) {
102 for (
x = 0;
x <
png.width;
x++, p++) {
105 int k = fgetc(input);
107 k = k * 255 / maxval;
void G_free(void *buf)
Free allocated memory.
unsigned int png_get_color(int r, int g, int b, int a)
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
GRASS png display driver - header file.
char * G_store(const char *s)
Copy string to allocated memory.