PDA

View Full Version : How to load a Bitmap from a resource?



Paulius
16-04-2003, 07:17 PM
I just started exploring SDl and I was wondering if anybody has an idea how to load a bitmap onto an SDL_Surface from a resource?

savage
26-04-2003, 12:37 AM
I just started exploring SDl and I was wondering if anybody has an idea how to load a bitmap onto an SDL_Surface from a resource?

Hi Paulis,
You will need to Load the Resource into a stream ( check this article to find out how http://community.borland.com/article/0,1410,16081,00.html ) and then use JEDI-SDL's LoadSDLBMPFromStream function which exists in SDLStreams.pas and returns a PSDL_Surface.

Remember to free your PSDL_Surface when you finish with them, to avoid memory leaks.

Paulius
26-04-2003, 12:43 PM
Thanks for your help, but I wanted to put a bitmap into an executable to avoid space waste, because it's only 3k. I want to make the whole application under 32k so I'll have to pass on VCL units. I have seen people loading a bitmap from resource with LoadImage windows API call and bliting it onto DirectDraw surface (I think SDL uses DirectDraw in windows?) so there should be a way to do this without streams.