views:

61

answers:

1

I'm building an app with PySide, there's some image manipulation that needs to be done and using Python code for this is way too slow. Therefore I hacked out a .dll file that will do it for me. The function definition is as follows:

   extern "C" {
QRectF get_image_slant(QImage *img, float slantangle, float offset) {

Now I can load this function in via ctypes. But I can't seem to get ctypes to accept a QImage. I tried calling it like this:

ext.get_image_slant(QImage(), 0, 0)

And the reply I get is:

File "<stdin>", line 1, in <module>
ctypes.ArgumentError: argument 1: <type 'exceptions.TypeError'>: Don't know how to convert parameter 1

I tired casting the QImage to a c_void_p and it doesn't like that either. From what I can tell QImage() in python should map exactly to a QImage * in C, but Python doesn't seem to understand that..

Is there any way to force the casting?

+1  A: 

Since ctypes for C++ isn't working very well, I would recommend using PySide's own wrapper - Shiboken. They actually use it to wrap the Qt libs themselves. Since your code deals with Qt object, this seems like the perfect choice for you.

Eli Bendersky