embedding image file in source, and use them from there... |
Asmodehn Shade
Guest
|
Hi Everyone,
I am currently using SDL to read a small bmp file and use it ( as a default icon ) I would like to store the image somehow in the source code, to get rid of the file dependency. And therefore I guess use SDL_CreateSurfaceFrom(void* pixels,...) instead of SDL_LoadBMP(char* filename). Although I dont really want to duplicate the SDL_LoadBMP code, I d like to know the easiest way to do that, just for few well known images... Has anyone already done it ? Thanks a lot for your help. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060124/810eecea/attachment.html |
|||||||||||
|
embedding image file in source, and use them from there... |
Jim Tilander
Guest
|
Take a look at the file SDL_rwops.h, it defines a simple little class with a
virtual table (ok, in C) for reading and writing to an abstract source/destination. SDL_LoadBMP is really a macro that points to a load function that takes one of these structures as an argument. Something like this: unsigned char g_startOfBitmapMemoryArray[] = { #include "mybitmap.inl" }; SDL_LoadBMP_RW( SDL_RWFromConstMem( g_startOfBitmapMemoryArray, sizeof(g_startOfBitmapMemoryArray), 1 ); To easily create the .inl file, use binary2.py at http://www.tilander.org/jim/pythoncookbook.shtml ... Cheers, Jim On 1/23/06, Asmodehn Shade <asmodehn at gmail.com> wrote:
An HTML attachment was scrubbed... URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060123/ef7007ef/attachment.htm |
|||||||||||||
|
embedding image file in source, and use them from there... |
Stanis³aw Morguñ
Guest
|
maybe you should try .xpm files look under the hood, and you will see ( open them in your text editor ) apator10 at wp.pl ---------------------------------------------------- Grypa? Damy rad?! Sprawd? jak jej zapobiega?, a je?li ju? za p??no ...jak leczy? - grypa.wp.pl http://klik.wp.pl/?adr=www.grypa.wp.pl&sid=636 |
|||||||||||||||
|
embedding image file in source, and use them from there... |
embedding image file in source, and use them from there... |
Asmodehn Shade
Guest
|
Mmm interesting what you said about zipfiles...
But my goal is not to make everything available from one binary... See, I am writing a library to simplify using SDL (I know it s already simple, but still...) . As an example one call to my lib and you can create a window with basic event handling. To achieve this kind of goal you need some default behaviour and default data. At the moment my library actually depends on only one little image file : the icon for the window. I dont want the build to mess around with this file, and I dont want users to have to put the file in the correct place before using the library... Thats why embedding the file in the source code looks the good solution to me. I was able to get the raw code of the whole file but using it is not really simple. I think I am gonna have a look at the RWOps to use them to read my data from memory... Thanks a lot all for your help. 2006/1/25, Ryan C. Gordon <icculus at icculus.org>:
An HTML attachment was scrubbed... URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060125/99486306/attachment.htm |
|||||||||||||||
|