Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-02-26 15:28:44 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-02-26 15:28:44 +0300
commitbbf6dde277a070ac82af8799376876e23dc13df1 (patch)
treef7c7ec354edf80604f9bba519787422158929148 /source/blender
parentd616286ffb15fda70c1ab1a5caa9804cbcc4e7fa (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')
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c34
-rw-r--r--source/blender/python/intern/bpy_rna.c13
2 files changed, 38 insertions, 9 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
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index fd427526ac9..b44b49a43c1 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -2882,7 +2882,7 @@ static PyObject * pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
ParameterIterator iter;
PropertyRNA *parm;
PyObject *ret, *item;
- int i, args_len, parms_len, ret_len, flag, err= 0, kw_tot= 0, kw_arg;
+ int i, pyargs_len, pykw_len, parms_len, ret_len, flag, err= 0, kw_tot= 0, kw_arg;
const char *parm_id;
PropertyRNA *pret_single= NULL;
@@ -2904,16 +2904,17 @@ static PyObject * pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
* the same ID as the functions. */
RNA_pointer_create(self_ptr->id.data, &RNA_Function, self_func, &funcptr);
- args_len= PyTuple_GET_SIZE(args);
+ pyargs_len= PyTuple_GET_SIZE(args);
+ pykw_len= kw ? PyDict_Size(kw) : 0;
RNA_parameter_list_create(&parms, self_ptr, self_func);
RNA_parameter_list_begin(&parms, &iter);
parms_len= RNA_parameter_list_size(&parms);
ret_len= 0;
- if(args_len + (kw ? PyDict_Size(kw):0) > parms_len) {
+ if(pyargs_len + pykw_len > parms_len) {
RNA_parameter_list_end(&iter);
- PyErr_Format(PyExc_TypeError, "%.200s.%.200s(): takes at most %d arguments, got %d", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), parms_len, args_len);
+ PyErr_Format(PyExc_TypeError, "%.200s.%.200s(): takes at most %d arguments, got %d", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), parms_len, pyargs_len + pykw_len);
err= -1;
}
@@ -2936,7 +2937,7 @@ static PyObject * pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
parm_id= RNA_property_identifier(parm);
item= NULL;
- if ((i < args_len) && (flag & PROP_REQUIRED)) {
+ if ((i < pyargs_len) && (flag & PROP_REQUIRED)) {
item= PyTuple_GET_ITEM(args, i);
i++;
@@ -2987,7 +2988,7 @@ static PyObject * pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
* the if below is quick, checking if it passed less keyword args then we gave.
* (Dont overwrite the error if we have one, otherwise can skip important messages and confuse with args)
*/
- if(err == 0 && kw && (PyDict_Size(kw) > kw_tot)) {
+ if(err == 0 && kw && (pykw_len > kw_tot)) {
PyObject *key, *value;
Py_ssize_t pos = 0;