load image from internet

BlitzMax Forums/BlitzMax Beginners Area/load image from internet

jkrankie(Posted 2006) [#1]
Is it possible to load an image from the intenet and use it as an image in a blitzmax application? If so, how.

I tried: global playerImage=loadimage("http::temp.macdock.com/charliesgames/BCG/blueflat.bmp")

but that didn't work.

Cheers
Charlie


tonyg(Posted 2006) [#2]
This?


jkrankie(Posted 2006) [#3]
Thanks


Booticus(Posted 2006) [#4]
Hey I can't get any of that original code to work in 1.22. Any clues? And in SuperStrict?

(From Xlsior's, from Skid's originally)

Graphics 400, 300, 0

DrawText "Getting Image...", 140, 144
Flip 

img:TImage = LoadImage(LoadBank("http::www.domain.com/images/image.jpg"))
If Not img Then RuntimeError "Unable to download image"

'Graphics img.width, img.height, 0 
Graphics 1024,768

DrawImage img, 0, 0
Flip

WaitKey()

End



tonyg(Posted 2006) [#5]
Does the image exist? The two graphics commands probably don't help.
Try this
Graphics 800,600
img:TImage = LoadImage(LoadBank("http::www.blitzbasic.com/img/brllogo-thin.png"))
If Not img Then RuntimeError "Unable to download image"
DrawImage img, 0, 0
Flip
WaitKey()
End



Booticus(Posted 2006) [#6]
Yeah it exists as far as I can tell, and its updated every 15 min or so. ;)

http: //www.ssec.wisc.edu/data/west/latest_westir.jpg

@tonyg - The code you suggested still fails and says "unable to download image".

Anyone having any luck? This worked back on the old versions of Blitz, not sure where I'm failing the IQ test. If anyone else IS able to get the code working to load and display an image, I'd really appreciate any help!

@jkrankie - Did you get it to work? Lemme know!!


tonyg(Posted 2006) [#7]
Did you get the same error using the brllogo-thin.jpg?
Trying the image from your example I get the 'unable to download image' message. However, when pasting the url I get a registration page.


Booticus(Posted 2006) [#8]
No I didn't get the same error using the brllogo-thin.jpg.! Hmmmm. Wierd. Pretty confused at this point. Tried a couple other direct links to images, even one from my own site. Same thing, unable to load image. Lame! :(


Yan(Posted 2006) [#9]
(From Xlsior's, from Skid's originally)
LOL...Is this some sort of conspiracy? |oD


Works fine here?
Graphics 400, 300, 0

DrawText "Getting Image...", 140, 144
Flip 

img:TImage = LoadImage(LoadBank("http::www.ssec.wisc.edu/data/west/latest_westir.jpg")) 
If Not img Then RuntimeError "Unable to download image"

Graphics img.width, img.height, 0 

DrawImage img, 0, 0
Flip

WaitKey()

End



tonyg(Posted 2006) [#10]
Yep, that works for me as well but then I *can* see that image if I paste the URL and change to http://


Yan(Posted 2006) [#11]
But that's what Booticus was trying to load, wasn't it?

I'm confused... 8o/


tonyg(Posted 2006) [#12]
That's the image but you've used a different url.


Booticus(Posted 2006) [#13]
Yeah Im trying to load that satellie image and save out "sanpshots" to the drive. I can see the image if I paste the URL into Firefox, of course, but within Blitz it fails out on me. Still scratching my head at this one....


Booticus(Posted 2006) [#14]
DUDE. Its working on my laptop here at work just fine now! But I RDC'd into my box at home, compiled, and it still errors out! :) Ah well, just chalking this one up to "wierdness occurence" and leaving it alone.


Yan(Posted 2006) [#15]
Does a straight dump of the bank work at home...
Graphics 400, 300, 0

DrawText "Getting Image...", 140, 144
Flip 

bank:TBank = LoadBank("http::www.ssec.wisc.edu/data/west/latest_westir.jpg") 
If Not bank Then RuntimeError "Unable to download image"

SaveBank(bank, RequestFile("Save Image...", "JPG files:jpg", True))

End
(just to rule out LoadPixmapJpeg())

??


Booticus(Posted 2006) [#16]
Damn Yan! That was it. I ran FrameworkAssistant and put the items in and it works!!!!

Framework brl.GLMax2D
Import brl.Max2D
Import brl.HTTPStream
Import brl.JPGLoader

' modules which may be required:
' Import BRL.PNGLoader
' Import BRL.BMPLoader
' Import BRL.TGALoader

Graphics 400, 300, 0

DrawText "Getting Image...", 140, 144
Flip 

img:TImage = LoadImage(LoadBank("http::www.ssec.wisc.edu/data/west/latest_westir.jpg")) 
If not img Then RuntimeError "Unable to download image"

Graphics img.width, img.height, 0 

DrawImage img, 0, 0
Flip

WaitKey()

End



Booticus(Posted 2006) [#17]
OH, PS I'll remove the actual link to the image, wonder if the site that I'm linking to is getting a lot of hits because of it. :)


tonyg(Posted 2006) [#18]
The readstream example might help and loadimage takes an http:: address for images.