Page 1 of 1

embedding a file

Posted: Fri Sep 28, 2007 11:50 am
by JPulham
If i have a file (image, sound, font) how can I link it into the executable or a module, and how can I load a pointer to the data afterwards?

EDIT: I'm trying to use platform independent C code rather than Win32 etc.

Posted: Fri Sep 28, 2007 12:34 pm
by hybrid
Convert it to hex values, make a static byte array in C code and initalize it with those values (u8 data = {data...}) and create a memory read file from that.

Posted: Fri Sep 28, 2007 8:35 pm
by FlyingIsFun1217
For Hybrid: You can't put it's binary data into a container?

FlyingIsFun1217 :)

Posted: Fri Sep 28, 2007 10:05 pm
by sio2
bin2h

Posted: Sat Sep 29, 2007 12:09 pm
by JPulham
cheers :D
I thought I heard of a way using the linker... but thinking about it I think it was using Win32 resource files :?

Posted: Sat Sep 29, 2007 12:16 pm
by 3ddev
If you are willing to sacrifice cross-platform support, then Windows Resource Files are the best option, IMO. Here is nice tutorial :arrow: http://www.softlookup.com/tutorial/vc++/vcu10fi.asp