• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 990
  • Last Modified:

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
0
sdj
Asked:
sdj
  • 2
1 Solution
 
galkinCommented:
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.
0
 
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,
Spencer
0
 
galkinCommented:
I am sorry this sample is AVIDD95 and can be downloaded from Microsoft ftp or WWW.
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now