diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-02-26 15:28:44 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-02-26 15:28:44 +0300 |
commit | bbf6dde277a070ac82af8799376876e23dc13df1 (patch) | |
tree | f7c7ec354edf80604f9bba519787422158929148 /source/blender/makesrna/intern/rna_image_api.c | |
parent | d616286ffb15fda70c1ab1a5caa9804cbcc4e7fa (diff) |
rna/py api
rename image.save() --> image.save_render() because it uses render settings for saving.
added image.save() which is like pressing save in the image view, saving to the images path and removing the dirty flag.
Diffstat (limited to 'source/blender/makesrna/intern/rna_image_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_image_api.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index e87ec02daea..533d954871c 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -37,15 +37,18 @@ #ifdef RNA_RUNTIME #include "BKE_image.h" +#include "BKE_packedFile.h" #include "BKE_main.h" #include "BKE_utildefines.h" +#include "IMB_imbuf.h" + #include "DNA_image_types.h" #include "DNA_scene_types.h" #include "MEM_guardedalloc.h" -static void rna_Image_save(Image *image, bContext *C, ReportList *reports, char *path, Scene *scene) +static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports, char *path, Scene *scene) { ImBuf *ibuf; @@ -74,6 +77,27 @@ static void rna_Image_save(Image *image, bContext *C, ReportList *reports, char } } +static void rna_Image_save(Image *image, ReportList *reports) +{ + ImBuf *ibuf= BKE_image_get_ibuf(image, NULL); + if(ibuf) { + if(image->packedfile) { + if (writePackedFile(reports, image->name, image->packedfile, 0) != RET_OK) { + BKE_reportf(reports, RPT_ERROR, "Image \"%s\" could saved packed file to \"%s\"", image->id.name+2, image->name); + } + } + else if (IMB_saveiff(ibuf, image->name, ibuf->flags)) { + ibuf->userflags &= ~IB_BITMAPDIRTY; + } + else { + BKE_reportf(reports, RPT_ERROR, "Image \"%s\" could not be saved to \"%s\"", image->id.name+2, image->name); + } + } + else { + BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name+2); + } +} + #else void RNA_api_image(StructRNA *srna) @@ -81,12 +105,16 @@ void RNA_api_image(StructRNA *srna) FunctionRNA *func; PropertyRNA *parm; - func= RNA_def_function(srna, "save", "rna_Image_save"); - RNA_def_function_ui_description(func, "Save image to a specific path."); + func= RNA_def_function(srna, "save_render", "rna_Image_save_render"); + RNA_def_function_ui_description(func, "Save image to a specific path using a scenes render settings."); 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); parm= RNA_def_pointer(func, "scene", "Scene", "", "Scene to take image parameters from."); + + func= RNA_def_function(srna, "save", "rna_Image_save"); + RNA_def_function_ui_description(func, "Save image to its source path."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); } #endif |