DrawBitmapFlipped

alfcen

Well-Known Member
Licensed User
Longtime User
Hello Erel,

After drawing a flipped bitmap, I fail to make further drawings on the same view.

In the source code,

Canvas1.DrawCircle(xj, yj, 3dip, Colors.Black, True, 1)

does not draw, unless I do not flip the image.

Perhaps, a Label to flip and draw on is no good choice, but it should not make any difference whether using a Label or an ImageView.

Anyway, can you please check the DrawBitmapFlipped function?

Thanks
Robert


B4X:
Sub DrawPositions

   Canvas1.Initialize(labJupiter)
   Canvas1.DrawBitmapRotated(bmpJup,Null,DRect, -tilt * rad)   
   bmpJupRot.Initialize3(Canvas1.Bitmap)  'copy tilted image for Flipping
   
   For i = 1 To 4
          x = jx(i) * sc
         y = jy(i) * sc
             RotatePoint(x, 0, y, 0, 0, tilt)
      Canvas1.Initialize(labJupiter)
      Select Case optics
                Case 1
            x = x0 + xg
               y = y0 - yg
            xj = x0j + xg * 2
               yj = y0j - yg * 2
            'Canvas1.DrawBitmapFlipped(bmpJupRot,Null,DRect,False,False)
            labNS.Text = "N"            
         Case 2
            x = x0 - xg
            y = y0 + yg
            xj = x0j - xg * 2
            yj = y0j + yg * 2
            Canvas1.DrawBitmapFlipped(bmpJupRot,Null,DRect,True,True)
            labNS.Text = "S"
         Case 3
            x = x0 + xg
            y = y0 + yg
            xj = x0j + xg * 2
            yj = y0j + yg * 2
            Canvas1.DrawBitmapFlipped(bmpJupRot,Null,DRect,True,False)
            labNS.Text = "S"
         Case 4
            x = x0 - xg
            y = y0 - yg
            xj = x0j - xg * 2
            yj = y0j - yg * 2
            Canvas1.DrawBitmapFlipped(bmpJupRot,Null,DRect,False,True)
            labNS.Text = "N"
      End Select
      Canvas1.DrawCircle(xj, yj, 3dip, Colors.Black, True, 1)[COLOR="Red"] 'THIS FAILS AFTER FLIP BUT DRAWS CORRECTLY WITHOUT PRIOR FLIPPING[/COLOR]
      labJupiter.Invalidate      
       Next

End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I have checked it with this code and it works fine:
B4X:
Sub Globals
    Dim c As Canvas
End Sub

Sub Activity_Create(FirstTime As Boolean)
    c.Initialize(Activity)
    Dim r As Rect
    r.Initialize(100dip, 100dip, 200dip, 200dip)
    c.DrawBitmapFlipped(LoadBitmap(File.DirAssets, "image1.jpg"), Null, r, True, True)
    c.DrawCircle(150dip, 150dip, 50dip, Colors.Red, True,0)
    activity.Invalidate
End Sub
 
Upvote 0

alfcen

Well-Known Member
Licensed User
Longtime User
Thanks very much for looking into this. So, I can rule out a misfunction, which is good knowing. I have provisionally solved my problem by overlaying a panel on the flipped image. Perhaps there is a logical error or nesting problem in my Sub.
 
Upvote 0
Top