diff options
-rw-r--r-- | source/blender/blenkernel/intern/packedFile.c | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Image.c | 17 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Image.py | 12 |
3 files changed, 22 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index f2b43247e4a..bd33fafe23c 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -286,7 +286,7 @@ int writePackedFile(char * filename, PackedFile *pf, int guimode) char tempname[FILE_MAXDIR + FILE_MAXFILE]; /* void * data; */ - waitcursor(1); + if (guimode) waitcursor(1); strcpy(name, filename); BLI_convertstringcode(name, G.sce, G.scene->r.cfra); diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c index 449ebcdfa7a..7ba3284e04e 100644 --- a/source/blender/python/api2_2x/Image.c +++ b/source/blender/python/api2_2x/Image.c @@ -657,7 +657,7 @@ static PyObject *Image_unpack( BPy_Image * self, PyObject * args ) /*get the absolute path */ if( !PyArg_ParseTuple( args, "i", &mode ) ) return EXPP_ReturnPyObjError( PyExc_TypeError, - "expected 1 integer" ); + "expected 1 integer from Blender.UnpackModes" ); if (image->packedfile==NULL) return EXPP_ReturnPyObjError( PyExc_RuntimeError, @@ -716,10 +716,21 @@ static PyObject *Image_makeCurrent( BPy_Image * self ) static PyObject *Image_save( BPy_Image * self ) { ImBuf *ibuf= BKE_image_get_ibuf(self->image, NULL); + + if(!ibuf) + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "could not save image (no image buffer)" ); - if(!ibuf || !IMB_saveiff( ibuf, self->image->name, ibuf->flags ) ) + /* If this is a packed file, write using writePackedFile + * because IMB_saveiff wont save to a file */ + if (self->image->packedfile) { + if (writePackedFile(self->image->name, self->image->packedfile, 0) != RET_OK) { + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "could not save image (writing image from packedfile failed)" ); + } + } else if (!IMB_saveiff( ibuf, self->image->name, ibuf->flags)) return EXPP_ReturnPyObjError( PyExc_RuntimeError, - "could not save image" ); + "could not save image (writing the image buffer failed)" ); Py_RETURN_NONE; /* normal return, image saved */ } diff --git a/source/blender/python/api2_2x/doc/Image.py b/source/blender/python/api2_2x/doc/Image.py index 17f4477aeb3..6d613b3c8fe 100644 --- a/source/blender/python/api2_2x/doc/Image.py +++ b/source/blender/python/api2_2x/doc/Image.py @@ -6,7 +6,7 @@ The Blender.Image submodule. Image ===== -B{New}: L{Image.setFilename}. +B{New}: L{Image.clampX}, L{Image.clampY}. This module provides access to B{Image} objects in Blender. @@ -335,9 +335,10 @@ class Image: def save(): """ - Saves the current image. - @returns: nothing - @rtype: none + Saves the current image to L{filename} + @note: Saving to a directory that doent exist will raise an error. + @note: Saving a packed image will make a unique (numbered) name if the file alredy exists. Remove the file first to be sure it will not be renamed. + @returns: None """ def pack(): @@ -355,7 +356,7 @@ class Image: def unpack(mode): """ Unpacks the image to the images filename. - @param mode: One of the values in Blender.Unpackmodes dict. + @param mode: One of the values in L{Blender.UnpackModes}. @note: An error will be raised if the image is not packed or the filename path does not exist. @returns: nothing @rtype: none @@ -365,6 +366,7 @@ class Image: """ Set the currently displayed Image from Blenders UV/Image window. When multiple images are displayed, the last active UV/Image windows image is used. + @warn: Deprecated, set bpy.data.images.active = image instead. @rtype: bool @return: True if the current image could be set, if no window was available, return False. """ |