diff options
author | Joseph Gilbert <ascotan@gmail.com> | 2006-05-26 00:47:17 +0400 |
---|---|---|
committer | Joseph Gilbert <ascotan@gmail.com> | 2006-05-26 00:47:17 +0400 |
commit | af87c651a5a8cce6fb78aa3727b097211eadcbf8 (patch) | |
tree | a4ee7106f6f2a6cdb2aa95c57bec8a87d5c51819 | |
parent | d8d720ed3ad49779814fa0f7e7e07907529196a3 (diff) |
*python fix
- fixed Render.saveRenderedImage() so now it works once again
(it was broken since render refactor)
-rw-r--r-- | source/blender/python/api2_2x/sceneRender.c | 46 | ||||
-rw-r--r-- | source/blender/src/writeimage.c | 2 |
2 files changed, 16 insertions, 32 deletions
diff --git a/source/blender/python/api2_2x/sceneRender.c b/source/blender/python/api2_2x/sceneRender.c index 873122ced77..5d81be2e7e4 100644 --- a/source/blender/python/api2_2x/sceneRender.c +++ b/source/blender/python/api2_2x/sceneRender.c @@ -61,6 +61,7 @@ struct View3D; /* keep me up here */ #define PY_FULL 2 extern void waitcursor(int); +extern void save_rendered_image_cb_real(char *name, int zbuf); //---------------------------------------Render prototypes------------- static PyObject *M_Render_CloseRenderWindow( PyObject * self ); @@ -906,48 +907,31 @@ PyObject *RenderData_Render( BPy_RenderData * self ) //This will save the rendered image to an output file path already defined PyObject *RenderData_SaveRenderedImage ( BPy_RenderData * self, PyObject *args ) { - char dir[FILE_MAXDIR * 2], str[FILE_MAXFILE * 2], strn[256]; + char dir[FILE_MAXDIR * 2], str[FILE_MAXFILE * 2]; char *name_str, filepath[FILE_MAXDIR+FILE_MAXFILE]; + RenderResult *rr = NULL; + int zbuff = 0; - if( !PyArg_ParseTuple( args, "s", &name_str ) ) - return EXPP_ReturnPyObjError( PyExc_TypeError, - "expected a filename (string)" ); + if( !PyArg_ParseTuple( args, "s|i", &name_str, &zbuff ) ) + return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a filename (string) and optional int" ); - if( strlen(self->renderContext->pic) + strlen(name_str) > - sizeof(filepath)-1 ) - return EXPP_ReturnPyObjError( PyExc_ValueError, - "full filename too long" ); + if( strlen(self->renderContext->pic) + strlen(name_str) > sizeof(filepath)-1 ) + return EXPP_ReturnPyObjError( PyExc_ValueError, "full filename too long" ); BLI_strncpy( filepath, self->renderContext->pic, sizeof(filepath) ); strcat(filepath, name_str); - - //if(0) {//!R.rectot) { - // return EXPP_ReturnPyObjError (PyExc_RuntimeError, - // "No image rendered"); - //} else { + + rr = RE_GetResult(RE_GetRender(G.scene->id.name)); + if(!rr) { + return EXPP_ReturnPyObjError (PyExc_ValueError, "No image rendered"); + } else { if(G.ima[0]==0) { strcpy(dir, G.sce); BLI_splitdirstring(dir, str); strcpy(G.ima, dir); } - -// R.r.imtype= G.scene->r.imtype; -// R.r.quality= G.scene->r.quality; -// R.r.planes= G.scene->r.planes; - - strcpy(strn, filepath); - BLI_convertstringcode(strn, G.sce, G.scene->r.cfra); - if(BLI_testextensie(strn,".blend")) { - return EXPP_ReturnPyObjError (PyExc_RuntimeError, - "Wrong filename"); - } - - waitcursor(1); -// schrijfplaatje(strn); - strcpy(G.ima, filepath); - waitcursor(0); - //} - + save_rendered_image_cb_real(filepath, zbuff); + } return EXPP_incr_ret(Py_None); } //------------------------------------RenderData.RenderAnim() ----------- diff --git a/source/blender/src/writeimage.c b/source/blender/src/writeimage.c index 8e3abd06a72..c7a35805786 100644 --- a/source/blender/src/writeimage.c +++ b/source/blender/src/writeimage.c @@ -86,7 +86,7 @@ void BIF_save_envmap(EnvMap *env, char *str) #define FTOCHAR(val) val<=0.0f?255: 255-(val>=255.0f?255: (char)(val)) /* callback for fileselect to save rendered image, renderresult was checked to exist */ -static void save_rendered_image_cb_real(char *name, int zbuf) +void save_rendered_image_cb_real(char *name, int zbuf) { char str[FILE_MAXDIR+FILE_MAXFILE]; int pixel, end; |