hi, kids.
how can i show up an internet loaded image (jpg/png..) in a ImageGadget? -- i'm getting it with the InternetReadFile-api..
after this, the image is stored in a variable...now: how can i give that var a valid ImageID()?
hope you got it ;-)
thanks for help.
internet image in ImageGadget?
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
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
Re: internet image in ImageGadget?
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.
"PureBasic won't be object oriented, period" - Fred.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada