How do you put images file into one file?
Hi guys, it may be stupid to ask this question, but can anyone help me out? How do you put image files into a single file of own format? I want to hear recommendations of yours, how do you go around implementing it?
I''m gonna learn MFC, would that be of any help? Thanks for your time!
Well, first you have read the image from one of the known formats. MFC can help you with this. It knows about the BMP format, but BMP is so simple that you can do without MFC. Maybe you should find some information about file formats.
When this is done you just output the info to a new file in a structure of your liking. The point here is that you need to define your own format.
Instead of doing this you might consider using one of the formats that supports multiple images such as the GIF format.
A format that is very easy to read and write is the PPM format so you might want to use this as a beginning for making your own format if you are a beginner in programming.
Jacob Marner
When this is done you just output the info to a new file in a structure of your liking. The point here is that you need to define your own format.
Instead of doing this you might consider using one of the formats that supports multiple images such as the GIF format.
A format that is very easy to read and write is the PPM format so you might want to use this as a beginning for making your own format if you are a beginner in programming.
Jacob Marner
Jacob Marner, M.Sc.Console Programmer, Deadline Games
I think what Baling is looking for is what''s known as resource files. Take a look here at gamedev, the Code off the Cob series has a section on resource files, but it''s a little hard to implement into your own system (particularly if you''re using Borland c++ Builder). There is also another article here which describes what they do, as well as an interface for the functions, but there''s no examples there.
Good Luck!
Simon
Good Luck!
Simon
XEOS Digital Development - Supporting the independant and OpenSource game developers!
xeos:
He wouldn't want to learn MFC, if he's using C++ Builder. But resource files are an option.
Baling:
I like using ZIP Files for all my data. Actually, during development I can keep all my data in a directory. Then, once I'm finished, I just use WinZip to zip the directory and am finished. My code automatically handles the transition and no changes have to be done to the program (no recompilation necessary ). Given ZLIB and the ZIP-File format specification, it is pretty simple to implement. With WinZip you could also just store the files in the ZIP Archive (No compression is used), so you wouldn't need ZLIB. I recommend that you use a 'standard' and not your own file format. It saves the trouble of writing your own utilities.
Happy coding,
Marco Koegler
Edited by - MK42 on May 27, 2000 6:39:49 AM
He wouldn't want to learn MFC, if he's using C++ Builder. But resource files are an option.
Baling:
I like using ZIP Files for all my data. Actually, during development I can keep all my data in a directory. Then, once I'm finished, I just use WinZip to zip the directory and am finished. My code automatically handles the transition and no changes have to be done to the program (no recompilation necessary ). Given ZLIB and the ZIP-File format specification, it is pretty simple to implement. With WinZip you could also just store the files in the ZIP Archive (No compression is used), so you wouldn't need ZLIB. I recommend that you use a 'standard' and not your own file format. It saves the trouble of writing your own utilities.
Happy coding,
Marco Koegler
Edited by - MK42 on May 27, 2000 6:39:49 AM
Ah, firstly, thanks a lot guys.
felonius :
Yeah, I was planning to do that also, just wanted to know your way of implementing it. Maybe you''ve got something I was not aware of.
xeos :
Ha, I''m not using the building, anyway there''s also resources in Visual C++ but if I were to add anything to the game later on, I got to recompile the thing :p
Marco :
This is pretty new to me, so what is that ZLIB? How did you implement yours? Because I don''t understand how your code works and I don''t have the specification either
felonius :
Yeah, I was planning to do that also, just wanted to know your way of implementing it. Maybe you''ve got something I was not aware of.
xeos :
Ha, I''m not using the building, anyway there''s also resources in Visual C++ but if I were to add anything to the game later on, I got to recompile the thing :p
Marco :
This is pretty new to me, so what is that ZLIB? How did you implement yours? Because I don''t understand how your code works and I don''t have the specification either
Hi!
ZLIB:
It''s a compression library, which implements the algorithm used in ZIP-Files. It''s also used in PNG files. You can get it at ftp://ftp.freesoftware.com/pub/infozip/zlib/
What I do:
Essentially, what I do is pretty simple. I have a manager class which is responsible for opening specific resources (images, other files, etc...). Now, at the beginning of my program I tell the manager class that it is responsible for a path, for example "IMAGES". Then the manager checks, whether there is a directory called "IMAGES". If there is, an archive class is created, which handles all the file stuff for directories. If there is no directory, the manager will look for a file (it tries to locate IMAGES.ZIP, IMAGES.DAT, IMAGES.PAK, and a few more). If the file is found, it is treated as a ZIP Archive and an archive class is created, which handles all the file stuff for ZIP-Files. That way, you can just tell the manager class:
TextureManager.Open("texture.tga");
and it does everything necessary. The actual program just doesn''t CARE where the file comes from, the manager and the archive classes handle all the difficult stuff. Now, this system is pretty tightly integrated into several projects of mine, so I can''t directly give it to you (my managers are application specific and I use a file-in-memory representation), but if you are interested in pursuing this, I can probably part with some code for the ZIP-File stuff. It won''t compile, since you need some more pieces for it to work, but you could take a look at how you can load ZIP-Files. Just send me a mail (koegler@uni-koblenz.de).
Resource files might be simpler to work with (and it also saves you a lot of code). I just wanted to show off a different possibility, which I like.
Happy coding,
MK42
ZLIB:
It''s a compression library, which implements the algorithm used in ZIP-Files. It''s also used in PNG files. You can get it at ftp://ftp.freesoftware.com/pub/infozip/zlib/
What I do:
Essentially, what I do is pretty simple. I have a manager class which is responsible for opening specific resources (images, other files, etc...). Now, at the beginning of my program I tell the manager class that it is responsible for a path, for example "IMAGES". Then the manager checks, whether there is a directory called "IMAGES". If there is, an archive class is created, which handles all the file stuff for directories. If there is no directory, the manager will look for a file (it tries to locate IMAGES.ZIP, IMAGES.DAT, IMAGES.PAK, and a few more). If the file is found, it is treated as a ZIP Archive and an archive class is created, which handles all the file stuff for ZIP-Files. That way, you can just tell the manager class:
TextureManager.Open("texture.tga");
and it does everything necessary. The actual program just doesn''t CARE where the file comes from, the manager and the archive classes handle all the difficult stuff. Now, this system is pretty tightly integrated into several projects of mine, so I can''t directly give it to you (my managers are application specific and I use a file-in-memory representation), but if you are interested in pursuing this, I can probably part with some code for the ZIP-File stuff. It won''t compile, since you need some more pieces for it to work, but you could take a look at how you can load ZIP-Files. Just send me a mail (koegler@uni-koblenz.de).
Resource files might be simpler to work with (and it also saves you a lot of code). I just wanted to show off a different possibility, which I like.
Happy coding,
MK42
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement