Grabbing an Image over the web

Blitz3D Forums/Blitz3D Beginners Area/Grabbing an Image over the web

CodeOrc(Posted 2011) [#1]
Hi All,

Been in the code archs, the forums, if I missed it please point me in the right direction.

What I wanna' do is pull an image from my server upon game boot

I have this that don't work.

 filein$="www.myserver.com/dir1/image1.jpg"

ad_image=LoadImage(filein$)


anyone doing this or know what to do?

thanx in advance

Last edited 2011


_PJ_(Posted 2011) [#2]
The reason that wont work as it stands is because Blitz (via its windows framework) cannot access files over the internet directly, any filepath beginning "http:\\" or "www." will fail since Load needs a path localised (LoadImage("../Image.bmp")), on a specified Harddrive path (LoadImage("C:\Folder\Image.bmp")) or a local LAN Server (LoadImage"\\Server\Share\Image.bmp") Otherwise, it's just not a path that Blitz can follow.

Before you can use the LoadImage command, you need to actually Downloa the image to somewhere, then Load it in from that dowload location.

Have a look in the CoeArcs for "BlitzGet" ( BlitzGetDeluxe?) or similar which is a great and very simple means to downloa web-based files

If you're still stuck, post back and I'l try top find the link and show an example :)


CodeOrc(Posted 2011) [#3]
Thank you Malice for the info, looking at it now.


Looks like I should be able to figure this out, but if not then yep, I'll post some code with a question ^^


_PJ_(Posted 2011) [#4]
This should be the sport of thing you need... It's basically just a complete copy of the BlitzGetDeluxe code with the example details changed a little to suit your requirements above (I also made sure it downloaded to the CurrentDir() rather than in the windows folder so it's easier to read the downloaded file back)

It's kinda messy overall, but at least you only really need to call the BlitzGet() function to achieve what you want.
If you feel more confident, of course, you can tinker with the functions, but mostly it shouldn't be necessary aside from ensuring your game isn't cluttered with the BlitzGet "Print" messages etc.