<html>
Thanks, I guess what I need to figure out is a way to tell PIL to output
in some format that is close to what QT uses internally (my guess is that
BMP or XBM fits the bill) then there should not be too much overhead from
the conversion. Still, just like you I wish there is a more
direct approach by writing some glue code (preferably in Python) that
hooks up the PIL JPG decoder and QT so that there is no conversion.<br>
<br>
Sheng-Te<br>
<br>
At 12:17 PM 3/30/2001 -0500, Gey-Hong Gweon wrote:<br>
<blockquote type=cite class=cite cite>I just ran the following code
segment in my PyQt program to perhaps do<br>
something similar to what you want to do without creating files. I
hope<br>
this is helpful. As commented, I wonder if there is a way to do
away<br>
with the "png" step somehow...?<br>
<br>
import Image<br>
image = Image.open ('Desktop/misc/picture/munch.scream.jpg')<br>
import StringIO<br>
s = StringIO.StringIO ()<br>
# Could the following three lines be simplified somehow??<br>
image.save (s, format = 'png')<br>
p = QPixmap ()<br>
p.loadFromData (s.getvalue ())<br>
gds.mdi.setBackgroundPixmap (p)<br>
<br>
On Fri March/30/2001, 11:58:46 -0500, Sheng-Te Tsao wrote: <br>
> Thanks for the tips. I'll look into using
loadFromData. Of course, if <br>
> someone has done this already, some sample code would be
appreciated :-)<br>
> <br>
> Sheng-Te<br>
> <br>
> At 06:43 PM 3/30/2001 +0200, Gerard Vermeulen wrote:<br>
> >Of course, the example is a dumb solution. If you want to
keep<br>
> >everything in memory, I would explore the following:<br>
> ><br>
> >(1) use memory mapped files: look in the Python library
reference for<br>
> >mmap. This supposes that the PythonWare Image Library and
Qt are<br>
> >willing to read/write those files.<br>
> ><br>
> >(2) convert the PIL image to a string (see PIL doc),
possibly make<br>
> >a QByteArray out of it and use loadFromData<br>
> ><br>
> >(3) use PIL to make a mmap, use all data of the
mmapped file<br>
> >as QByteArray in loadFromData<br>
> ><br>
> >(4) switch to Linux or buy Qt<br>
> ><br>
> >:-) Gerard<br>
> ><br>
> >Sheng-Te Tsao wrote:<br>
> > >Thank for the source code. I guess saving
it first as PNG first is a<br>
> > >possible solution :-)<br>
> > >Still, is there anyway to load the image into memory
directly without<br>
> ><having to save it as PNG first?<br>
> <br>
> <br>
> Sheng-Te Tsao<br>
> Online Status: <br>
>
<<a href="http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com" eudora="autourl">http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com</a>><<a href="http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com" eudora="autourl">http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com</a>><<a href="http://www.eudora.com/products/voicecontact/" eudora="autourl">http://www.eudora.com/products/voicecontact/</a>><br>
> <br>
> <html><br>
> Thanks for the tips.&nbsp;&nbsp; I'll look into
using<br>
> loadFromData.&nbsp;&nbsp;&nbsp;&nbsp; Of
course, if someone has done this<br>
> already, some sample code would be appreciated
:-)<br><br>
> <br><br>
> Sheng-Te<br><br>
> <br><br>
> At 06:43 PM 3/30/2001 +0200, Gerard Vermeulen
wrote:<br><br>
> <blockquote type=cite class=cite cite>Of course, the
example is a dumb<br>
> solution. If you want to keep<br><br>
> everything in memory, I would explore the
following:<br><br>
> <br><br>
> (1) use memory mapped files: look in the Python library
reference<br>
> for<br><br>
> mmap. This supposes that the PythonWare Image Library and Qt
are<br><br>
> willing to read/write those files.<br><br>
> <br><br>
> (2) convert the PIL image to a string (see PIL doc), possibly
make <br><br>
> a QByteArray out of it and use loadFromData<br><br>
> <br><br>
> (3) use PIL to make a mmap, use all data&nbsp; of the
mmapped file<br><br>
> as QByteArray in loadFromData<br><br>
> <br><br>
> (4) switch to Linux or buy Qt <br><br>
> <br><br>
> :-) Gerard<br><br>
> <br><br>
> Sheng-Te Tsao wrote:<br><br>
> &gt;Thank for the source code.&nbsp;&nbsp; I guess
saving it first as PNG<br>
> first is a <br><br>
> &gt;possible solution :-)<br><br>
> &gt;Still, is there anyway to load the image into memory
directly without<br>
> <br><br>
> &lt;having to save it as PNG
first?</blockquote><br><br>
> <!-- VC_SIGTAG --><br>Sheng-Te<br>
> Tsao<br><table cellpadding=2 cellspacing=3
bgcolor=#ffffff><tr><td>Online<br>
> Status:<br>
> <a
href="http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com"><img
NOSEND=1 height=16 width=100 border=0
src="http://eudora.voicecontact.com/servlets/presence?imgbase=status%252Fvc2final_email&amp;channel=HEARME_VC20.SDK.%2523tst%40eudoramail.com"></a></td><td><a
href="http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com"><img
border=0 NOSEND=1 height=25 width=75
src="http://eudora.voicecontact.com/vc3/images/email/vc2final/emailbtn_callsender.gif"></a></td><td><a
href="http://www.eudora.com/products/voicecontact/"><img
border=0 NOSEND=1 height=25 width=135
src="http://eudora.voicecontact.com/vc3/images/email/vc2final/download_eudora.gif"></a></td></tr></table><br></html><br>
<br>
-- <br>
Gey-Hong Gweon, Research Fellow, Ph.D.<br>
Randall Lab. of Physics, Univ. of Michigan, Ann Arbor, MI
48109-1120<br>
(734) 647-9434 (Office), 763-3417 (Lab), 763-9694
(Fax)</blockquote><br>
<!-- VC_SIGTAG --><br>Sheng-Te
Tsao<br><table cellpadding=2 cellspacing=3 bgcolor=#ffffff><tr><td>Online
Status:
<a href="http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com"><img NOSEND=1 height=16 width=100 border=0 src="http://eudora.voicecontact.com/servlets/presence?imgbase=status%252Fvc2final_email&channel=HEARME_VC20.SDK.%2523tst%40eudoramail.com"></a></td><td><a href="http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com"><img border=0 NOSEND=1 height=25 width=75 src="http://eudora.voicecontact.com/vc3/images/email/vc2final/emailbtn_callsender.gif"></a></td><td><a href="http://www.eudora.com/products/voicecontact/"><img border=0 NOSEND=1 height=25 width=135 src="http://eudora.voicecontact.com/vc3/images/email/vc2final/download_eudora.gif"></a></td></tr></table><br></html>