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 | |
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')
-rw-r--r-- | source/blender/python/api2_2x/Image.c | 29 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Image.py | 6 | ||||
-rw-r--r-- | source/blender/src/editobject.c | 8 |
3 files changed, 26 insertions, 17 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; } diff --git a/source/blender/python/api2_2x/doc/Image.py b/source/blender/python/api2_2x/doc/Image.py index a46fd554159..17f4477aeb3 100644 --- a/source/blender/python/api2_2x/doc/Image.py +++ b/source/blender/python/api2_2x/doc/Image.py @@ -343,7 +343,11 @@ class Image: def pack(): """ Packs the image into the current blend file. - @note: An error will be raised if the image is already packed or the filename path does not exist. + + Since 2.44 new images without valid filenames can be packed. + + If the image is alredy packed, it will be repacked. + @returns: nothing @rtype: none """ diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index a8d9251d249..67acf97f534 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -5464,16 +5464,16 @@ void hide_objects(int select) base->flag &= ~SELECT; base->object->flag = base->flag; base->object->restrictflag |= OB_RESTRICT_VIEW; - DAG_object_flush_update(G.scene, base->object, OB_RECALC_DATA); changed = 1; if (base==BASACT) BASACT= NULL; } } if (changed) { - allqueue(REDRAWVIEW3D,0); - allqueue(REDRAWOOPS,0); if(select) BIF_undo_push("Hide Selected Objects"); else if(select) BIF_undo_push("Hide Unselected Objects"); + DAG_scene_sort(G.scene); + allqueue(REDRAWVIEW3D,0); + allqueue(REDRAWOOPS,0); } } @@ -5486,12 +5486,12 @@ void show_objects(void) base->flag |= SELECT; base->object->flag = base->flag; base->object->restrictflag &= ~OB_RESTRICT_VIEW; - DAG_object_flush_update(G.scene, base->object, OB_RECALC_DATA); changed = 1; } } if (changed) { BIF_undo_push("Unhide Objects"); + DAG_scene_sort(G.scene); allqueue(REDRAWVIEW3D,0); allqueue(REDRAWOOPS,0); } |