LoadImage from web

BlitzMax Forums/BlitzMax Beginners Area/LoadImage from web

qim(Posted 2009) [#1]
Hi,

I try to load an image from my webserver, but my program hangs all the time. :-/

Local URL:String = "http://www.mywebsite.com/sprite.png"
Local Img:TImage = LoadImage(URL)
DrawImage Img,0,0


Img returns NULL, so the image is not loaded. If I locally load an image, it all works fine. Any ideas?

- Oliver


GfK(Posted 2009) [#2]
You need to use the prefix http::
Local URL:String = "http::www.mywebsite.com/sprite.png"
Local Img:TImage = LoadImage(URL)
DrawImage Img,0,0



qim(Posted 2009) [#3]
Ah, thanks! That helped. :-)


jkrankie(Posted 2009) [#4]
you'll probalby want to make sure that it has loaded before you use if though, otherwise your app will just crash!

Cheers
Charlie


xlsior(Posted 2009) [#5]
Note that some image formats can't be loaded directly, since the imageloader tries to seek in the stream... But you can get all of them work with one additional step:

Local pic:TImage=LoadImage(LoadBank("http::www.blitzbasic.com/img/brllogo-thin.png"))


That way the image is downloaded into a seekable memorybank first, before being passed on to the LoadImage function.