Dynamic Bitmap Surface

Sri

Newcomer
Joined
Oct 9, 2005
Messages
4
Location
Singapore
I need to show streaming images (changing bitmaps, which are created in the
app during every cycle of operation) on the screen.

I thought of implementing this in DirectDraw to speed up the display, time
being very critical in my app (total cycle time is in the order of 100 to 200
ms). But later realized that creating bitmap surfaces (using Surface
constructor) whenever I need to show a new bitmap is very time consuming.

Then I changed the way bitmaps are drawn by getting the DC of the surface
and using GDI+ to DrawImage onto this DC. But even this takes too much time
to blit, as my bitmaps are usually large (upto 2k x 2k).

Can anyone suggest a better way of doing this? Is my choice of using DirectX
for this interface justified compared to a normal GDI+ interface, to speed up
the display?

I'd really appreciate any light on this.

Thanks.
 
DirectX is much faster than GDI+ because the former runs on the hardware and GDI+ runs on software. If speed is of the essence, DirectX is most likely your best bet, but it makes the system requirments a bit higher.
 
Thanks for the inputs. I understand that the second stage which actually does the rendering to the hardware is done better in DirectX. But, considering the first stage wherein the bitmap is drawn to the surface in memory (which is where I think is my bottleneck), does DirectX have any advantage?

For drawing new images repeatedly on a surface, is it worthwhile to do it by getting the DC of the surface and draw the bitmap using GDI's DrawImage? Or, is there a better way?

I had to do this as I could not find any suitable method in the Surface class to pass a new bitmap to be used on an existing surface. Instead, everytime I need to destroy the surface and create a new one using the new bitmap.

BTW, I'm uisng managed DirectX 9.0c on .NET Framework 1.1.


Thanks.
 
I wouldn't use a surface. I would use a texture with the flag 'Dynamic'. Then display the texture using a sprite.

Are you loading the bitmaps from existing files or from some kind of I/O stream? Are the files already there? For example, 200 files already in one directory? In which case, you can buffer 10 or so into memory.
 
My bitmaps are System.Drawing.Bitmap objects, dynamically generated within my application and they are not files. I need to process the bitmap and display from memory as I can't afford disk access during the process cycle. And at any time, only one valid bitmap is available.

Thanks.
 
Is there any possibility that you can render your image onto the DirectDraw.Surface rather than the System.Drawing.Bitmap and save yourself a step? (DirectX has functions to draw on a surface, though not as many as GDI+).
 
No, my application is basically an image processing solution wherein I have to,
1. read images from an external source (thru a communication port),
2. do some analysis and image transformation
3. and then display the result image with statistics.

This is the complete cycle, and is iterated as long as new images are available.

As I need the power of raw bitmap, I will be left with a System.Drawing.Bitmap object to be displayed at the end of processing. How can I achieve this with minimum overhead? (using directx surfaces or otherwise).

Thanks for the inputs so far.
 
Back
Top