The
GetHTTPFile documentation gives an example of this.
Essentially, you set a server host then you call gethttpfile and wait for it to complete. This will place the image in your working directory. You can then load it (LoadImage).
Dont forget to close the http connection and delete it too.
Some code...mainly based from the example of GetHTTPFile
// set window properties
SetWindowTitle( "Internet Image" )
SetWindowSize( 1024, 768, 0 )
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetWindowAllowResize( 1 ) // allow the user to resize the window
UseNewDefaultFonts( 1 )
spr=GetAGKSprite() // Gets a sprite from the gamecreators server
Angle# = 0
do
Print("This logo was downloaded from the AGK website...")
if getpointerpressed()=1 then end
inc Angle#, GetFrameTime()*90 // Spin the logo
SetSpriteAngle(spr,Angle#)
Sync()
loop
function GetAGKSprite()
spr=0
iSecure=0
szHost$="www.appgamekit.com"
iHTTP= CreateHTTPConnection()
ret=SetHTTPHost(iHTTP, szHost$, iSecure )
szServerFile$="images/appgamekit-logo-colour-white.png" // This is the AGK logo
szLocalFile$="AGKLogo.png"
szPostData$=""
f=GetHTTPFile( iHTTP, szServerFile$, szLocalFile$, szPostData$ )
ok=0
do
p#=GetHTTPFileProgress(iHTTP)
print("downloading ... " + str(p#))
ok=GetHTTPFileComplete(iHTTP)
if ok=1 then exit
if ok=-1 then exit
Sync()
loop
CloseHTTPConnection( iHTTP )
DeleteHTTPConnection( iHTTP )
if ok=1
spr=LoadSprite(szLocalFile$)
SetSpriteOffset(spr,GetSpriteWidth(spr)/2,GetSpriteHeight(spr)/2)
SetSpritePositionbyoffset(spr,GetDeviceWidth()/2,GetDeviceHeight()/2)
else
spr=createsprite(0)
setspritecolor(spr,255,0,0,255)
endif
endfunction spr