DefineVirtualFile() and file image or sound

Find quick help here to get you started with Hollywood

DefineVirtualFile() and file image or sound

Postby sinisrus » Mon Sep 18, 2017 6:07 pm

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
sinisrus
 
Posts: 199
Joined: Tue Apr 21, 2015 5:43 pm

Re: DefineVirtualFile() and file image or sound

Postby zylesea » Mon Sep 18, 2017 9:44 pm

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"
Code: Select all
my_thumb = DefineVirtualFile(fullpath$, thumbstart$, thumbend$-thumbstart$, "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.
zylesea
 
Posts: 156
Joined: Tue Feb 16, 2010 1:50 am
Location: Westfalen/Germany

Re: DefineVirtualFile() and file image or sound

Postby sinisrus » Tue Sep 19, 2017 12:15 pm

Zylesea

OK is it possible for you to show me le content of the file fullpath$ please ?
sinisrus
 
Posts: 199
Joined: Tue Apr 21, 2015 5:43 pm

Re: DefineVirtualFile() and file image or sound

Postby zylesea » Tue Sep 19, 2017 4:38 pm

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.

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
zylesea
 
Posts: 156
Joined: Tue Feb 16, 2010 1:50 am
Location: Westfalen/Germany

Re: DefineVirtualFile() and file image or sound

Postby sinisrus » Wed Sep 20, 2017 8:07 am

ok in the example it is written that the virtual file contains several files
but if I understand many file links instead?
sinisrus
 
Posts: 199
Joined: Tue Apr 21, 2015 5:43 pm

Re: DefineVirtualFile() and file image or sound

Postby zylesea » Wed Sep 20, 2017 4:07 pm

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.
zylesea
 
Posts: 156
Joined: Tue Feb 16, 2010 1:50 am
Location: Westfalen/Germany

Re: DefineVirtualFile() and file image or sound

Postby sinisrus » Thu Sep 21, 2017 11:46 am

Ok thank you
sinisrus
 
Posts: 199
Joined: Tue Apr 21, 2015 5:43 pm

Re: DefineVirtualFile() and file image or sound

Postby airsoftsoftwair » Thu Sep 21, 2017 6:35 pm

zylesea wrote:Accessing "image.png" instead of vf$ would probably fail


Yes, it will just look for a normal file named "image.png" then.
User avatar
airsoftsoftwair
 
Posts: 2239
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany


Return to Newbie questions

Who is online

Users browsing this forum: No registered users and 3 guests

cron