image lib & Qt4

Fredrik Lundh fredrik at pythonware.com
Fri Jun 2 00:51:40 EDT 2006


aljosa wrote:

> does anybody know how to load <StringIO.StringIO instance> (in-memory
> representation of PNG image) from Qt (v.4.1.3) as QImage?

If you want the data from a StringIO object, you can either *read* the 
data from the object (it's a file-like object, after all), or use the 
getvalue() method.

Something like

    qim = QImage()
    qim.loadFromData(f.getvalue())

should work (unless they've changed things around lately).

To get better performance, you should be able to use PIL's tostring() 
method together with the QImage(buffer, width, height, depth, 
colortable, numColors, bitOrder) form of the QImage constructor.

</F>




More information about the Python-list mailing list