24 static void write_data(png_structp png_ptr, png_bytep data, png_size_t length)
32 fp = (FILE *) png_get_io_ptr(png_ptr);
36 check = fwrite(data, 1, length, fp);
42 static void output_flush(png_structp png_ptr)
49 fp = (FILE *) png_get_io_ptr(png_ptr);
59 static png_struct *png_ptr;
60 static png_info *info_ptr;
69 png_create_write_struct(PNG_LIBPNG_VER_STRING, &jbuf,
NULL,
NULL);
73 info_ptr = png_create_info_struct(png_ptr);
77 if (setjmp(png_jmpbuf(png_ptr)))
84 png_set_write_fn(png_ptr, output, write_data, output_flush);
86 png_set_IHDR(png_ptr, info_ptr,
89 PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
90 PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
93 png_set_invert_alpha(png_ptr);
95 png_color png_pal[256];
98 for (i = 0; i < 256; i++) {
104 png_set_PLTE(png_ptr, info_ptr, png_pal, 256);
107 png_byte trans = (png_byte) 0;
109 png_set_tRNS(png_ptr, info_ptr, &trans, 1,
NULL);
113 str =
getenv(
"GRASS_RENDER_FILE_COMPRESSION");
114 if (str && sscanf(str,
"%d", &compress) == 1)
115 png_set_compression_level(png_ptr, compress);
117 png_write_info(png_ptr, info_ptr);
125 for (x = 0; x <
png.
width; x++, p++) {
136 for (x = 0; x <
png.
width; x++, p++, q++)
139 png_write_row(png_ptr, line);
144 png_write_end(png_ptr, info_ptr);
146 png_destroy_write_struct(&png_ptr, &info_ptr);
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
GRASS png display driver - header file.
unsigned char palette[256][4]
void G_free(void *)
Free allocated memory.
void png_get_pixel(unsigned int pixel, int *r, int *g, int *b, int *a)
void output(const char *fmt,...)