PureBoard
http://forums.purebasic.com/german/

CustomFilterCallback() custom parameter! (Windows x64)
http://forums.purebasic.com/german/viewtopic.php?f=8&t=31454
Seite 1 von 1

Autor:  Mijikai [ 08.05.2019 10:06 ]
Betreff des Beitrags:  CustomFilterCallback() custom parameter! (Windows x64)

Da es keinen Custom Paramater für den Callback gibt habe ich mal was zusammengebastelt :)
Warum es diesen nicht von Haus aus gibt ist mir ein Rätsel.

Code:
Code:
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

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/