diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-04-20 03:45:33 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-04-20 03:45:33 +0400 |
commit | 3fe793f2b5ceb3842a888de20e7baf2c90753c73 (patch) | |
tree | 4864f82f9f9fcef8c9aaa16fcea092a99026674c /source/blender/python/api2_2x/Image.c | |
parent | 9c366833738af1565bc24aa5c2b995bb9320fcd3 (diff) |
[ #6442 ] image.repack (Python)
- Modified pack so it can repack too, rather the n raising an error.
editobject - Dont need to recalc data when hiding and unhiding. rather do what layers do and re-sort the scene.
Diffstat (limited to 'source/blender/python/api2_2x/Image.c')
-rw-r--r-- | source/blender/python/api2_2x/Image.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c index 06a9c8db1de..60ac0f6c5c9 100644 --- a/source/blender/python/api2_2x/Image.c +++ b/source/blender/python/api2_2x/Image.c @@ -542,6 +542,7 @@ static PyObject *Image_setPixelF( BPy_Image * self, PyObject * args ) pixel[index + 2] = ( char ) ( p[2] * 255.0 ); pixel[index + 3] = ( char ) ( p[3] * 255.0 ); + ibuf->userflags |= IB_BITMAPDIRTY; Py_RETURN_NONE; } @@ -597,7 +598,8 @@ static PyObject *Image_setPixelI( BPy_Image * self, PyObject * args ) pixel[index + 1] = ( char ) p[1]; pixel[index + 2] = ( char ) p[2]; pixel[index + 3] = ( char ) p[3]; - + + ibuf->userflags |= IB_BITMAPDIRTY; Py_RETURN_NONE; } @@ -671,18 +673,21 @@ static PyObject *Image_unpack( BPy_Image * self, PyObject * args ) 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" ); - if (!BLI_exists(expandpath)) + ImBuf *ibuf = BKE_image_get_ibuf(image, NULL); + + if( !ibuf || !ibuf->rect ) /* didn't work */ return EXPP_ReturnPyObjError( PyExc_RuntimeError, - "image path does not exist" ); - - image->packedfile = newPackedFile(image->name); + "couldn't load image data in Blender" ); + + if (image->packedfile ) { /* RePack? */ + if (ibuf->userflags & IB_BITMAPDIRTY) + BKE_image_memorypack(image); + } else { /* Pack for the first time */ + if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) + BKE_image_memorypack(image); + else + image->packedfile = newPackedFile(image->name); + } Py_RETURN_NONE; } |