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>2007-05-22 23:40:11 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-05-22 23:40:11 +0400
commitd6cbdabfe1c8c6ceea6fafbf8af09a6c4ddd84c9 (patch)
tree61c2da656fc8e2fcffb7897f7787a41a3c24c932 /source/blender/python/api2_2x/Image.c
parent5d1c012c0df3ddeb1a6a525721e0db9c1596217d (diff)
Bugfix for python Image.save()
[ #6702 ] Image doesn't get saved after painting & packing IMB_saveiff - (general saving function), does not write a file when the image is packed. so write a file with writePackedFile for packed files.
Diffstat (limited to 'source/blender/python/api2_2x/Image.c')
-rw-r--r--source/blender/python/api2_2x/Image.c17
1 files changed, 14 insertions, 3 deletions
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 */
}