Displaying bitmaps rapidly

Go To StackoverFlow.com

1

I have a WPF application where I need to add a feature that will display a series of full screen bitmaps very fast. In most cases it will be only two images, essentially toggling the two images. The rate they are displayed should be constant, around 10-20ms per image. I tried doing this directly in WPF using a timer, but the display rate appeared to vary quit a bit. I also tried using SharpGL (a .Net wrapper on OpenGL), but it was very slow when using large images (I may not have been doing the best way). I will have all the bitmaps upfront, before compile time, so the format could be changed as long as the pixels are not altered.

What would be the best way to do this?

I'm already behind schedule so I don't have time to learn lots of APIs or experiment with lots of options.

2012-04-04 00:12
by softwork
Is your program hogging up the system or can other programs be running? You will need to have them in memory, as loading them from disk will prevent this speed, is that reasonable - James Black 2012-04-04 00:17
James, this will be the only application running on the system, so I don't need to worry about hogging resources - softwork 2012-04-04 13:54


1

"I tried doing this directly in WPF using a timer, but the display rate appeared to vary quit a bit."

Instead of using a Timer, use Thread.Sleep(20) as it wont hog as many system resources. This should give you an immediate improvement.

It also sounds as though there will be user interaction with the application while the images are rapidly toggling, in this case put the code that toggles the images in a background thread. Remember though that the UI- is not thread safe.

These are just quick wins, but you might need to use DirectX for Hardware Acceleration to get around HAL:

The Windows' Hardware Abstraction Layer (HAL) is implemented in Hal.dll. The HAL implements a number of functions that are implemented in different ways by different hardware platforms, which in this context, refers mostly to the Chipset. Other components in the operating system can then call these functions in the same way on all platforms, without regard for the actual implementation.

2012-04-04 01:08
by Jeremy Thompson
Using a high resolution timer would also be helpful: http://msdn.microsoft.com/en-us/library/aa964692(v=vs.85).asp - James Black 2012-04-04 14:46
Ads