Well not sure this will help, but in VB somtimes i need to store jpg’s and what not into a resrouce file. As we all know BMP’s are quite large so I prefer something smaller and what not such as jpg, or png, ect…
Anyhow the problem is that in order to add these formats i need to add them as a binary data file, which of course does not allow me to them into a pictures property. So I get around it by litterlly writting the file to a temp path reading it and then killing it.
I see no reason why this could not be modified to work for you.
Here is my source snip, hope it helps.
Public Function LoadPictureResource(ByVal ResourceID As String, ByVal sResourceType As String) As Picture
On Error Resume Next
Dim sFileName As String Dim bytResourceData() As Byte Dim iFileNumOut As Integer sFileName = strPath & "x.jpg" Kill sFileName bytResourceData = LoadResData(ResourceID, sResourceType) iFileNumOut = FreeFile Open sFileName For Binary Access Write As #iFileNumOut Put #iFileNumOut, , bytResourceData Close #iFileNumOut Set LoadPictureResource = LoadPicture(sFileName) Kill sFileName On Error GoTo 0
sure u can load with MiniFmod (memory).
first thing, u need “Bin2C.exe”
this utile will create for u a *.h file of ur xm sound.
that means it will translate it to HEX values.
next u can use Fexp.exe to optimize effects.h of the original miniFmod that include, optimization is only for the created *.h file with bin2c.
next that u have the let say “music.h” (ya u created that with: “bin2c *.xm music music” command line).
next of course u need to implemnt the MiniFmod source that came with the zip from Fmod.org.
than well, u need to change some code around to make a new memory loading c file (edit copy etc from the source).
than what u do is to add the music.h to ur resource (vc): insert->resouce->import
find u file and add it, call the reource XM or something ;P
once its added u need to load that file from resource straight to memory:
let say u have “play button” u use this code:
if (mod == NULL)
mod = FMUSIC_LoadSong(NULL, NULL);
now, as i said the “loadmusic.c” u need to create (copy and paste from the open source of minifmod, the memory load/read etc functions), also include the “music.h” in the header (#include music.h) and edit the code to read from it (in the memopen function).
now if everything goes ok, u have a loaded xm file playing from resource, with no dlls what so ever.
and for Stoping the file to play use this code :
if (mod != NULL)
* if u wont use that code for loading/playing u will face serious crashes over xp
bin2c will take x file and will generate an hex values, and it will increase size:
20k xm file -> 140 *.h file.
but with upx/aspack u can minimize and compress the exe files
i hope everything is kinda clear now as u got alittle more backround on how to use minifmod with no dlls and loading from resource.
<font size=-1>[ This Message was edited by: Bengaly on 2002-03-13 04:15 ]</font>
- Bengaly answered 15 years ago
mmhh it didn’t work for me … The FindResource return me always 0, but why ? I ve converted an xm file to hex with bin2c (sound.h), added it as a resource file ( new type “song” –> IDR_SONG1 ), added #include “sound.h” to my main file, called LoadSong with NULL parameters and FindResource with :
rec = FindResource(NULL, MAKEINTRESOURCE(IDR_SONG1), RT_RCDATA);
I ve also tested with reading the file as a raw file :
int x; memfile->length = SOUND_LEN; // SOUND_LEN = 18947 memfile->data = calloc(memfile->length,1); memfile->pos = 0; for (x= 0; x < SOUND_LEN; x++) memfile->data = &sound[x]; // sound is an array of static char representing raw data of the music
Where i am wrong ?? U ll be very helpfull if you find a solution …
Thanx in advance 😉
Please login first to submit.