[PyQt] QImage from Python buffer

Phil Thompson phil at riverbankcomputing.com
Sun Feb 24 17:25:43 GMT 2008


On Saturday 23 February 2008, Jeremy Sanders wrote:
> Hi -
>
> Would it be possible to add support to create a QImage from a Python buffer
> object?
>
> I want to be able to quickly convert numpy arrays to QImages for display.
> Currently I have to convert the numpy to a string, then the string to a
> QImage.
>
> it would be nice to do
>
> QImage(numpyarray.data, 100, 100, QImage.Format_RGB32)
>
> where numpyarray is a 100x100x4 8 bit array.

Tonight's SIP snapshot will allow a Python object that supports the buffer 
interface to be used whenever a char or char * is expected. No need to 
rebuild PyQt.

Phil


More information about the PyQt mailing list