Create dummy images for forum example codes...

Share your advanced PureBasic knowledge/code with the community.
User avatar
Michael Vogel
Addict
Addict
Posts: 2807
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Create dummy images for forum example codes...

Post by Michael Vogel »

When trying a forum code example by just copy and paste it does not work sometimes because of missing images. Inserting the following code may help to be able to run the code quickly...

Code: Select all


; Define  - - -  LoadImage Dummy Procedure by Michael Vogel

	Procedure LoadImage_(id,name.s)

		Protected x,y,z

		CompilerIf 1
			#VoxMin=160
			#VoxMax=320
			#VoyMin=100
			#VoyMax=200

		CompilerElse
			#VoxMin=320
			#VoxMax=640
			#VoyMin=240
			#VoyMax=480

		CompilerEndIf

		If FileSize(name)>0
			ProcedureReturn LoadImage(id,name)

		Else
			x=#VoxMin+Random(#VoxMax-#VoxMin)
			y=#VoyMin+Random(#VoyMax-#VoyMin)
			z=CreateImage(id,x,y)

			If z
				If id=#PB_Any
					id=z
				EndIf
				StartDrawing(ImageOutput(id))
				Box(0,0,x,y,Random(#White))
				Circle(x>>1,y>>1,y>>1,Random(#White))
				StopDrawing()
				ProcedureReturn z
			EndIf

			ProcedureReturn #Null
		EndIf

	EndProcedure
	Macro LoadImage(a,b)
		LoadImage_(a,b)
	EndMacro

; EndDefine


;  - - -  Code example  - - - 

OpenWindow(0, 0, 0, 800,600, "-", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ImageGadget(1,	0,0,  		400,300,	ImageID(LoadImage(#PB_Any,#PB_Compiler_Home + "Examples/Sources/Data/PureBasic.bmp")))
ImageGadget(2,	400,0,		400,300,	LoadImage(33,#PB_Compiler_Home+"Examples/Sources/Data/GeeBee2.bmp"))
ImageGadget(3,	0,300,		400,300,	ImageID(LoadImage(#PB_Any,"C:\Purebasic\Examples\Sources\Data\AlphaChannel.bmp")))
ImageGadget(4,	400,300,	400,300,	LoadImage(99, "C:blah.bmp"))

Repeat
	Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow