Saving (and loading) several images into one file?

Started by
16 comments, last by Asclepius 20 years ago
Thank''s for the replies. I''ll save the page for the other ideas but I think there are two things I might do:

1) I''ll encrypt the file and put a function in the game do decrypt it (I''m working on a encryption algorithm with a friend so I''ll probably use it), then, from the game, save the images back to bmp and load them (I''m using the SDL_LoadBMP function) and finally delete them again. Maybe I won''t need to write them to the disk, there''s probably a way of loading directly to SDL_Surface pointers but I''m sure I''ll figure it out.

2)Use the Toolmaker Pak Archiver, it would be extremely simple and I believe it would work right. Maybe, to make it even more harder to crack, encrypt the file with my own algorithm.

I''ll talk to my friend who''s making the game with me (not programming, he doesn''t know how - he designs the tiles and such and gives ideas) and then decide what is the best solution.

Probably I''ll choose the second one, for it would be a lot easier.

I believe this topic was answered completely, I don''t know if it has to be closed or something by me or by the sysadmins..

If anyone whishes to say something (more), I''ll be coming here regularly so don''t be afraid I don''t get to see your answer / idea / sugestion!

THANK YOU ALL again, it''s so good to know a place where your questions are answered well and quick!

If you find any error or something like that forgive me but english is not my main-language, I''m Portuguese.
Advertisement
quote: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.?
It's a good learning experience - why exactly did you write a PAK system if there are "so many other utilities around"? It's one adequate solution to his problem so I thought I'd mention it. Not everyone may want to use your utility or any other that is around.

[edited by - OOCCO on April 15, 2004 10:28:18 AM]
"The Holocaust was an obscene period in our nation's history. I mean in this century's history. But we all lived in this century. I didn't live in this century."...Governor George W. Bush, 9/15/95
Guyaton, couldn't a smart game player then Alt+Tab the game, copy the bitmap and save it elsewhere?

EDIT: I just noticed that the PAK file format article above mentioned use of the D3DXCreateTextureFromFileInMemory() function, so all you'd need to do is decrypt it in memory and load it. Wow, DX makes it so easy. Oh yeah, and that's assuming you're using DirectX...

Stay Clausal,

Red Sodium

[edited by - red_sodium on April 15, 2004 10:29:43 AM]
"Learn as though you would never be able to master it,
hold it as though you would be in fear of losing it" - Confucius
Quote from red_sodium:

"Guyaton, couldn't a smart game player then Alt+Tab the game, copy the bitmap and save it elsewhere?"

There are ways of disallowing the alt+tab and windows key (and such) which might give the player that chance.

However, the purpose here is not letting the player replace the graphics: he can do whatever he wants with them, I don't care as long as the game isn't altered.

Also, if none of the keys worked, a smart game player could do a printscreen, so there are always ways of "stealing" graphics.

I've been trying out the pak archiver from Toolmaker but I didn't got on well with it; I believe it used some win32 functions and I want to make a portable (as much as I can, anyway) game. I guess I'll stick to the first option..

[ correction to the 1 option ]
(1) I'll encrypt the file (my own format, as BriTeg sugested, containing all the images) and put a function in the game do decrypt it (I'm working on a encryption algorithm with a friend so I'll probably use it), then, from the game, save the images back to bmp and load them (I'm using the SDL_LoadBMP function) and finally delete them again. Maybe I won't need to write them to the disk, there's probably a way of loading directly to SDL_Surfaces / sprites but I'm sure I'll figure it out.



[edited by - Asclepius on April 15, 2004 6:13:00 PM]
You can.. Should be pretty easy, actually, you just have to implement your own SDL_RWops to read from the pak-file and off you go. The LoadBMP is, as far as I know, just a macro that creates a standard RWop for reading from a file and passes that to the actual LoadBMP-function.

EDIT: Oh, and even if you don't, don't even start to think about disabling alt-tab.. You really annoy your users with that.


[edited by - Wuntvor on April 15, 2004 6:13:11 PM]
I''m going to recommend zlib, because I''m pretty sure it can read a file out of a zip without having to save the file again first.

Although encryption is another problem. There are a couple file encryption algorithms out there that you could use to encrypt the entire archive, XOR being the easiest.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
quote:Original post by Asclepius

I''ve been trying out the pak archiver from Toolmaker but I didn''t got on well with it; I believe it used some win32 functions and I want to make a portable (as much as I can, anyway) game. I guess I''ll stick to the first option..


I am glad that you at least tried it . But yeah, it uses Win32 functions and I don''t plan on changing that. I hate Linux, and thus I refuse to convert this into a crossplatfrom DLL/Shared Object. But thanks for trying.

Toolmaker




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

Toolmaker, no problem, if it was a win32-only game I would certainly use it.

BTW, why do you *hate* linux? I mean, I use both and don''t dislike none of them.. What do you find so bad about linux? I just started using it a couple weeks ago and I haven''t encountered problems so far.. Have you found lots? A bit off-subject but I was curious as I just started using it and I wanted to hear opinions on it.

Thank''s for your link anyway, I''ll use it if i do an app for windows! I think it''s really useful

Asclepius

This topic is closed to new replies.

Advertisement