Solved

GIF and WAV in Turbo C++

Posted on 1997-08-18
20
1,524 Views
Last Modified: 2008-03-10
How do I display a GIF File using Turbo C++, and How do I Play a WAV file using Turbo C++???  
0
Comment
Question by:bass5763
20 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
Comment Utility
You'll need a GIF library to display GIF files using Turbo C++. It does not come with such a library. To play a .WAV files, you'll need to look at the multimedia functions (they start with mci). Alternatively, you can look at SndPlaySound.
0
 
LVL 1

Author Comment

by:bass5763
Comment Utility
Please send me some source code on how to include the GIF file, also I need to know where the GIF library is Available.

Thanks,
Matt Calhoun
0
 
LVL 1

Author Comment

by:bass5763
Comment Utility
My e-mail address is: Bass5763@hotmail.com
0
 

Expert Comment

by:randyw
Comment Utility
Maybe you can find the library with source examples at borland's page.  www.borland.com
0
 
LVL 1

Author Comment

by:bass5763
Comment Utility
Adjusted points to 107.5
0
 
LVL 1

Author Comment

by:bass5763
Comment Utility
Adjusted points to 133.5
0
 
LVL 1

Author Comment

by:bass5763
Comment Utility
Adjusted points to 150
0
 
LVL 1

Author Comment

by:bass5763
Comment Utility
Thui did not reply to my comment so his answer was rejected.

0
 
LVL 1

Author Comment

by:bass5763
Comment Utility
Adjusted points to 200
0
 
LVL 2

Accepted Solution

by:
Slarti earned 200 total points
Comment Utility
I assume from the fact that you are using Turbo C++ (rather than Borland C++) that you are programming for DOS.

GIF files are quite a mess to display. You can find extensive information on the various GIF formats in the following locations:
http://www.wotsit.demon.co.uk/graphics/gif.zip
http://www.wotsit.demon.co.uk/graphics/gif89a.zip
http://www.wotsit.demon.co.uk/graphics/lzwexp.zip
I once wrote a GIF viewer in C with a friend of mine. If I can find it I will e-mail it to you in a couple of days.

As for wavs, this is kind of complicated. Creative has a free SDK (software lib) for this purpose, but only for Sound Blaster and compatible sound cards. You can download it, together with extensive documentation in Word format, from their site at:
http://www.creativelabs.com/
(look under Tech Info, Developer's Corner).

hope this helps
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 1

Author Comment

by:bass5763
Comment Utility
Slarti, Ok, I just recently purchased Borland Turbo C++ 4.5 for windows, and I also have Borland Turbo C++ 2.0 for Dos.  So, If you have the info for the Windows way, could you also send it to me?

Thanks,
Matt Calhoun

Whats your E-mail addy???
0
 
LVL 2

Expert Comment

by:Slarti
Comment Utility
Displaying GIFs in Windows is pretty much the same in terms of the decompression routines, the only difference is in how you actually plot the pixels - this is related to the WM_PAINT message. If you're not familiar with painting in Windows get a basic Windows programming book, which will guide you through this (it is quite different from DOS programming which you are used to). I recommend:
Petzold, C., "Programming Windows 3.1", Microsoft Press, or
Petzold, C., "Programming Windows 95", Microsoft Press, which is pretty much the same book but for 32-bit programming.

As for the sound playing: If you want to just play a sound file that's sitting on the hard disk, use sndPlaySound(). Look it up in the help - it's rather straightforward. You give a parameter with the filename, and whether you want the file played in the background or in exclusive mode (which means the function will only return after the file has been played). sndPlaySound will play all versions for which there are drivers in the control panel, including, for example, ADPCM if the sound card supports it. It is also more flexible in that it's not exclusively for soundblaster-compatible sound cards, but for anything that's installed in your computer - which is one of the main advantages of Windows over DOS.

If sndPlaySound() is not adequate, you can go much deeper into the guts of your computer, but it gets more complicated as you go. The next level down is called MCI and allows you to play, record, etc. with more control - e.g. stopping in the middle of the file, and so on; but it still supports only files found on the hard disk - no playback from memory. If you really want to go all the way down you use what's called the low-level multimedia functions, in which you can really send buffers of data to Windows and they go directly to the sound card. But try to avoid this if you can - it's sort of a pain.

About my e-mail address: I'll let you know by e-mail when I send you the GIF source code.
0
 
LVL 1

Author Comment

by:bass5763
Comment Utility
Will the sndPlaySound() Let me play a WAV file that is embedded inside of a Packed file? An example of this would be:

Like in a WAD file, (ROTT) , they have all the sounds and stuff packed into one WAD file.  Is there any command that will let me play a sound from inside of a WAD, or so on?

Thanks,
Matt Calhoun
0
 
LVL 2

Expert Comment

by:Slarti
Comment Utility
No. sndPlaySound has an option of playing from memory, but it still has to be a valid WAV file. In your case, if you don't want to mess around with low-level functions, you will have to read the section you want into memory, and then somehow convert it to WAV format. You'll need to know the format of the WAD file, and convert it to WAV, and then play it from memory.
0
 
LVL 1

Author Comment

by:bass5763
Comment Utility
Well, The WAD file contains more than just sounds, it has all the graphics, and so on in it to, and I don't want to have to make my game where the sounds are not in one file, I know its possible, because both Interplay and ID software have done it.  But, If you could send me some source code, I'll grade it, and we can continue our lives eh?

Thanks A Whole Bunch,
Matt Calhoun

0
 
LVL 2

Expert Comment

by:Slarti
Comment Utility
Good idea...
I sent the file, good luck with it...

0
 
LVL 1

Author Comment

by:bass5763
Comment Utility
I need the source for the Dos viewer too... Also when i ran it, and displayed a gif file, the colors were all wrong, it displayed the red in place of blue, and blue in place of red.  If you send me the source, and It works, I'll give you an A. Sorry about the way I'm doing this, But, since the Dos one is the main one, I would need  the source, so that I can have it inside of a program, displaying graphics that are predefined.  

Thanks,
Matt Calhoun
0
 
LVL 2

Expert Comment

by:Slarti
Comment Utility
Matt,
I did send you the source code. I have a copy of it in my sent-mail folder. What else do you want me to send.
0
 
LVL 1

Author Comment

by:bass5763
Comment Utility
I need a working version of the source code!
The version you sent me had 26 errors when I compiled it. Also, it was missing the header file  "320x200.h"  Is it the Dos or Windows version? I compiled it in both, and got the same amount of errors. Also, the EXE you sent me Displayed the  wrong Colors, the Blues were Red, and the Reds were Blue!

Thanks,
Matt Calhoun
0
 
LVL 1

Author Comment

by:bass5763
Comment Utility
Well, It didn't work again, it gave me 26 errors, and I did everything you said.  If you could, attach all the files needed and the project file, and i'll try compiling it.  Hopefully it will work.

Thanks,
Matt Calhoun
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now