when want to share a Graphic code on the forum, you say
"I would love to find a picture on the computer, which is in everyone"
so has to be that the example we share, although using the same image for all ....
then different ways to offer us
1 - include the image in Data .... hum that increases the code ...
2 - make an archive (zip) containing the picture ... it force have an accommodation somewhere to upload the code
3 - Gling! gling! (yes it's like that in my head when I find a lousy idea: lol:
use a picture available on the NET .... ha yeah,
but .... no luck Purebasic do not have a function for loading an image from the Net!
good no problem .... we will make it

Code: Select all
Procedure.l Loadimage_net(Adr$,nom_image$)
; By Dobro
;Adr$=adresse du fichier image a charger
;nom_image$ = nom qu'on donne a cette image
; la procedure renvoi l'Id de l'image recupéré
InitNetwork()
If ReceiveHTTPFile(Adr$, GetTemporaryDirectory()+nom_image$)
imagId=LoadImage(#PB_Any, GetTemporaryDirectory()+nom_image$)
DeleteFile(GetTemporaryDirectory()+nom_image$)
Debug "image récupérée !"
ProcedureReturn imagId
Else
Debug "Erreur"
EndIf
EndProcedure
and behold, the procedure in action, if it works you should see a cat at home ....
now, we can make Graphic codes using an image that everyone
will see ....
Code: Select all
UseJPEGImageDecoder()
Declare.l Loadimage_net(Adr$,nom_image$)
Enumeration
#win
#screen
Endenumeration
InitSprite()
InitMouse()
InitKeyboard()
Global image
Adr$="http://lapeniche.net/wp-content/uploads/2013/12/Chat.jpg" ; image a afficher qui viens du Net
nom_image$="Chat.jpg"
image=Loadimage_net(Adr$,nom_image$)
if OpenWindow(#win,10,10,1024,768,"test")
if OpenWindowedScreen(WindowID(#win),1,1,1024,768,1,1,1)
startdrawing(screenoutput())
if IsImage(image)<>0
ResizeImage(image,1024,768) ; pour faire entrer dans la fenetre
DrawImage(imageId(image),1,1)
Endif
Stopdrawing()
FlipBuffers()
Endif
Endif
;-boucle principale
Repeat
Repeat ; beurk !
Event = WaitWindowEvent(2)
Select Event
Case #PB_Event_Gadget
If EventGadget() = 0
End
EndIf
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
FlipBuffers()
;ClearScreen(RGB(0, 0, 0))
ForEver
;-zone procedure
Procedure.l Loadimage_net(Adr$,nom_image$)
; By Dobro
;Adr$=adresse du fichier image a charger
;nom_image$ = nom qu'on donne a cette image
; la procedure renvoi l'Id de l'image recupéré
InitNetwork()
If ReceiveHTTPFile(Adr$, GetTemporaryDirectory()+nom_image$)
imagId=LoadImage(#PB_Any, GetTemporaryDirectory()+nom_image$)
DeleteFile(GetTemporaryDirectory()+nom_image$)
Debug "image récupérée !"
ProcedureReturn imagId
Else
Debug "Erreur"
EndIf
EndProcedure
; Epb
what? Ha .... yes, it is too simple to be thought of!

