Page 1 of 1

LoadBrush() from data$ ????

Posted: Tue Mar 23, 2010 1:28 am
by Tuxedo
I wrote a simple routine that extrat the thumbs from Exif header of JPEG images...
Now my question was:
There's a way to load directly the brush from the data extracted without write it back to disk before?
To exlpain it better:

- I have:

data$ = ReadString(1, length)

Now in data$ I've my little jpeg...
My routine continues in that way:

OpenFile(2, "RAM:pippo.jpg", #MODE_WRITE)
WriteString(2, data$, length)
Thumb = LoadBrush(Nil, "RAM:pippo.jpg")


In that way it works perfectly but I've to load it after write it...
I think that now I've a passage more than what I really need...I'm wrong?

PS Naturally if I've to write it I will use T: to do that...

Sorry for stupid questions!

Re: LoadBrush() from data$ ????

Posted: Tue Mar 23, 2010 3:25 pm
by Allanon
Why not to try VirtualFile features for this purpose, I think it should be the right answer to your problem ;)


Re: LoadBrush() from data$ ????

Posted: Tue Mar 23, 2010 8:45 pm
by Tuxedo
Thank you for the reply but...
From the Hollywood guide explanation, the VirtualFile function will put file in another big one file...
I simply want(if possible(in some way) to load the file directly from my "data$" var withou open/write/close and than reload it...
I also check the MEM functions but it seems to me that was the same thing than with ReadString() function(Maybe more slower too since if I use memory functions have to do more passages to get the ram:xxx.jpg file wrote...)
Maybe I'm explained worng in the last post...sorry! My engllish wasnt so good! :P

Re: LoadBrush() from data$ ????

Posted: Tue Mar 23, 2010 9:02 pm
by Allanon
No Tuxedo you have explained well, but I was thinking that you could define a virtual file representing the thumbnail, then you can load it as a brush, just to explain things suppose your image has the following format (just inventing, I don't know where the thumbs are stored inside jpg images):

000000 - 150000 Image data
150001 - 165000 thumbnail data
165001 - 175000 Other data

you have to do:

Code: Select all

my_thumb = DefineVirtualFile("Image.jpg", 150001, 15000, "thumbnail.jpg")
LoadBrush(1, my_thumb) 
If you have the offset and the length of the thumbnails is really simple to define and read the thumbnails inside a file!

Re: LoadBrush() from data$ ????

Posted: Tue Mar 23, 2010 9:39 pm
by Tuxedo
I'm REALLY a NEWBE! I miss completely that nice VirtualFile function!
It works perfectly! And was exactly the elegant code I'm looking for(no weird and non usefull fiels around the system!)!
However I've done some speed comparison (with a timer) and no relevant differences was revealed...
Any Exif jpeg file (from 0.3 to 10 Mpx) tooks from 8 to 50 milliseconds to be scanned and have the thumb displayed...and from old code to the new no relevant and concrete differences(I've done 3 test for file for every code...), sometime the old was faster sometimes the pratically have the same speed :)
Maybe a real difference may occur on AmigaOS3.x on classic hw...but that wasnt the real problem I think...
So all was really fast :)

Thank you again for the help!