diff options
author | Martin Poirier <theeth@yahoo.com> | 2010-01-07 00:38:26 +0300 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2010-01-07 00:38:26 +0300 |
commit | f9177e21ceacb44778c5797475a5d8a288646d1a (patch) | |
tree | 263081b14003c4445e8ee1899f26fcfd6ef1a545 | |
parent | 635113085d9a37371eaaa20aa5cefc316db5cd12 (diff) |
RNA API: image.save(path)
Saves an image to the specified path. Uses format and other parameters from the scene (simpler this way than having to explicitly pass them to the function).
-rw-r--r-- | source/blender/makesrna/intern/rna_image_api.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 2bb7905fc03..343172be18e 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -63,6 +63,24 @@ static char *rna_Image_get_export_path(Image *image, char *dest_dir, int rel) return path; } +static void rna_Image_save(Image *image, bContext *C, ReportList *reports, char *path) +{ + ImBuf *ibuf; + Scene *scene = CTX_data_scene(C); + + if (scene) { + ibuf = BKE_image_get_ibuf(image, NULL); + + if (BKE_write_ibuf(NULL, ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality)) { + + } else { + BKE_reportf(reports, RPT_ERROR, "Couldn't write image: %s", path); + } + } else { + BKE_reportf(reports, RPT_ERROR, "Scene not in context, couldn't get save parameters"); + } +} + char *rna_Image_get_abs_filename(Image *image, bContext *C) { char *filename= MEM_callocN(FILE_MAX, "Image.get_abs_filename()"); @@ -95,6 +113,12 @@ void RNA_api_image(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm= RNA_def_string_file_path(func, "abs_filename", NULL, 0, "", "Image/movie absolute filename."); RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "save", "rna_Image_save"); + RNA_def_function_ui_description(func, "Save image to a specific path."); + RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + parm= RNA_def_string(func, "path", "", 0, "", "Save path."); + RNA_def_property_flag(parm, PROP_REQUIRED); } #endif |