Is there a possibility to load pictures on the fly?
At the moment I know only code to load images at program start.
Loading a picure on the fly
Re: Loading a picure on the fly
Hello Stefan, something like this:
Code: Select all
Procedure Loaded(Type, Filename$, ObjectId)
Debug "Loading image: " + Filename$
EndProcedure
Procedure LoadingError(Type, Filename$, ObjectId)
Debug Filename$ + ": loading error"
EndProcedure
BindEvent(#PB_Event_Loading, @Loaded())
BindEvent(#PB_Event_LoadingError, @LoadingError())
OpenWindow(0, 0, 0, 320, 200, "Image", #PB_Window_ScreenCentered)
CanvasGadget(1, 10, 10, 180, 180)
ButtonGadget(2, 220, 20, 80, 20, "Load image 1")
ButtonGadget(3, 220, 50, 80, 20, "Load image 2")
ButtonGadget(4, 220, 100, 80, 20, "View image 1")
ButtonGadget(5, 220, 130, 80, 20, "View image 2")
Procedure GadgetEvent()
Select EventGadget()
Case 2
LoadImage(11, "https://www.spiderbasic.com/img/logo.png")
Case 3
LoadImage(12, "http://forums.spiderbasic.com/styles/anami/imageset/spiderbasic.png")
Case 4
StartDrawing(CanvasOutput(1))
DrawImage(ImageID(11), 0, 0)
StopDrawing()
Case 5
StartDrawing(CanvasOutput(1))
DrawImage(ImageID(12), 0, 50)
StopDrawing()
EndSelect
EndProcedure
BindEvent(#PB_Event_Gadget, @GadgetEvent())
Re: Loading a picure on the fly
The problem here is, you need two steps to show a picture.
Step 1 to push a button to load a picture and
Step 2 to show this picture.
I need a way to do this in 1 step, to load a picture and to show it immediately without any more steps.
Step 1 to push a button to load a picture and
Step 2 to show this picture.
I need a way to do this in 1 step, to load a picture and to show it immediately without any more steps.
-
- Posts: 284
- Joined: Fri Sep 22, 2017 7:02 am
Re: Loading a picure on the fly
Code: Select all
Procedure Loaded(Type, Filename$, ObjectId)
Select ObjectId
Case 11
StartDrawing(CanvasOutput(1))
DrawImage(ImageID(11), 0, 0)
StopDrawing()
Case 12
StartDrawing(CanvasOutput(1))
DrawImage(ImageID(12), 0, 50)
StopDrawing()
EndSelect
EndProcedure
Procedure LoadingError(Type, Filename$, ObjectId)
Debug Filename$ + ": loading error"
EndProcedure
BindEvent(#PB_Event_Loading, @Loaded())
BindEvent(#PB_Event_LoadingError, @LoadingError())
OpenWindow(0, 0, 0, 320, 200, "Image", #PB_Window_ScreenCentered)
CanvasGadget(1, 10, 10, 180, 180)
ButtonGadget(2, 220, 20, 80, 20, "Load image 1")
ButtonGadget(3, 220, 50, 80, 20, "Load image 2")
Procedure GadgetEvent()
Select EventGadget()
Case 2
LoadImage(11, "https://www.spiderbasic.com/img/logo.png")
Case 3
LoadImage(12, "http://forums.spiderbasic.com/styles/anami/imageset/spiderbasic.png")
EndSelect
EndProcedure
BindEvent(#PB_Event_Gadget, @GadgetEvent())