Android Question Accelerated Surface Canvas and B4A Canvas on DrawCircle StrokeWidth set to high.

Michael Mejias

Member
Licensed User
Longtime User
Hello,
I have a circle and the strokewidth is set to high. It's fine when drawing it on view even if the strokewith is very high, but when I save it to file, Bitmap.WriteToStream, the output is different from what I saw on the canvas. It's like the strokewidth is using different size.

Here is my code in saving to file:

B4X:
Sub Addframe_Click
    AcSf2.Invalidate
    onionbitmap = AcSf2.Bitmap'IU.AlterColors(AcSf2.Bitmap,100,360,1) 'Set the bitmap alpha to 100


    Dim out As OutputStream
 
    out = File.OpenOutput(File.DirInternal,functions.currentframe & ".jpg",False)
    AcSf2.Bitmap.WriteToStream(out,100,"JPEG")
    out.Close
 
    functions.nextframe(functions.figurecount,x,y,con,w,cl,s,t,cnt)
 
    If functions.maxframe < functions.currentframe Then
        functions.maxframe = functions.currentframe
    End If
    functions.currentframe = functions.currentframe + 1
    AcSf.Invalidate
 
    theframes.addframe(AcSf2.Bitmap)
End Sub





And here is my code when drawing to canvas:


B4X:
Sub AcSf2_Draw(Ac As AS_Canvas)
    Dim a As Long
    Dim b As Long
    Dim fcon As Long
 
    Dim x1,y1,x2,y2 As Float
    For b=0 To functions.figurecount-1
        For a=1 To cnt(b)-1
            fcon = con(b,a)
            x1 = x(b,a)
            x2 = x(b,fcon)
            y1 = y(b,a)
            y2 = y(b,fcon)
            If t(b,a) = 0 Then
                Ac.DrawCircle(x2,y2,w(b,a)/2,cl(b,a),True,1dip,True)
                Ac.DrawLine(x1,y1,x2,y2,cl(b,a),w(b,a),True)
                Ac.DrawCircle(x1,y1,w(b,a)/2,cl(b,a),True,1dip,True)
            else if t(b,a) = 1 Then
                Ac.DrawCircle(x2/2 + x1/2,y2/2 + y1 / 2,Sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 -y1)))/2,Colors.White,True,w(b,a),True)
                Ac.DrawCircle(x2/2 + x1/2,y2/2 + y1 / 2,Sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 -y1)))/2,cl(b,a),False,w(b,a),True)
                'Log(Sqrt(((x(b,con(b,a)) - x(b,a)) * (x(b,con(b,a)) - x(b,a))) + ((y(b,con(b,a)) - y(b,a)) * (y(b,con(b,a)) - y(b,a) )))/2)
            End If
         
        Next
    Next

End Sub

Attach is image. There are two circles, the one with no hole is the one on the canvas, and the one with the hole is the one from file I loaded. Thanks.
 

Attachments

  • Screenshot_20181116-150429.png
    Screenshot_20181116-150429.png
    90.2 KB · Views: 321
Top