'gfxEffects libary by bunnX
'This libary adds some postfx image effects to your gfx screenbuffer.
'install
'########
'#######
'	-copy static/libgfxPostProcess.a in your fbc\lib\win32
'	-or copy gfxPostProcess.dll to your project exe folder 
'###
'##
'# 

#Define init_ok 		1
#Define init_error	0
#Define GFX_RED		&hFFFF0000
#Define GFX_GREEN		&hFF00FF00
#Define GFX_BLUE		&hFFFF00FF
#Define GFX_C8			7
#Define GFX_C64		6
#Define GFX_C512		5
#Define GFX_C65536	4

Type fbImageForGFX
	version		As Integer
	bpp			As Integer
	w				As Integer
	h				As Integer
	pitch			As Integer
	reserved(3)	As Integer
End Type

Extern "C"
	#Inclib "gfxPostProcess"
	Declare Function initEffects Alias "initEffects" ( w As Integer, h As Integer, sc As Long Ptr ) As Integer
	Declare Sub gfxFill Alias "gfxFill"( c As Long )
	Declare Sub gfxCls Alias "gfxCls"()
	Declare Sub gfxInvert Alias "gfxInvert"() 
	Declare Sub gfxGrayscale Alias "gfxGrayscale"() 
	Declare Sub gfxBrightness Alias "gfxBrightness"( level As Integer )
	Declare Sub gfxContrast Alias "gfxContrast"( level As Single )
	Declare Sub gfxEmboss Alias "gfxEmboss"()
	Declare Sub gfxSephia Alias "gfxSephia"()
	Declare Sub gfxSoftGlow Alias "gfxSoftGlow"( level As Integer )
	Declare Sub gfxColorAnd Alias "gfxColorAnd"( c As Integer )
	Declare Sub gfxPruneColor Alias "gfxPruneColor"( mode As Integer )
	Declare Sub gfxRGBNoise Alias "gfxRGBNoise"( level As Integer, seed As Single )
	Declare Sub gfxBlur Alias "gfxBlur"( level As Integer )
	Declare Sub gfxSharpen Alias "gfxSharpen"( level As Integer )
	Declare Sub gfxSobelGradient Alias "gfxSobelGradient"()
	Declare Sub gfxMonochrome Alias "gfxMonochrome"()
	Declare Sub gfxFlipV Alias "gfxFlipV"()
	Declare Sub gfxFlipH Alias "gfxFlipH"()
	Declare Sub gfxFlipHV Alias "gfxFlipHV"()
	Declare Sub gfxDeInit Alias "gfxDeInit"()
End Extern


Function gfxInitEffects( image As Any Ptr = 0 ) As Integer
	
	Open Cons For Output As #1
	If (image) Then
		Dim As fbImageForGFX Ptr fbimg
		fbimg = image
		If fbimg->version <> 7 	Then Return 0
		If fbimg->bpp <> 4 		Then Return 0
		Return initEffects(fbimg->pitch /4, fbimg->h, image + 32) 
	Else
		
		Dim As Integer w, h, depth
		If (screenptr) = 0 Then Return 0
		ScreenInfo w, h, depth
		If depth <> 32 Then Return 0
 		Return initEffects(w, h, screenptr) 
	EndIf
	

End Function
