Android Question B4XCanvas "setAntiAlias" method

Discussion in 'Android Questions' started by yiankos1, Dec 15, 2017.

  1. yiankos1

    yiankos1 Active Member Licensed User

    Hello my friend,
    How can i set antialias at b4x canvas?

    Code:
    Dim Obj1 As Reflector
       
    Dim Canv As Canvas
       Canv.Initialize(Btn1) 
    ' initialize on what you want
       Obj1.Target = Canv
       Obj1.Target = Obj1.GetField(
    "paint")
       Obj1.RunMethod2(
    "setAntiAlias"True"java.lang.boolean")
    This field(paint) does not exists.
     
  2. Peter Simpson

    Peter Simpson Expert Licensed User

    Hello try this, hopefully it will do the trick for you.

    Code:
    Sub CanvasRoutineSub
    'Draw canvas sub
         Dim CanvasMain As Canvas
             CanvasMain.Initialize(
    Activity)
         SetAntiAlias(CanvasMain)

         
    'Put the rest of your canvas code here
    End Sub

    'Set Anti Alias
    Sub SetAntiAlias (Canvas1 As Canvas)
         
    Dim Ref As Reflector
             Ref.Target = Canvas1

         
    Dim NativeCanvas As Object = Ref.GetField("canvas")
         
    Dim PaintFlagsDrawFilter As Object = Ref.CreateObject2("android.graphics.PaintFlagsDrawFilter"Array As Object(01), Array As String("java.lang.int""java.lang.int"))

         Ref.Target = NativeCanvas
         Ref.RunMethod4(
    "setDrawFilter"Array As Object(PaintFlagsDrawFilter), Array As String("android.graphics.DrawFilter"))
    End Sub
    Enjoy...
     
    Last edited: Dec 15, 2017
    DonManfred likes this.
  3. Erel

    Erel Administrator Staff Member Licensed User

    Antialiasing is enabled by default in B4XCanvas.
     
    yiankos1 likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice