Android Question BitmapCreator v4.73 draws unwanted lines

Discussion in 'Android Questions' started by Syd Wright, Jun 16, 2019.

  1. Syd Wright

    Syd Wright Active Member Licensed User

    I wondering whether there might be something wrong with drawing polygons in BitmapCreator v4.73.
    The top code draws unwanted lines from the top left corner of an imageview (pixel X=0, Y=0) to some of the objects on the OSM maps that I am rendering (picture attached):
    Code:
    Sub DrawPolyOpen2(Color As Int, Wid1 As Int)    'Causes unwanted lines problem
        Dim Rhombus As BCPath
        
    Dim brush As BCBrush = BC1.CreateBrushFromColor(Color)
        Rhombus.Initialize(PolyX1(
    0),PolyY1(0))
        
    For i=1 To PolyLen1-1
          Rhombus.LineTo(PolyX1(i),PolyY1(i))
        
    Next
        BC1.DrawPath2(Rhombus, brush, 
    False, Wid1)
    End Sub

    Sub DrawPolyOpen2(Color As Int, Wid1 As Int)     'No problems at all (with the same Poly data)
        Dim X1, Y1, X2, Y2 As Long
        X1=PolyX1(
    0)
        Y1=PolyY1(
    0)
        
    For i=1 To PolyLen1-1
          X2=PolyX1(i)
          Y2=PolyY1(i)
          BC1.drawline(X1,Y1,X2,Y2,Color,Wid1)
          X1=X2
          Y1=Y2
        
    Next
    End Sub
    Any thoughts?
     

    Attached Files:

  2. Syd Wright

    Syd Wright Active Member Licensed User

    I have found the cause: it happens when two points at the start of the polygon are exactly the same:
    After isolating one of culprets, this, for example, is the contents of the X and Y array:

    2153, 1150, 2153, 1150, 2171, 1147, 2171, 1148, 2175, 1179, 2150, 1182, 2147, 1168, 2156, 1166, 2153, 1150

    Apparently, if the initialization coordinates of the Rhombus: Rhombus.Initialize(PolyX1(0),PolyY1(0))
    are the same as the next polygon coordinates: Rhombus.LineTo(PolyX1(1),PolyY1(1))
    then this problem occurs! The code probably subtracts both points which results in 0,0 i.e. the origin of the Imageview.

    I can't avoid that sometimes this occurs, because that is part of the Open Street Map raw data that I use as input for the polygons.

    Can this be resolved please?

    PS: For the moment I have temporarily solved it with this work-around:
    Code:
    Sub DrawPolyOpen2(Color As Int, Wid1 As Int)        'Uses BC2
        Dim i As Long
        i=
    0
        
    If PolyX1(0) = PolyX1(1And PolyY1(0)=PolyY1(1Then i = 1   'Workaround
        Dim Rhombus As BCPath
        
    Dim brush As BCBrush = BC2.CreateBrushFromColor(Color)
        Rhombus.Initialize(PolyX1(i),PolyY1(i))
        i=i+
    1
        
    Do While i < PolyLen1
          Rhombus.LineTo(PolyX1(i),PolyY1(i))
          i=i+
    1
        
    Loop
        BC2.DrawPath2(Rhombus, brush, 
    False, Wid1)
    End Sub
     
    Last edited: Jun 16, 2019
  3. Erel

    Erel Administrator Staff Member Licensed User

    I've fixed it for the next update. The solution is similar to your code.
     
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