?
Solved

VC: Video application

Posted on 2000-01-27
10
Medium Priority
?
330 Views
Last Modified: 2010-04-10
Hi,
I am in the design stages of writing a program in Visual C++ 6 (MFC), and would like your comments. The program needs to read a set of nonstandard-format bitmap files and display them as video on screen. Ideally the program should be able to reach rates of about 30 fps.

I am currently seeking comments on the best way to do this. Right now I am thinking of reading the files one by one and BitBlting them. Any better ideas? Any comments on what framerate I will achieve in this method?

I will accept as an answer a link to written code which performs this operation. As the discussion evolves I may refine my question slightly. Or, if I get enough information from the comments, I will give the points to the expert who helped the most.

Thanks!
-- Slarti
0
Comment
Question by:Slarti
10 Comments
 
LVL 5

Expert Comment

by:Wyn
ID: 2392181
I once did this and I loaded all the maps together into a surface and bitblt them.
But I use Directx:)
Regards
Wyn.
0
 
LVL 2

Author Comment

by:Slarti
ID: 2392512
How difficult would it be to learn how to do this in Directx? Can anyone give me a sample code? I have never used DirectX before.
0
 
LVL 23

Expert Comment

by:chensu
ID: 2393721
Whether you can achieve the performance also depends on the bitmap size (display size and file size).
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 3

Expert Comment

by:GlennDean
ID: 2395489
BitBlting in DirectX is very similar to the CBitmap::Blt function, except you "Blt" to a target surface (typically a back buffer).  You can use DirectX in VC++ if you load ddraw.lib.  
   I know how to load a BMP file and Blt it to a surface but non-standard formats I have no clue how hard that is.  Once you figured that out, and you don't mind using COM (which DirectX hides from you for the most part) you can do what you want in a few days.
   MSDN has info on BitBlting in DirectX (check out IDirectDrawSurface3::Blt).
   Glenn
   
0
 
LVL 2

Author Comment

by:Slarti
ID: 2395754
Thanks for your info Glenn. I have a couple of questions (which go for all experts, of course):

1. Is it your estimation that using DirectDraw will be faster than ordinary BitBltting? Why do you think so? It seems to me that both APIs end up doing pretty much the same thing, so why bother?

2. Is there direct access to the BITMAP structure before I blt it? I need this in order to fill the bitmap with the pixels I want to blt (I know how to do this if I have a BITMAP structure).
0
 

Accepted Solution

by:
udia earned 200 total points
ID: 2396974
You can use DrawDib library functions. They are very simple to use and since the bitmaps are drawn directly to the video memory the performance is MUCH better then using standard GDI routines.
Refer the the MSDN documentation for further details.

If you are looking for an easy solution then DrawDib is the way to go. The only downside is that the DrawDib (and VFW) libraries are considered "old", even though they will be supported by Windows 2000 (and probably future versions as well).
0
 
LVL 3

Expert Comment

by:GlennDean
ID: 2397389
I made a mistake in my above comment - there is no CBitmap::Blt function.  I always forget in MFC you call BitBlt from the CDC class.
   I'm sure this is not the way to go, but you can always get complete info on a bitmap simply by reading from the BMP directly.  The first section of the BMP file is always a BITMAPFILEHEADER structure and the second is always a BITMAPINFOHEADER structure.  THEN, depending on what's in those two structures tells you what the rest of the BMP file contains.  You mentioned you needed info on the bitmap before Blt - most likely you need width,height, bit count (bpp) and image size which are all contained in the BITMAPINFOHEADER.
   Glenn
0
 
LVL 2

Author Comment

by:Slarti
ID: 2437521
Thanks for your comments everyone.

udia: I looked up DrawDib and it sounds interesting. However, it looks like the drawing is into direct screen coordinates, i.e. not into a window. Is this true? If so, could you or anyone else give me some code that will translate window coordinates to screen coordinates? (I need, for example, to be able to put the video in a resizable window, preferably with scroll bars).

Glenn: You are referring to the part of creating the bitmap. I know how to handle this part, I've done so before. I am looking for information on the fastest way to draw the bitmap on screen.
0
 
LVL 2

Author Comment

by:Slarti
ID: 2437562
I am actually not too sure about what I said in the last comment, about drawing into screen coordinates. The function DrawDibBegin() has a HDC parameter which is described as "Handle of a DC for drawing. This parameter is optional." Typical Microsoft online help phrazing: it tells me only what I don't need to know.

Does anybody know what this parameter does? In particular, does it cause DrawDib to plot into the coordinates limited by the supplied DC? If so, that's what I need.
0
 
LVL 2

Author Comment

by:Slarti
ID: 2519455
Since this thread has died down, and I have not received answers to some of my more specific answer, I will accept udia's last comment as an answer with grade C. Thank you everyone for your participation.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question