Drawing on a bitmap

ukimiku

Active Member
Licensed User
Longtime User
I would like to draw a line on a bitmap and display it in an imageview. I try (in Sub Globals):
B4X:
Dim b As Bitmap: b.InitializeMutable(382dip, 248dip)
Dim c As Canvas: c.Initialize2(b)
Dim v As ImageView: v.Initialize("v"): Activity.AddView(v, 184dip, 27dip, 382dip, 248dip)
v.Bitmap = b

Later I try to draw a line on the bitmap via the canvas:
B4X:
c.Drawline(10dip, 10dip, b.Width - 30dip, b.Height - 40dip, Colors.Blue, 2dip)
v.Invalidate

But no line to be seen.
Could you please help me find the mistake (in my concept & code)? Thanks.

Regards,

EDIT: Thanks for thinking about this. Turns out the drawing was working, but the imageview was under a panel holding the activity layout.
v.bringtofront was needed before v.invalidate
 
Last edited:
Top