? creator/winbuildinfo.h Index: blender/python/api2_2x/Image.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Image.c,v retrieving revision 1.72 diff -u -r1.72 Image.c --- blender/python/api2_2x/Image.c 15 Mar 2007 01:47:51 -0000 1.72 +++ blender/python/api2_2x/Image.c 25 Mar 2007 10:02:05 -0000 @@ -50,6 +50,7 @@ #include "BKE_icons.h" #include "IMB_imbuf.h" #include "IDProp.h" +#include "mydevice.h" /* used so we can get G.scene->r.cfra for getting the current image frame, some images change frame if they are a sequence */ @@ -117,6 +118,7 @@ static PyObject *Image_save( BPy_Image * self ); static PyObject *Image_unpack( BPy_Image * self, PyObject * args ); static PyObject *Image_pack( BPy_Image * self ); +static PyObject *Image_repack( BPy_Image * self ); static PyObject *Image_makeCurrent( BPy_Image * self ); @@ -185,6 +187,8 @@ "(int) - Unpack image. Uses the values defined in Blender.UnpackModes."}, {"pack", ( PyCFunction ) Image_pack, METH_NOARGS, "() - Pack the image"}, + {"repack", ( PyCFunction ) Image_repack, METH_NOARGS, + "() - Pack the image"}, {"makeCurrent", ( PyCFunction ) Image_makeCurrent, METH_NOARGS, "() - Make this the currently displayed image"}, {NULL, NULL, 0, NULL} @@ -683,6 +687,43 @@ "image path does not exist" ); image->packedfile = newPackedFile(image->name); + Py_RETURN_NONE; +} + +/* re-pack image */ + +static PyObject *Image_repack( BPy_Image * self ) +{ + Image *image = self->image; + Image *ima; + ImBuf *ibuf; + + char expandpath[FILE_MAXDIR + FILE_MAXFILE]; + BLI_strncpy(expandpath, image->name, FILE_MAXDIR+FILE_MAXFILE); + BLI_convertstringcode(expandpath, G.sce, 1); + + if (!BLI_exists(expandpath)) + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "image path does not exist" ); + ima=G.sima->image; + G.sima->image=image; + ibuf= BKE_image_get_ibuf(image, &G.sima->iuser); + if (!(ibuf && (ibuf->userflags & IB_BITMAPDIRTY))){ + G.sima->image=ima; + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "image do not need to re-pack" ); + } + if (image->packedfile) + { + BKE_image_memorypack(G.sima->image); + allqueue(REDRAWIMAGE, 0); + G.sima->image=ima; + } + else{ + G.sima->image=ima; + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "image is not alredy packed" ); + } Py_RETURN_NONE; }