Page 1 of 1
Loading a picure on the fly
Posted: Sat Feb 10, 2018 10:03 am
by Stefan
Is there a possibility to load pictures on the fly?
At the moment I know only code to load images at program start.
Re: Loading a picure on the fly
Posted: Sun Feb 11, 2018 10:52 am
by Alexander
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
Posted: Sun Feb 11, 2018 11:49 am
by Stefan
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.
Re: Loading a picure on the fly
Posted: Sun Feb 11, 2018 12:28 pm
by Alexander
Use timer.
Re: Loading a picure on the fly
Posted: Mon Feb 12, 2018 9:52 am
by Dirk Geppert
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())