gint gv_view_area_print_to_file(GvViewArea *view, int width, int height, const char * filename, const char * format, int is_rgb) { GDALDriverH driver; GDALDatasetH dataset; gint errcode; driver = GDALGetDriverByName( format ); if( driver == NULL ) return -1; if( is_rgb ) dataset = GDALCreate( driver, filename, width, height, 3, GDT_Byte, NULL ); else dataset = GDALCreate( driver, filename, width, height, 1, GDT_Byte, NULL ); if( dataset == NULL ) return -1; errcode = gv_view_area_render_to_func( view, width, height, print_handler, dataset ); GDALClose( dataset ); print_handler( NULL, NULL ); return errcode; }
static int output_handler(const char *str) { return print_handler(str, str_len(str), NULL); }