[PyQt] Re: QPixmap / QImage from numpy or string
melkor at orangepalantir.org
Sun Jun 28 17:34:15 BST 2009
When I do this I use an RGB image becuase each line of your image needs
to be a multiple of 32bits or something like that, it says it in the
Also I need to keep a reference to my original array.
total = numpy.zeros((h,w,4),numpy.uint8)
#code to fill total with image data
nimage = QtGui.QImage(total.data,w,h,QtGui.QImage.Format_RGB32)
nimage.ndarray = total
I got this base on some code from the PyQwt mailing list. Ill attach it.
> I am trying to create a QImage from a numpy array directly. this is
> not supported yet, right?
> has anybody tried to load a numpy array via a string into a QImage,
> a = numpy.zeros((100,50))
> image = QImage(a.tostring(), a.shape, a.shape., a.shape,
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2580 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090628/7ab121ab/qimage2ndarray.py
More information about the PyQt