[PyKDE] Using PIL in PyQT
Rajeev Joseph Sebastian
rajeev_jsv at dinamis.com
Sun Nov 27 09:13:32 GMT 2005
On Saturday 26 November 2005 20:25, Diez B. Roggisch wrote:
> Rajeev Joseph Sebastian wrote:
> > Hello all,
> >
> > Is it possible to load images using PIL and draw them on screen using
> > PyQt ? Does anyone have any code snippet that could make this possible ?
>
> Certainly. Qt supports some powerful formats, e.g. PNG. So open a image
> with PIL, and serialize it to memory using cStringIO as a PNG. The load
> it as QImage from there, providing the data as binary string by the
> means of a QByteArray. Module struct or ctypes might come in handy here.
>
> Other data formats may be even better - try whatever suits you best.
>
> However I don't have code - but I guess you get the gist.
>
> Diez
Ok, I have got it to work :) Thanks for the help.
But, I now have another problem. What I am doing is to render things using an
image library to a string (using string io), and then paint it (bitBlt) onto
a QWidget after loading it to a pixmap. However, this is really slow.
Do you think it is due to compression of the PNG image ? Is there some image
format using which this can be made faster ?
--
Rajeev J Sebastian
Dinamis Corporation
3266 Yonge Street, Suite 1419
Toronto, ON
Canada M4N 3P6
+1 416-410-3326
More information about the PyQt
mailing list