Here is some hackish way to add a additional custom parameter to the not so CustomFilterCallback()
Code for x64 (needs a test image):
Code: Select all
EnableExplicit
UseJPEGImageDecoder()
Procedure.i FilterImageCallback(X.i,Y.i,ColorSrc.i,ColorDst.i)
Protected *parameter
!mov rax,[rsp + 150h] ;<- locate the image structure
!mov rax,[rax + 20h] ;<- extract the custom parameter
!mov qword[p.p_parameter],rax
Debug *parameter
ProcedureReturn ColorSrc
EndProcedure
Procedure.i FilterImage(*Buffer,Path.s = #Null$)
Protected image.i
Protected backup.i
Protected *parameter.Integer
If *Buffer
image = CatchImage(#PB_Any,*Buffer)
Else
If Path
image = LoadImage(#PB_Any,Path)
EndIf
EndIf
If IsImage(image)
*parameter = image + $20 ;<- pointer to the image structure (vacant spot afaik)
backup = *parameter\i ;<- make a backup just to be safe
If StartDrawing(ImageOutput(image))
DrawingMode(#PB_2DDrawing_CustomFilter)
*parameter\i = 123456789 ;<- set the custom parameter
CustomFilterCallback(@FilterImageCallback())
Box(0,0,1,1) ;<- process one pixel
StopDrawing()
Else
FreeImage(image)
image = #Null
EndIf
*parameter\i = backup ;<- restore the image structure
EndIf
ProcedureReturn image
EndProcedure
FilterImage(#Null,"test.jpg")
End