How can I stream to a wxImage?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Nintendofreak88
Knows some wx things
Knows some wx things
Posts: 28
Joined: Mon Mar 14, 2005 2:16 am

How can I stream to a wxImage?

Post by Nintendofreak88 » Mon May 09, 2005 9:51 pm

I've looked at the image example and it shows streaming, but here's my problem. I'd like to do the stream reading into the wxImage myself because I want to have a progress bar (for loading very large images) and a cancel button while loading. When I pass a wxFileInputStream to wxImage::Load, it loads the thing by itself, and I have no time to display the progrmess bar, etc. Any ideas on how I might go about this? Is there soem way I can manually stream into a wxImage or wxBitmap? Thanks. :)

travfar
Earned some good credits
Earned some good credits
Posts: 132
Joined: Mon Apr 04, 2005 12:54 am
Location: California
Contact:

Post by travfar » Mon May 09, 2005 10:44 pm

You could try writing your own wxImageHandler but I have no idea how.
I see said the blind man to the deaf girl who was mute.

Visit my project at: http://vwp.sourceforge.net

wx version:2.6.2 and 2.6.3 on linux
OS's:Windows XP, Gentoo is the best!!!!!!
compiler:Codeblocks(MingW32) and gcc on linux

Nintendofreak88
Knows some wx things
Knows some wx things
Posts: 28
Joined: Mon Mar 14, 2005 2:16 am

Post by Nintendofreak88 » Mon May 09, 2005 11:28 pm

Well isn't there a way wxWidgets has built in to do that...? I've only been using it for a few months, and I probably couldn't write one even if I tried... :?

eco
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 203
Joined: Tue Aug 31, 2004 7:06 pm
Location: Behind a can of Mountain Dew
Contact:

Post by eco » Tue May 10, 2005 1:10 am

You might be able to derive a new class from wxFileInputStream and update the progress bar from there. It probably wouldn't cover the time needed to decompress the image but at least you'd get the file load progress.

Nintendofreak88
Knows some wx things
Knows some wx things
Posts: 28
Joined: Mon Mar 14, 2005 2:16 am

Post by Nintendofreak88 » Tue May 10, 2005 1:39 am

So should I overload the wxInputStream::Read method or the wxStreamBase::OnSysRead method? Also if I were to overload it how could i call the wxFileInputStream's version of the method from my new method?

eco
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 203
Joined: Tue Aug 31, 2004 7:06 pm
Location: Behind a can of Mountain Dew
Contact:

Post by eco » Tue May 10, 2005 6:41 am

I'm not sure, I've never done it. Has anyone on the board derived from wxFileInputStream and would like to share their insight?

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE » Tue May 10, 2005 6:56 am

Hi!
Nintendofreak88 wrote:So should I overload the wxInputStream::Read method or the wxStreamBase::OnSysRead method? Also if I were to overload it how could i call the wxFileInputStream's version of the method from my new method?
I just had a look at the code and I'd say that you should overload the wxStreamBase::OnSysRead() method as it is declared as a pure virtual function for wxInputStream and gets called by wxInputStream::Read() internaly.
As for the second question: Call the "normal" version of the methods with a wxFileInputStream:: prefix. So for calling wxFileInputStreams Ok() method use wxFileInputStream::Ok().
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

Nintendofreak88
Knows some wx things
Knows some wx things
Posts: 28
Joined: Mon Mar 14, 2005 2:16 am

Post by Nintendofreak88 » Tue May 10, 2005 12:07 pm

That worked perfectly! Thanks everyone!

Post Reply