How to draw on a bitmap as shown below (can draw like point A to B)?
And can be saved and undo.
Does anyone have the full code?
I found some code, but could not combine
And can be saved and undo.
Does anyone have the full code?
I found some code, but could not combine
B4X:
'Make a new copy of the existing bitmap and save it
Dim bt As Bitmap
bt.InitializeMutable(b.Width,b.Height)
Dim cv As Canvas
cv.Initialize2(bt)
'Dim rect1 As Rect
'rect1.Initialize(0,0,b.Width,b.Height)
'cv.DrawBitmap(b,Null,rect1)
'c.DrawCircle(X,Y,5dip,Colors.Red,True,1dip)
'ImageView1.Invalidate
undo.Add(bt)
Select action
Case Activity.ACTION_DOWN
x1 = X
y1 = Y
c.DrawCircle(x1, y1, Radius, LineColor, True, 1dip)
rect1.Left = x1 - Radius
rect1.Top = y1 - Radius
rect1.Right = rect1.Left + LineWidth
rect1.Bottom = rect1.Top + LineWidth
ImageView1.Invalidate2(rect1)
Case Activity.ACTION_MOVE
x2 = X
y2 = Y
c.DrawCircle(x1, y1, Radius, LineColor, True, 1)
c.DrawLine(x1, y1, x2, y2, LineColor, LineWidth)
rect1.Left = Min(x1, x2) - Radius
rect1.Top = Min(y1, y2) - Radius
rect1.Right = Max(x1, x2) + LineWidth
rect1.Bottom = Max(y1, y2) + LineWidth
ImageView1.Invalidate2(rect1)
x1 = x2
y1 = y2
End Select