Solved

GIF and WAV in Turbo C++

Posted on 1997-08-18
20
1,536 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
ID: 1167687
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
ID: 1167688
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
ID: 1167689
My e-mail address is: Bass5763@hotmail.com
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Expert Comment

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

Author Comment

by:bass5763
ID: 1167691
Adjusted points to 107.5
0
 
LVL 1

Author Comment

by:bass5763
ID: 1167692
Adjusted points to 133.5
0
 
LVL 1

Author Comment

by:bass5763
ID: 1167693
Adjusted points to 150
0
 
LVL 1

Author Comment

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

0
 
LVL 1

Author Comment

by:bass5763
ID: 1167695
Adjusted points to 200
0
 
LVL 2

Accepted Solution

by:
Slarti earned 200 total points
ID: 1167696
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
 
LVL 1

Author Comment

by:bass5763
ID: 1167697
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
ID: 1167698
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
ID: 1167699
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
ID: 1167700
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
ID: 1167701
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
ID: 1167702
Good idea...
I sent the file, good luck with it...

0
 
LVL 1

Author Comment

by:bass5763
ID: 1167703
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
ID: 1167704
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
ID: 1167705
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
ID: 1167706
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

828 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