On 29/07/2011 1:37 PM, Gordon L. Kindlmann wrote:
On Wednesday 27 Jul 2011 10:09:58 Hugo Parente Lima wrote:


On Wednesday 27 July 2011 02:15:35 Gordon L. Kindlmann wrote:
Hello,

I see from

http://doc.qt.nokia.com/latest/qimage.html#QImage-4

that I can create a QImage around an existing ray image data buffer in
memory, communicated by the "uchar * data" argument, which is what I
want.

However, looking at

http://www.pyside.org/docs/pyside/PySide/QtGui/QImage.html#PySide.QtGui.QIm
age

(which seems to be based on the same documentation) the corresponding
PySide constructor seems to take a "data" argument of type "uchar".
Is this right?

The docs, no, but you can pass a Python buffer object to the QImage
constructor.

Can someone let me know if it possible or not to use PySide to display
in-memory image data, referenced by a pointer?  The image data is
generated by an extension module written in C.

If the value returned by this extension implements the Python buffer interface
it's possible.

Thanks,
Gordon


Thanks for the info.  Just to be certain, you are referring this?

http://docs.python.org/c-api/buffer.html

Do you know of any code examples that demonstrate this being used with PySide? Googling for 'pyside "buffer interface"' was not so informative. I'm especially interested in examples that don't depend on numpy, for simplicity's sake.

Thanks,
Gordon
Hi,
You shouldn't be searching for something like that. Once you have your data in a form that implements the /Python/ buffer interface, getting a QImage is trivial.
Something like this will do:
qImage = QtGui.QImage(myBuffer,
                      width,
                      height,
QtGui.QImage.Format_ARGB32) # Obviously adapt the image format to the appropriate value.

What you should be really doing is figuring out how to get your data wrapped as a Python buffer which is completely independent of PySide. Note that Python strings also implement the buffer interface if it is easier to wrap your data as a string.

Gerald.
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside

Reply via email to