ctypes and PySide

Posted by Timothy Baldridge on Stack Overflow See other posts from Stack Overflow or by Timothy Baldridge
Published on 2010-05-28T15:08:20Z Indexed on 2010/05/29 5:22 UTC
Read the original article Hit count: 498

Filed under:
|
|
|
|

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?

© Stack Overflow or respective owner

Related posts about python

Related posts about qt4