Jump to content
  • Advertisement

Archived

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

ByteMe95

What to do with all these bmps??

This topic is 6012 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

I''m almost done with my game, and I have around 40 bmp files in an images dir. Before I release I thin it would be nice if i could combine them all into one file and load the iamges straight away from there. But I would also like to do this without changing too much code. Right now I have a basic sprite class that everything is based on, and i load the image by doing something like sprite.Load("images/image.bmp"); So does anyone know of an easy way to accomplish this with minimal effort?? thanks ByteMe95::~ByteMe95() Cerebrum Software

Share this post


Link to post
Share on other sites
Advertisement
Is all images bitmap files? In that case you can use write a simple RLE compress algorithm to minimize the size of all the files and decrypt them so that the end user can´t see them. Look it up at wosit site. Very simple. Should not take more then a couple of days to write.



Zeblar Nagrim, Lord of Chaos

Share this post


Link to post
Share on other sites
Ya, write a encryptor and decryptor class that scans a file and saves it to a new file(usually .dat or something). Then with the DeleteFile function, delete the original file. With the decryptor, decrpyt it back to its original form at runtime. Then you can load it. When you clean up the program, delete the bitmap again.

This is great for any format.

[Edited by - kmsixpence on October 17, 2005 6:56:12 PM]

Share this post


Link to post
Share on other sites
Hmm, I suppose the last option is a possibility, I have to write an encruption/decryption algorithm anyway cause i have some text files with level data and high scores, etc, which i have to encrypt anyway.
But in regard to the bitmaps, i was thinking of maybe being able to combine them all into one big WAD file of some sort, is there any simple way to do that? (And Zeblar, 2 days is much too long)

ByteMe95::~ByteMe95()
Cerebrum Software

Share this post


Link to post
Share on other sites
to store loads of files, you could always use something like pak files. i made my own packing format just the other day and got a nifty app to create them. extracting can be simple, seeing as you created the format.

you wont even need to extract the file for the game, just search for the file to load in the file, then read in the bmp data. easy.

for encryption, say for the high score file, just XOR each character, then to decrypt, XOR each character again, simple but effective.

alan

Share this post


Link to post
Share on other sites
hmm, i never thought of xor-ing, sounds like a good idea
Generally when i would encrypt files i would use some mathematical formula involving +,-,/,* of some sort
i think i''ll try that
as for paking the files, I''m using
DDLoadBitmap(lpDD, filename, 0, 0); to the load the data into the surface, if i pak the data into one file I dont believe I can use that, so what can I do?

ByteMe95::~ByteMe95()
Cerebrum Software

Share this post


Link to post
Share on other sites
This isn''t the best method but here''s how i would do it. You can put this maybe in a class. Oh and by the way, I never tried it out because I don''t have the need to right now but I would assume it would work. Get a pointer to the bitmap file. Then open it and read all the text in the first bitmap. Create a new file pointer to a .pak file and open it/create it. Write all the information from the first bitmap to that file. Then close it and open the second bitmap file in a new file pointer. Open the pak file again but this time with the append specifier for adding to an end of a file. Then make up a certain code, such as aaeeiioouu. Add that to the end of the file and copy all of the information from the second bitmap to the pack file after that certain code. Keep repeating until all the bitmaps are in the pak file.

During runtime, before you load the bitmaps, scan the pak file and copy the information to new files, a new file each time the certain code is found. That certain code divides the bitmaps inside the file. Name the new file that you found a .bmp file. Keep repeating until all of the files in the pak file are created. Now you load them like they were already there in your initialization. After you have completed your game loop and you have it all done, use the deletefile function to delete all the actual data, the .bmps. This would hide the bmps from the user, unless they minimized the program and modified them, lol. Oooh, another good idea, after you copy the bitmap file information, encrypt the .pak file so it would be tough for the user to modify the actual data permantly.

[Edited by - kmsixpence on October 17, 2005 6:32:55 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by ByteMe95
hmm, i never thought of xor-ing, sounds like a good idea
Generally when i would encrypt files i would use some mathematical formula involving +,-,/,* of some sort
i think i'll try that
as for paking the files, I'm using
DDLoadBitmap(lpDD, filename, 0, 0); to the load the data into the surface, if i pak the data into one file I dont believe I can use that, so what can I do?

ByteMe95::~ByteMe95()
Cerebrum Software


DDLoadBitmap? im gonna guess thats direct draw load bitmap function or something? (please correct me)

i thought you had your own bitmap loader. however, it seems not. in which case im not sure on what you can do.

well, you could always pack all your bitmaps into a pak/wad/whatever packing file, then extract them all at runtime (then on the programs end you delete them) i've made a library for doing this (doesnt take long at all) however, the only draw back being that it doubles the amount of the bitmaps while the game is running (say 40bmps in the pak and 40bmps extracted).

then again, you could always call a function to extract just the single bitmap as its needed. simply call a function such as:

ExtractFromPak("mybmp.bmp")

but that would need to be called just before every DDLoadBitmap()

it depends really on how much time and effort your willing to put into it.


edit: i just checked msdn, using DDLoadBitmap, is it not possible to load that bitmap from a resource? inwhich case, you could just compile all the bitmaps into the game exe, so 1 big exe and no seperate bmps?

edit again: mkay, i was too slow replying, but i did add some ideas so uhm, yeh


Edited by - Bezzant on December 31, 2001 9:40:47 PM

Edited by - Bezzant on December 31, 2001 9:43:27 PM

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!