Quick display of an ImageID
Posted: Thu Aug 07, 2008 12:38 am
I wrote this to quickly display the contents of an PureBasic image ID.
Code: Select all
Structure SplashImage
WndID.l
ImageID.l
ImageWidth.l
ImageHeight.l
ImageGadget.l
ThreadID.l
CloseWindow.l
EndStructure
Global Glob_SplashImage.SplashImage
Procedure SplashThread(ThreadID)
With Glob_SplashImage
Repeat: Delay(1)
Until Glob_SplashImage\ThreadID
If Not \WndID
\WndID=OpenWindow(#PB_Any,0,0,\ImageWidth,\ImageHeight,"",#PB_Window_BorderLess)
CreateGadgetList(WindowID(\WndID))
\ImageGadget=ImageGadget(#PB_Any,0,0,\ImageWidth,\ImageHeight,ImageID(\ImageID))
EndIf
Repeat: Delay(1)
SetGadgetState(\ImageGadget,ImageID(\ImageID))
Event=WindowEvent()
If OldWidth And Not OldWidth=\ImageWidth And OldHeight And Not OldHeight=\ImageHeight
ResizeWindow(\WndID,#PB_Ignore,#PB_Ignore,\ImageWidth,\ImageHeight)
EndIf
OldWidth=\ImageWidth
OldHeight=\ImageHeight
Until \CloseWindow
EndWith
EndProcedure
Procedure DisplaySplash(ImageID)
Glob_SplashImage\ImageID=ImageID
Glob_SplashImage\ImageWidth=ImageWidth(ImageID)
Glob_SplashImage\ImageHeight=ImageHeight(ImageID)
If Not Glob_SplashImage\ThreadID And Not IsThread(Glob_SplashImage\ThreadID)
Glob_SplashImage\ImageID=ImageID
ThreadID=CreateThread(@SplashThread(),ThreadID)
Glob_SplashImage\ThreadID=ThreadID
EndIf
EndProcedure
Procedure CloseSplash()
Glob_SplashImage\CloseWindow=1
Repeat: Delay(1)
Until Not IsThread(Glob_SplashImage\ThreadID)
CloseWindow(Glob_SplashImage\WndID)
Glob_SplashImage\CloseWindow=0
Glob_SplashImage\ThreadID=0
Glob_SplashImage\WndID=0
EndProcedure