<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.&nbsp;&nbsp; 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 &quot;png&quot; 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>
&nbsp;&gt; Thanks for the tips.&nbsp;&nbsp; I'll look into using
loadFromData.&nbsp;&nbsp;&nbsp;&nbsp; Of course, if <br>
&nbsp;&gt; someone has done this already, some sample code would be
appreciated :-)<br>
&nbsp;&gt; <br>
&nbsp;&gt; Sheng-Te<br>
&nbsp;&gt; <br>
&nbsp;&gt; At 06:43 PM 3/30/2001 +0200, Gerard Vermeulen wrote:<br>
&nbsp;&gt; &gt;Of course, the example is a dumb solution. If you want to
keep<br>
&nbsp;&gt; &gt;everything in memory, I would explore the following:<br>
&nbsp;&gt; &gt;<br>
&nbsp;&gt; &gt;(1) use memory mapped files: look in the Python library
reference for<br>
&nbsp;&gt; &gt;mmap. This supposes that the PythonWare Image Library and
Qt are<br>
&nbsp;&gt; &gt;willing to read/write those files.<br>
&nbsp;&gt; &gt;<br>
&nbsp;&gt; &gt;(2) convert the PIL image to a string (see PIL doc),
possibly make<br>
&nbsp;&gt; &gt;a QByteArray out of it and use loadFromData<br>
&nbsp;&gt; &gt;<br>
&nbsp;&gt; &gt;(3) use PIL to make a mmap, use all data&nbsp; of the
mmapped file<br>
&nbsp;&gt; &gt;as QByteArray in loadFromData<br>
&nbsp;&gt; &gt;<br>
&nbsp;&gt; &gt;(4) switch to Linux or buy Qt<br>
&nbsp;&gt; &gt;<br>
&nbsp;&gt; &gt;:-) Gerard<br>
&nbsp;&gt; &gt;<br>
&nbsp;&gt; &gt;Sheng-Te Tsao wrote:<br>
&nbsp;&gt; &gt; &gt;Thank for the source code.&nbsp;&nbsp; I guess saving
it first as PNG first is a<br>
&nbsp;&gt; &gt; &gt;possible solution :-)<br>
&nbsp;&gt; &gt; &gt;Still, is there anyway to load the image into memory
directly without<br>
&nbsp;&gt; &gt;&lt;having to save it as PNG first?<br>
&nbsp;&gt; <br>
&nbsp;&gt; <br>
&nbsp;&gt; Sheng-Te Tsao<br>
&nbsp;&gt; Online Status: <br>
&nbsp;&gt;
&lt;<a href="http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com" eudora="autourl">http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com</a>&gt;&lt;<a href="http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com" eudora="autourl">http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com</a>&gt;&lt;<a href="http://www.eudora.com/products/voicecontact/" eudora="autourl">http://www.eudora.com/products/voicecontact/</a>&gt;<br>
&nbsp;&gt; <br>
&nbsp;&gt; &lt;html&gt;<br>
&nbsp;&gt; Thanks for the tips.&amp;nbsp;&amp;nbsp; I'll look into
using<br>
&nbsp;&gt; loadFromData.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Of
course, if someone has done this<br>
&nbsp;&gt; already, some sample code would be appreciated
:-)&lt;br&gt;<br>
&nbsp;&gt; &lt;br&gt;<br>
&nbsp;&gt; Sheng-Te&lt;br&gt;<br>
&nbsp;&gt; &lt;br&gt;<br>
&nbsp;&gt; At 06:43 PM 3/30/2001 +0200, Gerard Vermeulen
wrote:&lt;br&gt;<br>
&nbsp;&gt; &lt;blockquote type=cite class=cite cite&gt;Of course, the
example is a dumb<br>
&nbsp;&gt; solution. If you want to keep&lt;br&gt;<br>
&nbsp;&gt; everything in memory, I would explore the
following:&lt;br&gt;<br>
&nbsp;&gt; &lt;br&gt;<br>
&nbsp;&gt; (1) use memory mapped files: look in the Python library
reference<br>
&nbsp;&gt; for&lt;br&gt;<br>
&nbsp;&gt; mmap. This supposes that the PythonWare Image Library and Qt
are&lt;br&gt;<br>
&nbsp;&gt; willing to read/write those files.&lt;br&gt;<br>
&nbsp;&gt; &lt;br&gt;<br>
&nbsp;&gt; (2) convert the PIL image to a string (see PIL doc), possibly
make &lt;br&gt;<br>
&nbsp;&gt; a QByteArray out of it and use loadFromData&lt;br&gt;<br>
&nbsp;&gt; &lt;br&gt;<br>
&nbsp;&gt; (3) use PIL to make a mmap, use all data&amp;nbsp; of the
mmapped file&lt;br&gt;<br>
&nbsp;&gt; as QByteArray in loadFromData&lt;br&gt;<br>
&nbsp;&gt; &lt;br&gt;<br>
&nbsp;&gt; (4) switch to Linux or buy Qt &lt;br&gt;<br>
&nbsp;&gt; &lt;br&gt;<br>
&nbsp;&gt; :-) Gerard&lt;br&gt;<br>
&nbsp;&gt; &lt;br&gt;<br>
&nbsp;&gt; Sheng-Te Tsao wrote:&lt;br&gt;<br>
&nbsp;&gt; &amp;gt;Thank for the source code.&amp;nbsp;&amp;nbsp; I guess
saving it first as PNG<br>
&nbsp;&gt; first is a &lt;br&gt;<br>
&nbsp;&gt; &amp;gt;possible solution :-)&lt;br&gt;<br>
&nbsp;&gt; &amp;gt;Still, is there anyway to load the image into memory
directly without<br>
&nbsp;&gt; &lt;br&gt;<br>
&nbsp;&gt; &amp;lt;having to save it as PNG
first?&lt;/blockquote&gt;&lt;br&gt;<br>
&nbsp;&gt; &lt;!-- VC_SIGTAG --&gt;&lt;br&gt;Sheng-Te<br>
&nbsp;&gt; Tsao&lt;br&gt;&lt;table cellpadding=2 cellspacing=3
bgcolor=#ffffff&gt;&lt;tr&gt;&lt;td&gt;Online<br>
&nbsp;&gt; Status:<br>
&nbsp;&gt; &lt;a
href=&quot;http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com&quot;&gt;&lt;img
NOSEND=1 height=16 width=100 border=0
src=&quot;http://eudora.voicecontact.com/servlets/presence?imgbase=status%252Fvc2final_email&amp;amp;channel=HEARME_VC20.SDK.%2523tst%40eudoramail.com&quot;&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a
href=&quot;http://eudora.voicecontact.com/vc3/?tst%40eudoramail.com&quot;&gt;&lt;img
border=0 NOSEND=1 height=25 width=75
src=&quot;http://eudora.voicecontact.com/vc3/images/email/vc2final/emailbtn_callsender.gif&quot;&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a
href=&quot;http://www.eudora.com/products/voicecontact/&quot;&gt;&lt;img
border=0 NOSEND=1 height=25 width=135
src=&quot;http://eudora.voicecontact.com/vc3/images/email/vc2final/download_eudora.gif&quot;&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br&gt;&lt;/html&gt;<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&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>