Packing all multimedia in one file

Started by
3 comments, last by negflar 17 years, 11 months ago
Hello, I would want to package all image of my game in one file like a .dat file. How can i do this? At moment i have various bmp image that i load (with SDL) with IMG_Load("image.bmp"). Tank's
Advertisement
You can zip it, and extract it when you load data from your game.
That's probably the easiest way to do it, it might save you some disk space as well. :)
I don't know about SDL but the way I do this with DirectDraw is to have a tool that converts my bitmaps to raw RGB Quads which are saved to a file. I can then structure the file how I want and include additional information like image size and offsets. When I load them onto a surface I use Win32 StretchDIBits which requires a windows device context to the surface and bung the RGB quad data back on the surface like that.

Don't know if SDL gives you a DC to its bitmap types.
Using a virtual file system like PhysFS, you can have all of your game data in zip files and still read them in like a normal directory heirarchy. When you use this method, you'll be reading in surfaces via RWops. There a lot of information on how to read in surfaces via RWops here.
Rob Loach [Website] [Projects] [Contact]
Hello,
Fist of all many tank's for reponse.
I have tried to use RWops but i have some problems when i try to load a gzipped image . here the code:

file = gzopen("sfondo.bmp.gz", "r");fileSize = gzread(file, buffer, 1550000);rw = SDL_RWFromMem(buffer, fileSize);sfondo = SDL_LoadBMP_RW(rw, 0);applica_superficie( bgX, bgY, sfondo, screen );


applica_superficie function is my function for blitting surface with SDL_BlitSurface.

Here prototype:
void applica_superficie( int x, int y, SDL_Surface* source, SDL_Surface* destination )

The problem is taht the image is not loaded and i can see only a black screen.

What's the problem?

Tank's



This topic is closed to new replies.

Advertisement