Archived

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

ByteMe95

What to do with all these bmps??

Recommended Posts

ByteMe95    122
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
Zeblar Nagrim    150
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
kmsixpence    134
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
ByteMe95    122
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
Bezzant    122
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
ByteMe95    122
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
kmsixpence    134
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
Bezzant    122
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
scaught    122
quote:
Original post by kmsixpence
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.


Egads, no! Not only is this method extremely slow and a waste of disk space (you''ll need (worst case) twice the disk space of the packed files) - it contributes to disk fragmentation.

The right answer is to read the .bmp format yourself directly from the packed file - if there''s no compression/encryption, it''s a straight read from a specific point in the file (store a ''table of contents'' at the beginning/end with the location/size of the files) and if it is compressed/encrypted then you need a decode step (in *memory*) in there.

Of course, if you''re constrained by other measures (eg, your using an external bmp loader that only works on a filename/file pointer) your options start limiting themselves...but it sounds like it''s something of your own doing...

Cheers,
-scott

(drunk posting rules)

Share this post


Link to post
Share on other sites
Bezzant    122
quote:
Original post by scaught
Egads, no! Not only is this method extremely slow and a waste of disk space (you'll need (worst case) twice the disk space of the packed files) - it contributes to disk fragmentation.

The right answer is to read the .bmp format yourself directly from the packed file - if there's no compression/encryption, it's a straight read from a specific point in the file (store a 'table of contents' at the beginning/end with the location/size of the files) and if it is compressed/encrypted then you need a decode step (in *memory*) in there.

Cheers,
-scott

(drunk posting rules)



ok, forget i said to extract all files at runtime or when there needed. but however, read in the bmp data straight from the pak.

edit: im tired. damn errors

Edited by - Bezzant on December 31, 2001 10:25:42 PM

Share this post


Link to post
Share on other sites
donmc    122
Maybe i''m missing something here, but for a *small* game why not compile all the bitmaps into the .exe itself?

You can use studio to generate a resource script for you. Then import the bitmaps into the script. Now they will be compiled into your .exe when you build.

If you are using, say, LoadImage() to load up your bitmaps you only have to change a couple paramaters and you''re good to go.

~don









"They that can give up essential liberty to obtain temporary safety deserve neither liberty nor safety."
- Benjamin Franklin

Share this post


Link to post
Share on other sites
Tjoppen    122
Just to make sure one thing: If you intend to encrypt using the XOR method, FOR GODS SAKE, USE MORE THAN ONE CHAR!

For instance, do not use a code that look like ''nja: ''a'' or ''4'' and so on...

Instead is should look: "this is the password" or more suitable: "fj&346nfU2S!%" or something...

But i guess it´s pretty obvious, but i wanted it to be said

Share this post


Link to post
Share on other sites
ByteMe95    122
I just checked out ddloadbitmap, it''s in ddutil.h that comes with the sdk, and it does in fact use LoadImage to load the file, and it even cehcks if it''s a resource first before it loads it as a file.
But I have about 13MB on images, is it bad to make an exe that big? Or does it not matter? What about speed issues?
Also, since it''s using LoadImage, is there a way to pass a pointer to data to that fucntion to load the bitmap, then I can read from my own pak file and pass a pointer to the necessary data.

ByteMe95::~ByteMe95()
Cerebrum Software

Share this post


Link to post
Share on other sites
ByteMe95    122
I just found something that looks promising, but im not sure how to use it. I still have the dx3 or dx5 sdk on my old HD and found fastfile. Anyone remember taht at all? If you remember the dx sample FoxBear, you might remember that it had all of it''s art files stored in one big .art file, and it used fastfile to access it and load it up. I looked through the code for foxbear and it''s really really sloppy, i almost threw up ;P
It doesnt use loadbitmap anywhere, it uses like 20 different functions, its very messy.
Well does anyone know anythnig about fastfile and if I could use it somehow and pass the data to LoadImage or some equivalent of it?

ByteMe95::~ByteMe95()
Cerebrum Software

Share this post


Link to post
Share on other sites
Bezzant    122
i think its gonna be easier for you if you just make all the bitmaps resources. regardless of the size of them, 13MBs of bitmaps is 13MB''s and its gonna be with your game no matter what. and loading from a resource is probably faster than loading from a pak file anyhow.

Share this post


Link to post
Share on other sites
rapso    180
there are exe-file packer and they pack as well as zip and the only thing to do is to pack the exe. most of my exes are 50% of the size or less...
your 13mb bmps should be compressed to less than 25% if you manually decrease the colorcount. for example convert them to 64k-colors and then back to 32bit.

rapso->greets()

Share this post


Link to post
Share on other sites
ByteMe95    122
all my bmps are 256 colored, they each have their own palette and the game runs in 16b mode, so I dont have to worry about palettes, so would the exe be small then?
someone on experts-exchange suggested I make a dll resource file with all the gfx, then use LoadLibrary and get handles to the image for use in LoadImage, but i never used dlls before, dont know how to make em or use em, anyone know if that''s a good idea?

ByteMe95::~ByteMe95()
Cerebrum Software

Share this post


Link to post
Share on other sites
JHL    150
Wasn''t there a artical resently call "making your own file system" or something like that it discussed taking all your little files and puting them in one big archive and then how to loading them. Search gamedev for "file system" I''m sure it will come up that would be your best bet for help.

Share this post


Link to post
Share on other sites
Zeusel    122
make a single bmp file containing all the bitmaps! in front do a register storing the start bytes of every bitmap, when loading a bitmap, search the register, and fseek() to your bitmap! then you can load it and have only one file!

Share this post


Link to post
Share on other sites
ByteMe95    122
That''s probably the most complicated solution any one has offered yet
Not to mention every time I want to load one bitmap I would have to load an ENTIRE 13mb bitmap to load it.
And I cant do fsee or any file pointer manipulations, cause as I''ve said I have to use LoadImage() for this task.
Thanks for the suggestion either way though, I appreciate every suggestion

ByteMe95::~ByteMe95()
Cerebrum Software

Share this post


Link to post
Share on other sites
Heaven    600
Why do you have to use LoadImage()?

Pack your BMP files into a single file. Write a short console program to do this. Make it able to unpack as well for utility''s sake.

Next, in your main program, load the data into a temporary buffer for whatever BMP you need (using some kind of index which you stored with the PAK file) and then bind that data to a LPDIRECTDRAWSURFACE.

Isn''t this doable?


Care,
Chris
Florida, USA

Share this post


Link to post
Share on other sites