[PyQt] writing to a QImage buffer

Florian Bruhin me at the-compiler.org
Thu Nov 13 05:13:50 GMT 2014


* James Conger <jlconger at yahoo.com> [2014-11-12 17:00:01 -0800]:
> QImage.scanLine() returns a sip void * pointer to a memory block containing one row of the image. For performance reasons I would like to write pixel RGB data directly to that buffer from within my Python code. How do you convert the void * pointer to a r/w object such as a Python array? 
> 
> Many thanks.

See
http://pyqt.sourceforge.net/Docs/PyQt5/gotchas.html#support-for-void

    A sip.voidptr may also be given a size (ie. the size of the block
    of memory that is pointed to) by calling its setsize() method. If
    it has a size then it is also able to support Python’s buffer
    protocol and behaves like a Python memoryview object so that the
    block of memory can be treated as a mutable list of bytes.

Florian

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
             GPG 0xFD55A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20141113/460f8751/attachment.sig>


More information about the PyQt mailing list