Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Asclepius

Saving (and loading) several images into one file?

This topic is 5239 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! This is my first post and I've just registered, but I've been searching and reading this forums a *lot* for the past 2/3 weeks and I figured this was the best place for me to ask my question(s). There is a post similar to mine but the answers weren't what I wanted. How can I save several images (probably bitmaps) to one file and load them afterwards? I'm using devcpp with sdl to make a game. I've just begun but I don't want people to be able to mess around with the game's images when I put it up on my site for download.. So, I was wondering if there's a way of saving all images into one large file and load them from within the game. I've seen it done on a game called Uplink (http://www.introversion.co.uk/uplink , I think) and I think it was some kind of compression system or something.. If that's is not possible then is there a way of joining them with the final exe? (Tough I don't like the idea, it would make the executable *really* big. Thank's in advance for any answer. Asclepius [edited by - Asclepius on April 14, 2004 4:54:19 PM]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
If I recall correctly, Uplink just took all the game data, zipped them, renamed the zip files and XORed every bit in all the files by some number. The game then read in the data, XORed it again and performed the unzip funtion. You could write somthing similar. Or you could write a program that takes a filename, gets the binary size of the file and writes in as a package. Somthing like this:
File 1 = bitmap 10000 bytes
File 2 = text file 500 bytes
File 3 = text file 550 bytes
The game data file would be 11050 bytes long, plus a header which would include offsets for the locations in the file where the other 3 files are, and their sizes. The game would load all this in and seperate it into resource structures or class or whatever.

Share this post


Link to post
Share on other sites
I''ve done something very simular to that, where it creates a file of any filetype and combines them into one. In addition I use encryption to keep the files from being directly opened. I created another program to load it. The only problem that I encountered, was trying to load the image in DirectX. Instead for now, I have it just output the file to the origional files so that they can be loaded that way for now. I would like to know how to directly load the bitmaps from the file though. If you want the source code, email me:
guyaton@hotmail.com




~Guyaton

Share this post


Link to post
Share on other sites
There are lots of ways you can do it. If you want to keep it simple, you can just create your own file format. Maybe something like this:

Header
- int: size of header in bytes
- int: number of images in file:
- int array: number of bytes for each image block

Each image block:
- int: image width
- int: image height
- int: image color depth
- int: image size in bytes
- byte array: image data

Thus, your file would be a header plus the appropriate number of image blocks, which would be each to jump around and load whichever image you needed.

Share this post


Link to post
Share on other sites
once you do that, how do you load the bitmap into memory so that you can load it as a texture? That''s the part i''m having problems with.



~Guyaton

Share this post


Link to post
Share on other sites
DirectX has functions that take a memory address. I don''t recall there names, but they exactly like the file based load routines, only they load from memory. Like LoadSurfaceFromMemory or something like that.

Share this post


Link to post
Share on other sites
You could zip and then use the zlib library to read the zip file at runtime.

-----------------------------------------------------
Writer, Programer, Cook, I''m a Jack of all Trades
Current Design project: Ambitions Slave

Share this post


Link to post
Share on other sites
Or use my PAK file archive I wrote for this purpose... You can find information on what it is, and how it works in general on this page:
http://toolmaker.homeip.net/index.php?page=5

Since I still haven''t fixed my download script(Will start doing that today), I placed it in my upload folder. You can download the archive DLL, C++ headers required to use the interface(And a small wrapper for it) and documentation at http://toolmaker.homeip.net/upload/ToolPAKv110.zip

It''s simple to use, and the DLL is pretty small. It probably saves you the hassle of writing your own or use zlib. It doesn''t have compression, but does use encryption and CRC32 checks to ensure data integrity. It also supports multiple archives(You just have multiple archive objects or reuse one).

If you are going to use it, lemme know if you got any ideas suggestions for it.

Toolmaker



My site
/* -Earth is 98% full. Please delete anybody you can.*/

Share this post


Link to post
Share on other sites
quote:
Original post by OOCCO
Creating a PAK file format


What''s the point in that? Writing your own custom library, is kinda pointless when there are so many other utilities around, such as zlib, my pak archiver, etc.?

Toolmaker



My site
/* -Earth is 98% full. Please delete anybody you can.*/

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!