DirectDraw for fast DIB drawing?

Environment: Visual C++ 5.0 SP3, WinNT 4.0

I realise that there is a great deal of information about DirectX available
via the WEB and Microsoft SDKs, and I have spent the last two days perusing
this information. However it seems a little bit sketchy in the actual area I
require. If anybody knows of anywhere where I can get info on, or samples /
examples of the following I would be very interested:


My application is for Windows NT4.0 (I believe I can use up to DirectX3.0
with NT), the software requires a video capture board to be located in the
machine. The capture board supplies a pointer to each captured image in
RGB24 format to the software via a driver. I then use this pointer to draw
the captured image to a "monitor" using StretchDIBits(). The problem I have
is this is very slow. In particular because the monitor is only a small part
of the whole program (it is in a separate thread to prevent the rest of the
program being stalled.)

Firstly would it be faster to use BitBlt using front and back buffers as in
the samples provided? Would this be a significant improvement for the
overhead of using the DirectX SDK?

I believe it is possible to use DirectX to speed this up but what exactly do
I need to do. Is it possible to simply allocate space for the image on a
pre-allocated DirectDraw surface, and just copy the image to it? I know that
some video capture card drivers use overlay to display images directly to
the video card surface but I can find no examples of how this is possible. I
have also found a reference to DirectShow for multimedia applications but
this does not seem to cope with the raw data. And finally I have seen
references to VideoPorts in the DirectDraw online help, but no samples of
how to use them, or examples of how to correctly set up a videoport.
(Videoports are stated to be developers who want to include video playback
in their applications: is it also possible for images taken directly from a
capture card?)

Many Thanks In Advance,

Spencer Jones
Chief Software Developer
Azure Limited
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

First if you have enough video memory you can screate directDraw surface in this memory and then blit your image on this surface using either IDirectDrawSurface2::Blt or IDirectDrawSurface2::BltFast. Then use IDirectDrawSurface2::Flip to make this front-buffer surface front buffer surface. This operation is very fast and doesn't cause any flickering. If you don't have enough video memory you can build back buffer surface in regular memory. In this case istead of Flip you must blit from back buffer onto front buffer using Blt or BltFast. It is slower then Flip but faster then off screen GDI blitting. You can also use DrawDIBDraw do send raw data to back buffer.

If you download DirectX SDK see DirectDraw samples. There is sample which parses AVI file into separate frames and uses DrawDIBDraw to draw a frame on back buffer.
sdjAuthor Commented:
I have downloaded the SDK (I have version 5.0 on my 95 machine, although I know I can not use this for NT) and through the multiple samples I still can not find one that uses video. I have searched them all on the keywords "avi", "DrawDIBDraw" and "video".

Hence I understand you are confirming that it should be quicker to use DirectDraw, however I still can not find any good sample code....

Thanks Anyway,
I am sorry this sample is AVIDD95 and can be downloaded from Microsoft ftp or WWW.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.