[PyKDE] How to display GIF and JPEG
Sheng-Te Tsao
shengte.tsao at firsttick.com
Fri Mar 30 17:17:45 BST 2001
Thank for the source code. I guess saving it first as PNG first is a
possible solution :-)
Still, is there anyway to load the image into memory directly without
having to save it as PNG first?
Thanks
ST
At 09:22 AM 3/29/2001 +0200, Gerard Vermeulen wrote:
>Here is an example, which fills the background of
>a future killer app with .gif or .jpg picture.
>
>--START--#!/usr/bin/env python
>
>import sys
>from qt import *
>import Image # the PythonWare Imaging Library
>
>class Viewer(QWidget):
> def __init__(self, filename, *args):
> apply(QWidget.__init__, (self,) + args)
> self.pixmap = QPixmap()
> #if not self.pixmap.load(filename): # Qt2/Linux loads *.gif and
> *.jpg!
> if 1:
> print 'Could not load "%s", converting to "%s.png"' % \
> (filename, filename)
> image = Image.open(filename)
> image.save(filename + '.png') # saved format depends on extension
> self.pixmap.load(filename + '.png')
> self.setBackgroundPixmap(self.pixmap)
>
>app = QApplication(sys.argv)
># lena.gif and lena.jpg are included in the PythonWare Imaging Library
>demo = Viewer("lena.jpg") # or demo = Viewer("lena.gif")
>app.setMainWidget(demo)
>demo.show()
>app.exec_loop()
>
>--END--
>
>However, on Mandrake-Linux-7.2 and Qt-2.2.1 it works without
>the PythonWare Image Library. Therefore I had to replace the
>if not self ....
>by
>if 1:
>
>
>Gerard Vermeulen
Sheng-Te Tsao
Online Status:
<http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com><http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com><http://www.eudora.com/products/voicecontact/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20010330/f3d1fd20/attachment.html
More information about the PyQt
mailing list