Using C++ and .net I have a stream of data I want to display as a scrolling image. Each time I get some new data I want to add it as a new row (128×1 pixels) and scroll the previous contents to one side.
My first stab at the problem involved rendering the entire data set each time I got a new row. This worked, but was far too slow, so I’m thinking it might make more sense to write to a buffer of some sort (a bitmap maybe?). The problem is that I can’t see how I can do that; Graphic objects allow you to draw quite happily, but I can’t see an obvious way to tell my control to use a Bitmap object as it’s buffer? Similarly, I can’t see a way to draw on a bitmap which I could then write to the screen.
This must be possible, but my google-foo has failed me thus far…
[Edit1] Just to clarify, the data is a spectrogram. The following image shows the sort of thing I was trying to achieve:
alt text http://www.geekops.co.uk/photos/0000-00-02%20(Forum%20images)/ScrollingGraphicsAlgorithmExplanation.png
The data I’m plotting comes in arrays of floats. There’s nothing to limit how many I’ll get, so I just want to forget data as it drops off the side of the plot.
I’m currently inheriting from a System::Windows::Forms::UserControl, but could switch to something else if there’s a better alterative?
Take a look at the ScrollWindow win32 method. You can scroll the existing data on the screen and then draw only the new data. This is very fast.