Page 1 of 1

Quick display of an ImageID

Posted: Thu Aug 07, 2008 12:38 am
by Mistrel
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

BMP Splash Image

Posted: Tue Jun 02, 2009 11:51 pm
by Hot Pockets
Neither of these show how to load a bmp image file and then dispaly it on the screen. I ried sustuting Bmp for the jpeg with the name of the bmp image file I'm trying to use but it comes up didn't intialize. I don't know what that means. This is a great image of a nite sky and i really need it for my splash screen .How can i make this file work[StarMap3.bmp]?