[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyKDE] (transparent) PIL image to QImage conversion?
From:       Orcan Ogetbil <orcan () psu ! edu>
Date:       2006-04-23 22:38:38
Message-ID: 1145831918.22474.3.camel () localhost ! localdomain
[Download RAW message or body]

On Sun, 2006-04-23 at 23:20 +0200, David Boddie wrote: 
> On Thu, 6 Apr 2006 16:37:07, "ORCAN OGETBIL" wrote:
> 
> > My problem is, the JPEG encoding kills the transparency of my PNG images.
> > When I do RAW encoding, I get nothing from the QByteArray object. I also
> > couldn't get the thing work with a GIF encoding. PIL's tostring() function
> > doesn't support PNG encoding.
> >
> > Here I found a list of encodings PIL provides:
> > http://mail.python.org/pipermail/image-sig/2004-September/002908.html
> >
> > Has anybody encountered this problem?
> > Can I use cStringIO.StringIO() instead of PIL's tostring() somehow?
> > Any solutions?
> 
> If you haven't already solved this problem, you might want to try saving
> the contents of the Image to a StringIO object then reading the data
> stored in the StringIO into a QImage. Try something like this:
> 
>   # im is an existing PIL Image object.
>   from qt import QImage
>   from cStringIO import StringIO
>   s = StringIO()
>   im.save(s, "PNG")
>   s.seek(0)
>   image = QImage()
>   image.loadFromData(s.read())
> 
> Hope this is useful,
> 
> David

Thank you, it works this way. Apparently I forgot to put the the line
with the seek() function. I knew it was so easy.
Thanks again.

Orcan

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic