internet image in ImageGadget?

Just starting out? Need help? Post your questions and find answers here.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

How's this?

Code: Select all

UseJPEGImageDecoder()

ProcedureDLL Read_File(file.s)  
  #INTERNET_FLAG_RELOAD = $80000000 
  Bytes.l = 0 
  *html  = AllocateMemory(50000)
  hInet.l = InternetOpen_("networkmaestro.com", 1, #Null, #Null, 0) 
  If hInet 
    hURL.l  = InternetOpenUrl_(hInet, file, #Null, 0, #INTERNET_FLAG_RELOAD, 0) 
    If hURL 
      If InternetReadFile_(hURL, *html, 50000, @Bytes) 
        CatchImage(0,*html, bytes)
        InternetCloseHandle_(hURL) 
      Else 
        ProcedureReturn 0
      EndIf 
    Else 
      ProcedureReturn 0
    EndIf    
    InternetCloseHandle_(hInet) 
  Else 
    ProcedureReturn 0
  EndIf 
  ProcedureReturn bytes
EndProcedure

If Read_File("http://www.networkmaestro.com/dreamer2.jpg")
  If IsImage(0) 
    If OpenWindow(0,0,0,ImageWidth(0),ImageHeight(0),"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
      If CreateGadgetList(WindowID(0))
        ImageGadget(0,0,0,0,0,ImageID(0))
        Repeat:Until WaitWindowEvent()=#WM_CLOSE
      EndIf
    EndIf
  EndIf
endif
Last edited by netmaestro on Sat Mar 17, 2007 1:25 pm, edited 2 times in total.
BERESHEIT
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: internet image in ImageGadget?

Post by PB »

Code: Select all

; Win 98 or above ONLY, due to needing DeleteUrlCacheEntry API.

Procedure Download(url$,file$)
  DeleteUrlCacheEntry_(url$) ; Remove from cache first (if there).
  URLDownloadToFile_(0,url$,file$,0,0) ; Now download remote file.
EndProcedure

UseJPEGImageDecoder()

jpg$="c:\kylie-minogue.jpg"
Download("http://www.kylie-minogue.sztunie.pl/kylie-minogue.jpg",jpg$)

OpenWindow(0,200,200,600,428,"test")
CreateGadgetList(WindowID(0))
LoadImage(0,jpg$)
ImageGadget(0,0,0,600,428,ImageID(0))
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
DeleteFile(jpg$)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Well your picture's nicer than mine, I'll concede that!
BERESHEIT
hss
User
User
Posts: 69
Joined: Thu Mar 08, 2007 6:02 pm

Post by hss »

yes! super-b..
Post Reply