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:
|
