There was talk on the lists last year about wxImage accepting an IO stream like the wxWindows. Has this happened and if not how can I best convert the JPEG stream from a server into a wxImage or bitmap in memory?
Nigel
There was talk on the lists last year about wxImage accepting an IO stream like the wxWindows. Has this happened and if not how can I best convert the JPEG stream from a server into a wxImage or bitmap in memory?
Nigel
----- Original Message
From: Nigel Moriarty
There was talk on the lists last year about wxImage accepting an IO stream like the wxWindows. Has this happened and if not how
can I best >convert the JPEG stream from a server into a wxImage or bitmap in memory?
Nigel
The version currently in CVS has it, although I have not tried it. Here's an excerpt from
the Demo. You have to d/l the CVS version from wxWindows website and build it, though.
#--------------------------------
Jeff Sasmor
jeff@sasmor.com
-----------------------------------------------------------
from wxPython.wx import *
from Main import opj
from cStringIO import StringIO
#----------------------------------------------------------------------
class TestPanel(wxPanel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1)
data = open(opj('bitmaps/image.gif'), "rb").read()
stream = StringIO(data)
bmp = wxBitmapFromImage( wxImageFromStream( stream ))
wxStaticText(self, -1,
"This image was loaded from a Python file-like object:",
(15, 15))
wxStaticBitmap(self, -1, bmp, (15, 45))
#----------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#----------------------------------------------------------------------
overview = """\
At long last there is finally a way to load any supported image type
directly from any Python file-like object, such as a memory buffer
using StringIO. """
Thanks for the prompt reply. I'll d/l forthwith.
----- Original Message -----
From: "Jeff Sasmor" <jsasmor@gte.net>
To: <wxpython-users@lists.wxwindows.org>
Sent: Friday, May 31, 2002 11:13 AM
Subject: Re: [wxPython] wxImage
----- Original Message
>From: Nigel Moriarty
>There was talk on the lists last year about wxImage accepting an IO
stream like the wxWindows. Has this happened and if not how
can I best >convert the JPEG stream from a server into a wxImage or bitmap
in memory?
>Nigel
The version currently in CVS has it, although I have not tried it. Here's
an excerpt from
the Demo. You have to d/l the CVS version from wxWindows website and build
it, though.
#--------------------------------
Jeff Sasmor
jeff@sasmor.com-----------------------------------------------------------
from wxPython.wx import *
from Main import opjfrom cStringIO import StringIO
#----------------------------------------------------------------------
class TestPanel(wxPanel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1)data = open(opj('bitmaps/image.gif'), "rb").read()
stream = StringIO(data)bmp = wxBitmapFromImage( wxImageFromStream( stream ))
wxStaticText(self, -1,
"This image was loaded from a Python file-like
object:",
(15, 15))
wxStaticBitmap(self, -1, bmp, (15, 45))#----------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win#----------------------------------------------------------------------
overview = """\
At long last there is finally a way to load any supported image type
directly from any Python file-like object, such as a memory buffer
using StringIO. """_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users
There was talk on the lists last year about wxImage accepting an
IO stream like the wxWindows. Has this happened and if not how
can I best convert the JPEG stream from a server into a wxImage
or bitmap in memory?
I recently tried
img = wxBitmapFromImage(wxImageFromStream(file(r"C:\Steve\My
Pictures\bluespiral.png", "rb")))
and it worked fine. I was using 2.3.3pre3, haven't tested 2.3.2 for its
presence.
regards
-----------------------------------------------------------------------
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------