[SDL] Who brokes SDL compilation with gcc 2.95.3 ?

Mike Gorchak lestat at i.com.ua
Thu Jan 27 05:55:11 PST 2005


On Thu, 2005-01-13 at 19:21 +0100, Benjamin Deutsch wrote:
> Hi,
> 
> >>> I need to load a lot of images using too much memory space when loaded:
> >>> 152 images, 35kb each but in memory they are much bigger because of image
> >>> uncompression and byte alignment.
> >>> My idea is to read all the image data compressed in png format in memory
> >>> and load the images from memory instead of disk.
> 
> Try the following:
> 
> - Load the file into memory. Try the stdio.h functions, if you're using
>    C or C++.
> 
> - Create an SDL_RWOps structure with SDL_RWFromMeM:
>    http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fRWops
> 
> - Use the SDL_image library to load your images:
>    http://jcatki.no-ip.org/SDL_image/
>    Basically, IMG_Load_RW, IMG_LoadTyped_RW or IMG_LoadPNG_RW should
>    work.
> 
> However:
> 
> >> The only way this would take less space than just loading the images
> >> would be keeping the compressed data in memory and decompress it on the
> >> fly while blitting. I bet that's too slow to be of any practical value :(
> >>
> > i think he means it would be faster if the raw file was loaded into ram and
> > decompressed there.
> 
> I must agree here, without further information, we don't know what you 
> mean or whether this will actually help.
> 
> On the other hand, I've been daydreaming about converting a .png file to 
> a .o file, maybe through a .c file that contained
> 
>    unsigned char *my_image = {
>    0, 0, 0, 42, ...
> 
> and then having my image embedded in my binary. The benefits and 
> drawbacks of embedded images aside, is this already possible somehow?

Sure, I do it all the time. I have a little utility (call toch) that
converts any file, binary or otherwise, to a .c and .h file. There are
utilities like that available all over the net. If you want mine just
let me know. I can send it or post it along with an example make file
that uses it. It is good for including small numbers of images and
sounds in a program. 

		Bob Pendleton

> 
> Hope the above helps, though,
> 
>    Benjamin
> 
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
> 





More information about the SDL mailing list