[PyKDE] StringIO and QImage

David Boddie david at boddie.org.uk
Thu Jun 1 18:52:41 BST 2006


On Thu Jun 1 18:57:00 MEST 2006, Aljosa Mohorovic wrote:
 
> i'm using PIL to open an image file and then convert it to PNG image and now
> i would like to display that image in Qt.
> 
> does anybody know how to load <StringIO.StringIO instance> (in-memory
> representation of PNG image) from Qt (v.4.1.3) as QImage?

Read the in-memory PNG from the StringIO instance into a QByteArray then
pass it to QImage.loadFromData():

http://doc.trolltech.com/4.1/qimage.html#loadFromData-2

> any other ideas on loading different image format files and displaying it in
> Qt4 is welcome.

Qt 4 is capable of loading most common formats. However, I saw that you are
having problems with Qt's image loaders and py2exe. If you can solve that
problem, you might find that you can do all the image loading with Qt without
having to use an additional library.

David




More information about the PyQt mailing list