wxImage & DIB suggestions Topic is solved

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
spectrum
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Sat Jul 21, 2007 12:17 pm

wxImage & DIB suggestions

Post by spectrum »

hi all,
i was wandering if my approach of displaying a DIB is correct.

I have a DIB in memory, generated from a commerical graphic library.

Using wxWidget 2.8 im using the following procedure to display it, and mantain the application win/mac portable.

1) i mirror the Y axis (my own function) of the bitmap in memory (DIB are stored with lines reversed).
2) sometime the DIB is 8bpp, so when necessary, i convert 8bpp to 24bpp (my own function).
3) i give the 24bpp buffer to the wxImage constructor.
4) i create a wxBitmap(wxImage)
5) i use dc.DrawBitmap

This procedure works fine, but i'm not sure if i can avoid some steps, if i'm missing something to make it easier.


Many thanks, Angelo
spectrum
Trikko
Experienced Solver
Experienced Solver
Posts: 94
Joined: Tue Oct 18, 2005 8:28 pm
Location: Venice, IT
Contact:

Re: wxImage & DIB suggestions

Post by Trikko »

spectrum wrote:hi all,
i was wandering if my approach of displaying a DIB is correct.

I have a DIB in memory, generated from a commerical graphic library.

Using wxWidget 2.8 im using the following procedure to display it, and mantain the application win/mac portable.

1) i mirror the Y axis (my own function) of the bitmap in memory (DIB are stored with lines reversed).
2) sometime the DIB is 8bpp, so when necessary, i convert 8bpp to 24bpp (my own function).
3) i give the 24bpp buffer to the wxImage constructor.
4) i create a wxBitmap(wxImage)
5) i use dc.DrawBitmap

This procedure works fine, but i'm not sure if i can avoid some steps, if i'm missing something to make it easier.


Many thanks, Angelo
Do you call these steps many times?
Are dib dimensions fixed?
spectrum
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Sat Jul 21, 2007 12:17 pm

Post by spectrum »

the application display a particular XY graph. For now i've fixed it to 640x480, and i recall the procedure everytime i zoom or i move the diagram.
spectrum
Trikko
Experienced Solver
Experienced Solver
Posts: 94
Joined: Tue Oct 18, 2005 8:28 pm
Location: Venice, IT
Contact:

Post by Trikko »

spectrum wrote:the application display a particular XY graph. For now i've fixed it to 640x480, and i recall the procedure everytime i zoom or i move the diagram.
Maybe you can speedup a bit using a single wxImage everytime, and updating its buffer copying memory from dib to wxImage buffer (using memory functions like memcpy).

I know there're some undocumented classes that you can use to access to raw bitmap data maybe. In this case you can use wxBitmap only (without wxImage)
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

Trikko wrote:I know there're some undocumented classes that you can use to access to raw bitmap data maybe. In this case you can use wxBitmap only (without wxImage)
There's a file called rawbmp.h that contains just that. It contains some example code as well. Can be pretty handy.
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
spectrum
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Sat Jul 21, 2007 12:17 pm

Post by spectrum »

many thanks
spectrum
Post Reply