[wxPython] wxImage construction from StringIO?

I'm trying to create a bunch of wxImages from data in a zipfile.
I've got the data wrapped in StringIO objects, but wxImage will
apparently only load files directly from disk, not from memory.
I *could* use PIL to process each image, or save a temp file to
disk, but I'm going to be doing about 100-200 images at a time
and this is rather slow--I'd think that loading them directly as
(StringIO->wxImage) or even (StringIO->wxstream->wxImage) would
be a lot faster than (StringIO->PILImage->datastring->wxImage).

Searching the archives, it seems that Robin mentioned (in
February) that he was considering the possibility of wrapping
wxstream objects for wxPython. Has this been done? I don't see
any mention of wxImage stream constructors in the docs (for
wxPython 2.3.2), but I'm hoping that maybe the docs just didn't
get updated... :wink: I *do* see that there is a wrapper for
wxInputStream, but no indications of how to use it. (I can pass a
StringIO object to the constructor and the stream will read()
okay, but trying to seek() locks up the interpreter...) and no
sign of any derived classes (the wxWindows docs note that
wxInputStream is an abstract base...) And even if I could get a
fully working wxInputStream, I'm still not sure how to pass that
to a wxImage...

Am I missing something? Is there some way to use the existing
wxInputStream to accomplish this? Or will I just have to live
with the slower load time from PIL overhead?

Jeff Shannon
Technician/Programmer
Credit International

I'm trying to create a bunch of wxImages from data in a zipfile.
I've got the data wrapped in StringIO objects, but wxImage will
apparently only load files directly from disk, not from memory.
I *could* use PIL to process each image, or save a temp file to
disk, but I'm going to be doing about 100-200 images at a time
and this is rather slow--I'd think that loading them directly as
(StringIO->wxImage) or even (StringIO->wxstream->wxImage) would
be a lot faster than (StringIO->PILImage->datastring->wxImage).

...

Am I missing something? Is there some way to use the existing
wxInputStream to accomplish this?

Not currently. I think the wxInputStream wrappers are supposed to be able
to do this but I havn't checked for sure. (I didn't write them, they were
contributed.) But even if it can, the wxImage methods needed to load from a
stream are not wrapped.

Or will I just have to live
with the slower load time from PIL overhead?

For now yes, but this item is nearing the top of my TODO list so I hope to
have it working soon.

ยทยทยท

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!