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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 || !IMB_saveiff( ibuf, self->image->name, ibuf->flags ) )
|
||||
|
||||
if(!ibuf)
|
||||
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||
"could not save image" );
|
||||
"could not save image (no image buffer)" );
|
||||
|
||||
/* 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 (writing the image buffer failed)" );
|
||||
|
||||
Py_RETURN_NONE; /* normal return, image saved */
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user