Hello,
I do not understand too much how to do the documentation is a bit too light
I know you have to create a file that contains the files in "MyFile.dat"
and in if I put some text I do => DefineVirtualFile ("hugeresource.dat", 0, 150, "montext.txt")
but for an image or a sound I do not understand in what form or how I can put them in the .dat file ???
do I have to convert the image file to text file and copy the text into my .dat file?
if it is possible to have a complete example?
thank you
DefineVirtualFile() and file image or sound
Re: DefineVirtualFile() and file image or sound
I think I don't really understand what you are actually asking for..?
DefineVirtualFile() is used to make a virtual file (i.e. no host DOS action involved, it's done 100% within the programs allocated RAM chunk) from a real file and use this file then just if it were a real file. Same for definevirtualfilefromstring, but here the source is not a file, but a string variable.
Here's a case from a program from me that uses virtual files to handle thumbnail views of larger jpgs. First I seek for the beginning and end of the thumbnail chunk (thumbstart$, thumbend$) within the source file (fullpath$), once I found that I copy the according part from the original file to a virtual file named "thumbnail.jpg"
From here you can use my_thumb as handle to the virtual file, for example
loadbrush(1,my_thumb) to load the thumbnail (of which the virtual file consists) to a brush.
It's pretty much exactly as in the manual's example.
DefineVirtualFile() is used to make a virtual file (i.e. no host DOS action involved, it's done 100% within the programs allocated RAM chunk) from a real file and use this file then just if it were a real file. Same for definevirtualfilefromstring, but here the source is not a file, but a string variable.
Here's a case from a program from me that uses virtual files to handle thumbnail views of larger jpgs. First I seek for the beginning and end of the thumbnail chunk (thumbstart$, thumbend$) within the source file (fullpath$), once I found that I copy the according part from the original file to a virtual file named "thumbnail.jpg"
Code: Select all
my_thumb = DefineVirtualFile(fullpath$, thumbstart$, thumbend$-thumbstart$, "thumbnail.jpg")
loadbrush(1,my_thumb) to load the thumbnail (of which the virtual file consists) to a brush.
It's pretty much exactly as in the manual's example.
Re: DefineVirtualFile() and file image or sound
Zylesea
OK is it possible for you to show me le content of the file fullpath$ please ?
OK is it possible for you to show me le content of the file fullpath$ please ?
Re: DefineVirtualFile() and file image or sound
The files can be anything. It's a variable that get filled by a filerequester. It's just some path to some original file the virtual file gets derived from.
Here's a bit more code within some context (slightly changed from the original program), it's a routine to quickly extract embedded thumbnails off .jpgs or tiffs.
Here's a bit more code within some context (slightly changed from the original program), it's a routine to quickly extract embedded thumbnails off .jpgs or tiffs.
Code: Select all
fullpath$=FileRequest("Select drawer", "jpg|jpeg|tiff",#REQ_NORMAL, mypath$) ; get a real file
OpenFile (1,fullpath$)
my_rawjpg$=ReadString(1,30000)
thumbstart$=(PatternFindStrDirect(my_rawjpg$,"\255\216",100)) ;patternmatching
thumbend$=(PatternFindStrDirect(my_rawjpg$,"\255\217",100))
If thumbend$ <> -1 And thumbend$>thumbstart$
my_thumb = DefineVirtualFile(fullpath$, thumbstart$, thumbend$-thumbstart$, "thumbnail.jpg") ;make virtual file
ret_valx, table=IsPicture(my_thumb) ;check whether the virtual file is actually a picture
Re: DefineVirtualFile() and file image or sound
ok in the example it is written that the virtual file contains several files
but if I understand many file links instead?
but if I understand many file links instead?
Re: DefineVirtualFile() and file image or sound
The filename of the virtual file seems not to matter at all (except the file name extension for a type casting by Hollywood). To work with the virtual file you rather need the handle to the virtual file, just like with the example from the documentation:
vf$ = DefineVirtualFile("hugeresource.dat", 100000, 32768, "image.png")
LoadBrush(1, vf$, {LoadAlpha = True})
Accessing "image.png" instead of vf$ would probably fail, as the virtual file is not present in any file system and hence there is no path to the virtual file. Instead you need the handle (vf$) to work with the virtual file.
That's how I understood it.
vf$ = DefineVirtualFile("hugeresource.dat", 100000, 32768, "image.png")
LoadBrush(1, vf$, {LoadAlpha = True})
Accessing "image.png" instead of vf$ would probably fail, as the virtual file is not present in any file system and hence there is no path to the virtual file. Instead you need the handle (vf$) to work with the virtual file.
That's how I understood it.
Re: DefineVirtualFile() and file image or sound
Ok thank you
- airsoftsoftwair
- Posts: 5443
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: DefineVirtualFile() and file image or sound
Yes, it will just look for a normal file named "image.png" then.zylesea wrote:Accessing "image.png" instead of vf$ would probably fail