6.10b7 CustomFilterCallback() error

Just starting out? Need help? Post your questions and find answers here.
hoerbie
Enthusiast
Enthusiast
Posts: 136
Joined: Fri Dec 06, 2013 11:57 am
Location: DE/BY/MUC

6.10b7 CustomFilterCallback() error

Post by hoerbie »

Hi,

using the following example from the docs

Code: Select all

Procedure FilterCallback(x, y, SourceColor, TargetColor)
    ; Take only the Red component from the Source, do not modify the others
    ProcedureReturn RGBA(Red(SourceColor), Green(TargetColor), Blue(TargetColor), Alpha(TargetColor))
  EndProcedure
  
  UseJPEGImageDecoder()

  If OpenWindow(0, 0, 0, 400, 200, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    LoadImage(1, #PB_Compiler_Home + "examples/3d/Data/Textures/clouds.jpg")
  
    If CreateImage(0, 400, 200) And StartDrawing(ImageOutput(0))
      DrawImage(ImageID(1), 0, 0, 400, 200)
      
      DrawingMode(#PB_2DDrawing_CustomFilter)      
      CustomFilterCallback(@FilterCallback())
      Circle(100, 100, 100, $0000FF)   
      Circle(300, 100, 100, $000000)
      
      StopDrawing() 
      ImageGadget(0, 0, 0, 400, 200, ImageID(0))
    EndIf
    
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
  EndIf
I get an error message

Code: Select all

CustomFilterCallback(): The Procedure specified in '@Callback()' does not have the required argument or returntype.
I don't know if this is a general problem of the C compiler or only on mac, or maybe a problem of the docs?

Because in the docs it is written:
The SourceColor ... and the TargetColor .... Both colors are always 32-bit with alpha channel independent of the color depth of the output. The callback has to calculate the color that the target pixel should have after the drawing and return that.
But normally for PB it is told, that if NO type is given, the .i integer type will be used, that on 64-bit systems will be 64-bit and not the 32-bit for colors from the help.

Thanks, hoerbie
User avatar
mk-soft
Always Here
Always Here
Posts: 6202
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: 6.10b7 CustomFilterCallback() error

Post by mk-soft »

New since Beta 7 to avoid invalid value range ;)

Code: Select all

Procedure FilterCallback(x, y, SourceColor.l, TargetColor.l) ; <- Colors must be define as long
  ; Take only the Red component from the Source, do not modify the others
  ProcedureReturn RGBA(Red(SourceColor), Green(TargetColor), Blue(TargetColor), Alpha(TargetColor))
EndProcedure

UseJPEGImageDecoder()

If OpenWindow(0, 0, 0, 400, 200, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  LoadImage(1, #PB_Compiler_Home + "examples/3d/Data/Textures/clouds.jpg")
  
  If CreateImage(0, 400, 200) And StartDrawing(ImageOutput(0))
    DrawImage(ImageID(1), 0, 0, 400, 200)
    
    DrawingMode(#PB_2DDrawing_CustomFilter)      
    CustomFilterCallback(@FilterCallback())
    Circle(100, 100, 100, $0000FF)   
    Circle(300, 100, 100, $000000)
    
    StopDrawing() 
    ImageGadget(0, 0, 0, 400, 200, ImageID(0))
  EndIf
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
Link: https://www.purebasic.fr/english/viewto ... 45#p616845
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
hoerbie
Enthusiast
Enthusiast
Posts: 136
Joined: Fri Dec 06, 2013 11:57 am
Location: DE/BY/MUC

Re: 6.10b7 CustomFilterCallback() error

Post by hoerbie »

Hi,

thanks, then the (english) doc of the 6.10b7 is not up to date on Mac.

And in the case of making it stricter, I would then additionally expect an

Code: Select all

Procedure.l FilterCallback(x, y, SourceColor.l, TargetColor.l) ; <- Colors must be define as long
          ^
declaration for the return parameter, because it just as well gives back a color.

Greets, hoerbie
Post Reply