23 static void write_data(png_structp png_ptr, png_bytep data, png_size_t length)
31 fp = (FILE *)png_get_io_ptr(png_ptr);
35 check = fwrite(data, 1, length, fp);
41 static void output_flush(png_structp png_ptr)
48 fp = (FILE *)png_get_io_ptr(png_ptr);
58 static png_struct *png_ptr;
59 static png_info *info_ptr;
67 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, &jbuf,
NULL,
NULL);
71 info_ptr = png_create_info_struct(png_ptr);
75 if (setjmp(png_jmpbuf(png_ptr)))
82 png_set_write_fn(png_ptr,
output, write_data, output_flush);
86 : PNG_COLOR_TYPE_PALETTE,
87 PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
88 PNG_FILTER_TYPE_DEFAULT);
91 png_set_invert_alpha(png_ptr);
93 png_color png_pal[256];
96 for (i = 0; i < 256; i++) {
102 png_set_PLTE(png_ptr, info_ptr, png_pal, 256);
105 png_byte trans = (png_byte)0;
107 png_set_tRNS(png_ptr, info_ptr, &trans, 1,
NULL);
111 str = getenv(
"GRASS_RENDER_FILE_COMPRESSION");
112 if (str && sscanf(str,
"%d", &compress) == 1)
113 png_set_compression_level(png_ptr, compress);
115 png_write_info(png_ptr, info_ptr);
137 png_write_row(png_ptr, line);
142 png_write_end(png_ptr, info_ptr);
144 png_destroy_write_struct(&png_ptr, &info_ptr);
void png_get_pixel(unsigned int pixel, int *r, int *g, int *b, int *a)
void G_free(void *)
Free allocated memory.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
GRASS png display driver - header file.
void output(const char *fmt,...)
unsigned char palette[256][4]