void TCOD_image_save(TCOD_image_t image, const char *filename) { image_data_t *img=(image_data_t *)image; void *bitmap=NULL; if ( img->sys_img ) { bitmap=img->sys_img; } else if ( img->mipmaps ){ bitmap=TCOD_sys_create_bitmap(img->mipmaps[0].width, img->mipmaps[0].height, img->mipmaps[0].buf); } if (bitmap) TCOD_sys_save_bitmap(bitmap, filename); }
void TCOD_image_save(TCOD_image_t image, const char *filename) { image_data_t *img=(image_data_t *)image; void *bitmap=NULL; bool must_free=false; if ( img->sys_img ) { bitmap=img->sys_img; } else if ( img->mipmaps ){ bitmap=TCOD_sys_create_bitmap(img->mipmaps[0].width, img->mipmaps[0].height, img->mipmaps[0].buf); must_free=true; } if (bitmap) { TCOD_sys_save_bitmap(bitmap, filename); if ( must_free ) { TCOD_sys_delete_bitmap(bitmap); } } }