Hi I am using the following code for draw inside an image and save this with the change.
I get this code from some example in the board.
How do I to erase the lastest line drawed, when I use colors.transparent I see a black line.
I get this code from some example in the board.
How do I to erase the lastest line drawed, when I use colors.transparent I see a black line.
B4X:
Sub Process_Globals
Dim fromx,fromy,tox,toy As Int
End Sub
Sub Globals
Dim Obj1 As Reflector
Dim Panel1 As Panel
Dim picCanvas As Canvas
Dim bm As Bitmap
Dim Button2 As Button
Dim Button3 As Button
Dim color2 As Int
Dim DestRect As Rect
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim bd As BitmapDrawable
bd.Initialize(LoadBitmap(File.DirAssets, "h1.jpg"))
bd.Gravity = Gravity.FILL
Activity.Background = bd
picCanvas.Initialize(Activity)
color2 = Colors.Red
Obj1.Target = Activity
Obj1.SetOnTouchListener("Panel1_OnTouch")
Button2.Initialize("Button2")
Button2.Text = "Clear"
Button3.Initialize("Button3")
Button3.Text = "Save"
Activity.AddView(Button2,0,0,100%x,60dip)
Activity.AddView(Button3,0,60dip,100%x,60dip)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Panel1_OnTouch(viewtag As Object, action As Int, X As Float, Y As Float, motionevent As Object) As Boolean
Select action
Case Activity.ACTION_DOWN
fromx = X
fromy = Y
picCanvas.DrawCircle(fromx, fromy, 2dip, color2, True, 3dip)
Case Activity.ACTION_UP
tox = X
toy = Y
picCanvas.DrawCircle(tox, toy, 2dip, color2, True, 3dip)
Case Activity.ACTION_MOVE
tox = X
toy = Y
picCanvas.DrawLine(fromx,fromy,tox,toy,color2, 3dip)
fromx = tox
fromy = toy
End Select
Activity.Invalidate
Return True
End Sub
Sub Button2_Click
color2 = Colors.Transparent
End Sub
Sub Button3_Click
Dim Out As OutputStream
bm.Initialize3(picCanvas.Bitmap)
Out = File.OpenOutput(File.DirRootExternal, "Test2189.png", False)
bm.WriteToStream(Out, 100, "PNG")
Out.Close
End Sub