[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17281] trunk/blender/source/gameengine/ VideoTexture/blendVideoTex.cpp: VideoTexture: remove numpy dependency.

Benoit Bolsee benoit.bolsee at online.be
Sat Nov 1 23:28:27 CET 2008


Revision: 17281
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17281
Author:   ben2610
Date:     2008-11-01 23:28:27 +0100 (Sat, 01 Nov 2008)

Log Message:
-----------
VideoTexture: remove numpy dependency.

Modified Paths:
--------------
    trunk/blender/source/gameengine/VideoTexture/blendVideoTex.cpp

Modified: trunk/blender/source/gameengine/VideoTexture/blendVideoTex.cpp
===================================================================
--- trunk/blender/source/gameengine/VideoTexture/blendVideoTex.cpp	2008-11-01 22:26:58 UTC (rev 17280)
+++ trunk/blender/source/gameengine/VideoTexture/blendVideoTex.cpp	2008-11-01 22:28:27 UTC (rev 17281)
@@ -20,16 +20,12 @@
 -----------------------------------------------------------------------------
 */
 
-#define PY_ARRAY_UNIQUE_SYMBOL numpyPtr
-
 #include <Python.h>
 
 #include <RAS_GLExtensionManager.h>
 
 #include <RAS_IPolygonMaterial.h>
 
-#include <numpy/arrayobject.h>
-
 //Old API
 //#include "TexPlayer.h"
 //#include "TexImage.h"
@@ -85,15 +81,6 @@
 }
 
 
-// function to initialize numpy structures
-static bool initNumpy (void)
-{
-	// init module and report failure
-	import_array1(false);
-	// report success
-	return true;
-}
-
 // image to numpy array
 static PyObject * imageToArray (PyObject * self, PyObject *args)
 {
@@ -107,15 +94,14 @@
 	}
 	// get image structure
 	PyImage * img = reinterpret_cast<PyImage*>(pyImg);
-	// check initialization of numpy interface, and initialize it if needed
-	if (numpyPtr == NULL && !initNumpy()) Py_RETURN_NONE;
 	// create array object
-	npy_intp dim[1];
-	dim[0] = img->m_image->getBuffSize() / sizeof(unsigned int);
 	unsigned int * imgBuff = img->m_image->getImage();
 	// if image is available, convert it to array
 	if (imgBuff != NULL)
-		return PyArray_SimpleNewFromData(1, dim, NPY_UBYTE, imgBuff);
+        // Nasty problem here: the image buffer is an array of integers 
+        // in the processor endian format. The user must take care of that in the script. 
+        // Need to find an elegant solution to this problem 
+        return Py_BuildValue("s#", imgBuff, img->m_image->getBuffSize());
 	// otherwise return None
 	Py_RETURN_NONE;
 }
@@ -189,9 +175,6 @@
 	if (m == NULL) 
 		return NULL;
 
-	// prepare numpy array
-	numpyPtr = NULL;
-
 	// initialize classes
 	pyImageTypes.reg(m);
 	pyFilterTypes.reg(m);





More information about the Bf-blender-cvs mailing list