diff options
author | Campbell Barton <ideasman42@gmail.com> | 2006-05-06 10:17:46 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2006-05-06 10:17:46 +0400 |
commit | e9718958ee2d0425e9cdc8e403ffc05ecc669872 (patch) | |
tree | 2be45d1c7ec9f7d2a2820a4ed158370f04cc1dcb /source/blender/python/api2_2x/Image.c | |
parent | 75f4416e32353af374c08f18f46c4c5f80dd7985 (diff) |
Applied pack unpack from Pablo Martin (caedes),
http://projects.blender.org/tracker/?func=detail&atid=127&aid=3246&group_id=9
adds
Blender.c:
Blender.UnpackModes (dict with the unpack modes)
Blender.UnpackAll(mode)
Blender.PackAll()
Blender.CountPackedFiles()
Image.c:
image.packed (this was working)
image.pack()
image.unpack()
Sound.c:
sound.packed
sound.pack()
sound.unpack()
Diffstat (limited to 'source/blender/python/api2_2x/Image.c')
-rw-r--r-- | source/blender/python/api2_2x/Image.c | 45 |
1 files changed, 9 insertions, 36 deletions
diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c index 896bcd07433..024196bd9a9 100644 --- a/source/blender/python/api2_2x/Image.c +++ b/source/blender/python/api2_2x/Image.c @@ -166,7 +166,7 @@ static PyMethodDef BPy_Image_methods[] = { {"save", ( PyCFunction ) Image_save, METH_NOARGS, "() - Write image buffer to file"}, {"unpack", ( PyCFunction ) Image_unpack, METH_VARARGS, - "(int) - Unpack image. [0,1,2], Never overwrite, Overwrite if different, Overwrite all."}, + "(int) - Unpack image. Uses the values defined in Blender.UnpackModes."}, {"pack", ( PyCFunction ) Image_pack, METH_NOARGS, "() Pack the image"}, {NULL, NULL, 0, NULL} @@ -642,19 +642,12 @@ static PyObject *Image_getMinXY( BPy_Image * self ) "could not determine min x or y" ); } - -/* unpack -mode 0; never overwrite -mode 1; overwrite only if differs packed. -mode 2; always overwrite. -*/ - +/* unpack image */ static PyObject *Image_unpack( BPy_Image * self, PyObject * args ) { Image *image = self->image; - int mode, check, ret=RET_OK; /* offset into image data */ - char expandpath[FILE_MAXDIR + FILE_MAXFILE]; + int mode; /*get the absolute path */ if( !PyArg_ParseTuple( args, "i", &mode ) ) @@ -665,41 +658,21 @@ static PyObject *Image_unpack( BPy_Image * self, PyObject * args ) return EXPP_ReturnPyObjError( PyExc_RuntimeError, "image not packed" ); - BLI_strncpy(expandpath, image->name, FILE_MAXDIR+FILE_MAXFILE); - BLI_convertstringcode(expandpath, G.sce, 1); - check= checkPackedFile(expandpath, image->packedfile); - - if (check==PF_NOFILE) { - ret= writePackedFile(expandpath, image->packedfile, 0); /* no guimode */ - } else if (check==PF_EQUAL){ - if (mode==2) /*always overwrite */ - ret= writePackedFile(expandpath, image->packedfile, 0); - } else if (check==PF_DIFFERS) { - if (mode!=0) - ret= writePackedFile(expandpath, image->packedfile, 0); /* no guimode */ - } - - if (ret==RET_ERROR) + if (unpackImage(image, mode) == RET_ERROR) return EXPP_ReturnPyObjError( PyExc_RuntimeError, - "internal unpacking error, could not write packed image, image still packed." ); - - /*free packed data*/ - freePackedFile(image->packedfile); - image->packedfile=NULL; - - /*free icon*/ - BKE_icon_delete(&image->id); - image->id.icon_id = 0; - + "error unpacking image" ); Py_RETURN_NONE; } +/* pack image */ + static PyObject *Image_pack( BPy_Image * self ) { Image *image = self->image; char expandpath[FILE_MAXDIR + FILE_MAXFILE]; BLI_strncpy(expandpath, image->name, FILE_MAXDIR+FILE_MAXFILE); - + BLI_convertstringcode(expandpath, G.sce, 1); + if (image->packedfile ) return EXPP_ReturnPyObjError( PyExc_RuntimeError, "image alredy packed" ); |